Reputation: 2249
I am using some types which are referenced in both the service and client. I made some changes to my WCF service. When I tried to update the service reference I got the following error:
Metadata contains a reference that cannot be resolved. 'net.tcp//xxxx/mex
To resolve this I added the mex end piont.
<endpoint address="mex" contract="IMetadataExchange" binding="mexTcpBindng" />
I was able to update the service reference. But it is creating its new type for my client even when "reuse types in referenced asssembly" option is checked in "configure service reference" setting. Why is it creating new types ignoring the "reuse type" setting? Is using ImetadataExchnge can cause this?
Upvotes: 2
Views: 2023
Reputation: 31780
This behavior happens because when you specify the Reuse types from referenced assemblies option, Visual Studio calls svcutil.exe under the hood with the /r flag specified.
Because svcutil.exe uses DataContractSerializer
to generate your code, and unfortunately this has a rather strict set of rules when it comes to parsing the service definition (XSDs contained in the WSDL definition), often it will be unable to generate the code. In this instance svcutil.exe will switch to use XmlSerializer
instead, which doesn't support the /r flag (or re-use). Hence you will not be able to re-use types.
If you can reference the actual service contract types (via binary reference) this is a much better solution as you can do away with service references all together.
You can also use WSCF.blue to generate your service contracts, as this has it's own custom serializer and supports re-use of types.
Upvotes: 2