DCSIMG
Generic List<T> Using svcutil.exe - Tamir Shlomi's Blog

Tamir Shlomi's Blog

Welcome to Tamir Shlomi's blog. All about .NET, OOP and SQL server

Generic List<T> Using svcutil.exe

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

Comments

Kalpp said:

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

# June 10, 2011 12:02 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: