TypedList - odd error in webservice

Posts   
 
    
Posts: 94
Joined: 23-Aug-2006
# Posted on: 28-Aug-2006 01:22:53   

I'd like to return a typedlist from a webmethod call, but it appears to run into a very odd error. Namely it produces a null ref exception with a stack as listed below (top of the trace)

[NullReferenceException: Object reference not set to an instance of an object.] System.Data.XmlTreeGen.FindTargetNamespace(DataTable table) +268 System.Data.XmlTreeGen.HandleColumn(DataColumn col, XmlDocument dc, XmlElement schema, Boolean fWriteOrdinal) +250 System.Data.XmlTreeGen.HandleTable(DataTable table, XmlDocument dc, XmlElement schema, Boolean genNested) +4334 System.Data.XmlTreeGen.SchemaTree(XmlDocument xd, DataTable dt) +892 System.Data.XmlTreeGen.Save(DataTable dt, XmlWriter xw) +79 System.Data.DataTable.GetSchema() +152

The strange part is that I can get it to excecute just fine if its not used as a web method. The TypedList executes and everything seems to work. This is the only TypedList used in the code, other web methods return entities and entity collections. They all work. Has anyone come across this sort of thing before?

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Aug-2006 07:39:28   

A typedList is a dataTable, and you can not return a dataTable from a webMethod, it's not marked as serializable, instead you should enclose it in a dataSet that can be returned from a webMethod.

Refer to the following link: http://support.microsoft.com/default.aspx?scid=kb;en-us;306134

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 28-Aug-2006 09:26:22   

DataTable is serializable starting from .net 2. This sounds like a different exception. Are you using .net 2? What happens if you pass a blank instance of DataTable? Are both client and server on .net 2? When does this error actually happen? etc.

Posts: 94
Joined: 23-Aug-2006
# Posted on: 28-Aug-2006 16:17:15   

Miha - as long as I dont return a typed list everything works fine. A datatable by itself has no problem.

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 28-Aug-2006 17:31:56   

Hi,

well, it seems the error has to do with the inherited DataTable namespace, then what happens if you set the Namespace property manually before the method returns?

Posts: 94
Joined: 23-Aug-2006
# Posted on: 28-Aug-2006 19:31:15   

Setting the TypedList.Namespace equal to the namespace of the webservice did not change the error message.

Posts: 94
Joined: 23-Aug-2006
# Posted on: 28-Aug-2006 19:34:29   

Just as a sanity check, have the templates in ver 2.0 changed already? I downloaded the product about 2 weeks ago which would make me think its as current as can be.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 29-Aug-2006 13:21:33   

Typed lists are always serialized through the datatable's Xml serialization method, LLBLGen Pro doesn't have extra code for supporting a typedlist over webservices as it doesn't need to. In .NET 1.1, you have to add the typedlist to a dataset and return that. In .NET 2.0, you can just return the typedview.

If a typedlist gives serialization issues over a webservice, it's an issue which can also happen for a normal datatable, as a typedlist is a normal datatable. The template changes made recently don't affect the typedlist for serialization purposes as there is no code necessary in the typedlist for serialization purposes.

Frans Bouma | Lead developer LLBLGen Pro