WCF - Built-in types not being reused
I have a WCF service library and another library that has a service reference to it in VS2010. "Reuse types in all referenced assemblies" is selected on the reference properties. When I scope in the client proxy namespace in the consuming libra开发者_如何学Cry code, I get this error:
WCF Error 'Exception' is an ambiguous reference between 'System.Exception' and 'My.Namespace.CoreService.Exception'
... where My.Namespace.CoreService
is the namespace of the service reference. My service library does not define a type called Exception
; the line in question is a catch block for the built-in Exception
type.
Strangely, when I added the service reference, four datasources were automatically created in the consuming project for built in types (System.Data.DataSet
, System.Data.DataTable
, System.ServiceModel.Channels.Message
and System.Xml.XmlElement
). These four types are used as return types in some of my OperationContracts.
Based on this it seems to me that the built-in types aren't being reused across the assembly boundaries. This doesn't make any sense to me, can anyone help?
Thanks
Do you have a type in the generated proxy code called exception (something the service was using as a type in its contract)? If so, you will have to fully qualify the types or use aliases
You can check to see the generated code my clicking on Show all files in solution explorer and opening up the service reference and reference.svcmap until you see reference.cs - this is the generated proxy code
精彩评论