Scraping KnownType attributes during SvcUtil and WSDL Code generation

261 views Asked by At

I have a WCF service with a mex endpoint for metadata. I use the SvcUtil through visual studio to generate client data contracts code (C#) while the service is running. SvcUtil adds KnownType attributes for the inherited and referenced types. I have a custom data contract resolver and have no use for these Known Types. How can I make SvcUtil or the WSDL Importer not tag all these types with KnownType attributes? My worst case scenario is to go through the file after code generation and remove these attributes, but I am hoping there is a cleaner way to do this.

1

There are 1 answers

4
RobV8R On

One option would be to add the known types to a configuration file. The configuration file doesn't need to be your app.config (or web.config). It could be called dummy.config.

When you run svcutil.exe, add the following parameter /svcutilConfig:dummy.config. When the client code is generated, your KnownType attributes should go away.

Here's another example of registering known types using a configuration file.