Commerce Server General - Problem with Simplist.Add in C#

This is Interesting: Free IT Magazines  
Home > Archive > Commerce Server General > October 2005 > Problem with Simplist.Add in C#





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Problem with Simplist.Add in C#
rlhendrix

2005-10-24, 10:38 am

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 for
‘Microsoft.CommerceServer.Runtime.IsimpleList.Add(ref object)’has
some invalid arguments.

royhendrix@comcast.net

2005-10-24, 10:38 am

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...

David Hargis [MSFT]

2005-10-24, 10:38 am


The code you have is correct.

--------------------
From: "royhendrix@comcast.net" <royhendrix@comcast.net>
Newsgroups: microsoft.public.commerceserver.general
Subject: Re: Problem with Simplist.Add in C#
Date: 17 Oct 2005 10:32:47 -0700
Organization: http://groups.google.com
Lines: 19
Message-ID: <1129570367.286856.266460@g14g2000cwa.googlegroups.com>
References: <VfSdnVoZy5kNSc7eRVn_vQ@giganews.com>
NNTP-Posting-Host: 134.134.136.5
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1129570372 2780 127.0.0.1 (17 Oct 2005 17:32:52
GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 17 Oct 2005 17:32:52 +0000 (UTC)
In-Reply-To: <VfSdnVoZy5kNSc7eRVn_vQ@giganews.com>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
.NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.0 jffwpr05.jf.intel.com:911 (squid/2.5.STABLE10)
Complaints-To: groups-abuse@google.com
Injection-Info: g14g2000cwa.googlegroups.com; posting-host=134.134.136.5;
posting- account=Q3KorAwAAAD0z1mEm9C1tlw2mM4E4raH

Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fastwebnet.it!tiscali!ne
wsfeed1.ip.tiscali.net!proxad.net!216.239.36.134.MISMATCH!postnews.google.co
m!g14g2000cwa.googlegroups.com!not-for-mail
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.commerceserver.general:3685
X-Tomcat-NG: microsoft.public.commerceserver.general

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...




--

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.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com