Thursday 31 January 2008

Excluding data contracts from a WCF service proxy class

It may happen that you do not want to generate your data contract classes in the proxy class of your service. For example, you might wish to deploy these data contracts in a separate assembly so as to share them between your different services.

To generate a WCF service proxy by excluding data contracts use the svcutil.exe command. You can execute this command in a visual studio command window.

Syntax: svcutil /et:<Fully qualified name of your data contract class> <Service URL>

Note that et: is the short form for excludeType. The above command is the same as:

svcutil /excludeType:<Fully qualified name of your data contract class> <Service URL>

The successful execution of the above command generates, in your current directory:
1. A proxy class
2. A configuration file for the proxy.

1 comment:

smmniceguy said...

If you want to exclude more than one data contract class, insert into your command a /et: per data contract you want to exclude.