Problem with Simplist.Add in C#
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
Problem with Simplist.Add in C#

 
Post new topic   Reply to topic    Windows Server Forum Index -> Commerce Server
Author Message
rlhendrix
Guest





Posted: Mon Oct 17, 2005 4:51 pm    Post subject: Problem with Simplist.Add in C# Reply with quote

I'm having a problem with adding to a SimpleList in C#

Here is the segment of C# code where I’m having trouble

SimpleList FreeListItems = LineItem[“orc_free_items”] as SimpleList

Dictionary FreeItem = new Dictionary()

FreeItem[“_sku”] = “12345”

FreeListItems.Add(FreeItem); <--------------- ERROR Line

Error from Visual Studio

The best overloaded method match fo
‘Microsoft.CommerceServer.Runtime.IsimpleList.Add(ref object)’ha
some invalid arguments
Back to top
royhendrix@comcast.net
Guest





Posted: Mon Oct 17, 2005 8:51 pm    Post subject: Re: Problem with Simplist.Add in C# Reply with quote

Tried the following and it seemed to work. Seems like you need to
create the com object using in non-interaop MSCS objects first and set
a typed reference to that new object and use that type reference to
build up the object. Then use the com reference for the Simplelist.Add
method.

object objNewDict = Server.CreateObject("Commerce.Dictionary")
Dictionary FreeItem = objNewDict as Dictionary;
FreeItem["_sku"] = "12345";

SimpleList FreeListItems = LineItem["orc_free_items"] as
SimpleList;
FreeListItems.Add(ref objNewDict);


If anyone knows a better way to do this or sees a problem with this
please post a reply.
Thanks...
Back to top
David Hargis [MSFT]
Guest





Posted: Thu Oct 20, 2005 12:51 am    Post subject: Re: Problem with Simplist.Add in C# Reply with quote

The code you have is correct.

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Commerce Server All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB