Generating new classes for Generic Collections

Topics: General Discussion Forum
Sep 17, 2010 at 8:53 AM

When trying to generate the classes for a service contract using a datacontract the tool for some reason creates new classes for any collections that you try to use instead of using the collections from the DataContract that are referenced. It uses the XML namespace of the service contract and creates a new namespace in the service and references these new collections of data contract objects intead of the correct referenced collections.

All messages have isWrapped=true and I am using the DataContractSerializer

For example, in my model I have a data contract class Quiz and a data contract collection (List) of Quizzes, QuizList. I then create a method in my service contract that returns a QuizList. However, instead of referencing the DataContracts.QuizList when generating the code from svcutil it creates a new class that uses the XML namespace called XMLNAMESPACE.QuizList : List<DataContract.Quiz>

 

Why does this happen? It only seems to happen for collections, all other datacontract objects work as expected.

Developer
Sep 17, 2010 at 11:02 AM

Hi,

The WSSF implementation for DC collections, for let's say a collection defined like a List<T> where T is your DC element in your array, you will get a generated collection class that derives from LIst<YourDCitem>. Then you will refer to the generated DataContractCollection from your MessageContract.

On the other hand, you can get some pointers to genericas in WCF in this thread: http://servicefactory.codeplex.com/Thread/View.aspx?ThreadId=76699

Regards,

Hernan