HashTable in Web Service
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngwebservices' list.


KHALLERAN@hklaw.com
Any idea why this code returns the following error?

[WebMethod]

public System.Collections.Hashtable GetUserInfo(string UserID)

{

System.Collections.Hashtable Info=new
System.Collections.Hashtable();

Info.Add("FName","Kevin");

return Info;

}

Server Error in '/UserInfo' Application.

_____

The type System.Collections.Hashtable is not supported because it implements
IDictionary.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NotSupportedException: The type
System.Collections.Hashtable is not supported because it implements
IDictionary.

Source Error:

Kevin A. Halleran

Holland & Knight LLP

Internet Programmer
Reply to this message...
 
    
Tim and Anne Royal
did you make sure to reference the System.Collections namespace in your file?

using System.Web;
using System.Collections;
using System.Web.UI;

etc
etc...

the system collections namespace isn't implicitly added to web services like it is non-code behind aspx files. i got tripped ont hat, too, until I added the reference as per above. Then, you should be able to use the Hashtable object *and* you don't have to preface it (instead of System.Collections.Hashtable, you can just use Hashtable if you prefer).

tim

----- Original Message -----
From: Click here to reveal e-mail address
To: aspngwebservices
Sent: Monday, July 15, 2002 10:18 AM
Subject: [aspngwebservices] HashTable in Web Service

Any idea why this code returns the following error?
[WebMethod]

public System.Collections.Hashtable GetUserInfo(string UserID)

{

System.Collections.Hashtable Info=new System.Collections.Hashtable();

Info.Add("FName","Kevin");

return Info;

}

Server Error in '/UserInfo' Application.

------------------------------------------------------------------------------

The type System.Collections.Hashtable is not supported because it implements IDictionary.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: The type System.Collections.Hashtable is not supported because it implements IDictionary.

Source Error:

Kevin A. Halleran

Holland & Knight LLP

Internet Programmer

| [aspngwebservices] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngwebservices.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
    
KHALLERAN@hklaw.com
Thank you for the response. Yes the collections reference is in my project.
The code works from both a windows form and a web form. Just not from a web
service. Any help would be appreciated.

Kevin

-----Original Message-----
From: Tim and Anne Royal [mailto:Click here to reveal e-mail address]
Sent: Monday, July 15, 2002 6:28 PM
To: aspngwebservices
Subject: [aspngwebservices] Re: HashTable in Web Service

did you make sure to reference the System.Collections namespace in your
file?

using System.Web;

using System.Collections;

using System.Web.UI;

etc

etc...

the system collections namespace isn't implicitly added to web services like
it is non-code behind aspx files. i got tripped ont hat, too, until I added
the reference as per above. Then, you should be able to use the Hashtable
object *and* you don't have to preface it (instead of
System.Collections.Hashtable, you can just use Hashtable if you prefer).

tim

----- Original Message -----

From: Click here to reveal e-mail address <mailto:Click here to reveal e-mail address>

To: aspngwebservices <mailto:Click here to reveal e-mail address>

Sent: Monday, July 15, 2002 10:18 AM

Subject: [aspngwebservices] HashTable in Web Service

Any idea why this code returns the following error?

[WebMethod]

public System.Collections.Hashtable GetUserInfo(string UserID)

{

System.Collections.Hashtable Info=new
System.Collections.Hashtable();

Info.Add("FName","Kevin");

return Info;

}

Server Error in '/UserInfo' Application.

_____

The type System.Collections.Hashtable is not supported because it implements
IDictionary.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NotSupportedException: The type
System.Collections.Hashtable is not supported because it implements
IDictionary.

Source Error:

Kevin A. Halleran

Holland & Knight LLP

Internet Programmer

| [aspngwebservices] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngwebservices.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngwebservices] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngwebservices.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
    
Robert Chartier

IDictionary cannot be serialized via XML, you will not be able to use the
hastable for a parameter over web services. change the data type to
something that can be serialized.

At 10:33 AM 7/16/2002 -0400, you wrote:

[Original message clipped]

Robert Chartier
Author and Developer
604-975-5590
Click here to reveal e-mail address
http://www.aspalliance.com/nothingmn/

Reply to this message...
 
    
Tim and Anne Royal
doh! sorry, i just remembered, you can't return a hashTable in a web service.

you'll have to return an array instead. Web Services are quite limited in what they can return, and any of the collections based stuff can be used, but not returned. At least that's what it was for me when calling web services from GET or POST requests. SOAP may be richer in what types it can return, but definitely for the first two are limited.

tim
----- Original Message -----
From: Click here to reveal e-mail address
To: aspngwebservices
Sent: Tuesday, July 16, 2002 7:33 AM
Subject: [aspngwebservices] Re: HashTable in Web Service

Thank you for the response. Yes the collections reference is in my project. The code works from both a windows form and a web form. Just not from a web service. Any help would be appreciated.

Kevin

-----Original Message-----
From: Tim and Anne Royal [mailto:Click here to reveal e-mail address]
Sent: Monday, July 15, 2002 6:28 PM
To: aspngwebservices
Subject: [aspngwebservices] Re: HashTable in Web Service

did you make sure to reference the System.Collections namespace in your file?

using System.Web;

using System.Collections;

using System.Web.UI;

etc

etc...

the system collections namespace isn't implicitly added to web services like it is non-code behind aspx files. i got tripped ont hat, too, until I added the reference as per above. Then, you should be able to use the Hashtable object *and* you don't have to preface it (instead of System.Collections.Hashtable, you can just use Hashtable if you prefer).

tim

----- Original Message -----

From: Click here to reveal e-mail address

To: aspngwebservices

Sent: Monday, July 15, 2002 10:18 AM

Subject: [aspngwebservices] HashTable in Web Service

Any idea why this code returns the following error?
[WebMethod]

public System.Collections.Hashtable GetUserInfo(string UserID)

{

System.Collections.Hashtable Info=new System.Collections.Hashtable();

Info.Add("FName","Kevin");

return Info;

}

Server Error in '/UserInfo' Application.

----------------------------------------------------------------------------

The type System.Collections.Hashtable is not supported because it implements IDictionary.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: The type System.Collections.Hashtable is not supported because it implements IDictionary.

Source Error:

Kevin A. Halleran

Holland & Knight LLP

Internet Programmer

| [aspngwebservices] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngwebservices.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngwebservices] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngwebservices.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngwebservices] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngwebservices.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
 
System.Collections.Hashtable
System.Collections.IDictionary
System.NotSupportedException




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com