Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't the /reference option to svcutil.exe work?

I'm attempting to use svcutil.exe to generate -only- the service contracts (interfaces) from a set of .wsdl files. When I do this (from an http-hosted wsdl), it picks up the included schemas and generates all the code for them.

Great.

What I would REALLY like to do, however, is to use a set of classes already generated from the schema files using the xsd.exe tool (the reasons for this are not important, suffice it to say that I need to have the types in one assembly, and the service contracts in another). I was successful in generating an assembly containing all the types.

The problem occurs when I attempt to get svcutil.exe to use the types in that assembly. My command line looks something like this:

svcutil /target:code /noconfig /reference:my_types.dll http://path/to/wsdl

This works fine, but the generated code contains duplicates of all the types in the my_types.dll file. It is my understanding from the documentation for svcutil.exe that this is the exact problem that the /reference: parameter is meant to overcome. In my case, however, it is not working.

Why?

like image 369
Mark Avatar asked Sep 02 '10 18:09

Mark


People also ask

Where SvcUtil EXE is located?

The ServiceModel Metadata Utility Tool can be found at the Windows SDK installation location, specifically %ProgramFiles%\Microsoft SDKs\Windows\v6.


2 Answers

Apparently it only works for DataContract types and not XmlSerializer types.

Link

like image 141
Andrew Avatar answered Jan 02 '23 04:01

Andrew


I had this problem. Something in a binary that I was referencing with /r was still being built again in the generated code. One of the objects being returned from one of the service functions was returning a datatable or some other horrid thing like that. I added a /r to the whole path to System.Data and that fixed it.

/r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Data.dll"

like image 40
David Osborne Avatar answered Jan 02 '23 05:01

David Osborne