Generic List<T> Using svcutil.exe

16 ביוני 2009

תגיות: , , ,
תגובה אחת

When using the svcutil.exe in order to create WCF proxy, any reflected collection will be converted into System.Array by default.


Good to know that this can be controlled using the svcutil.exe.
You can define the output data type for collections using the "/ct:" keyword.


For example, generating generic list collection (System.Collections.Generic.List<T>) will be done like that:


svcutil.exe http://localhost/Services/Sample.svc?wsdl /ct:System.Collections.Generic.List`1


This brings us all of the generics advantages and it is much more comfortable for working then the old System.Array.


You can choose other collection types like ArrayList, Collection etc.
Dictionary output data type can be controlled either.


When using Visual Studio 2008, there is ready to use menu where you can define that.
Right click your relevant service reference –> Configure service reference option and you can choose the output data type for collections and dictionaries types.


Hope this helps,
Tamir Shlomi

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. (*) שדות חובה מסומנים

תגובה אחת

  1. Kalpp10 ביוני 2011 ב 12:02

    When I try to run this command, it gives an error that it is not in Reference list. Please let me know the reason.

    להגיב