WCF Service Reference does not reuse types in existing assemblies (VS 2010 Beta 2)

一世执手 提交于 2019-12-05 15:12:48

问题


I'm looking for the best approach to share types (the actual classes, not proxies) between a WCF service and a client. To that end, I defined the classes in a separate assembly that both service and client reference. I selected "Reuse types in all referenced assemblies" when generating the service reference in the client, but References.cs is generated with proxies for all classes.

This is exactly the same question as this one, but I don't know how to implement the accepted solution. One difference is that I'm using VS 2010 Beta 2.

import the complete service contract in code form

or

create your own ClientBase-derived class. It's really very easy

Assuming this is the best approach, I would appreciate a good link that covers how to do this. Is the approach outlined in the linked answer the best one?


回答1:


I did two things in the same step. Not sure if one or both resolved the problem:

  1. Added a [DataContract(Namespace="My.Shared.Assemblys.Namespace")] to one of the classes in the shared assembly.
  2. Restarted VS 2010 Beta 2



回答2:


Had the same issue, but the I forgot to build assembly with DataContracts for client and thus it was generating it's own contracts. Once I've rebuilt the assembly - it reused them.




回答3:


My issue with VS2010 SP1 was trying to use a class that derived from Dictionary<T,U> with a CollectionDataContract attribute. Seems VS won't reuse the type... I also tried Eric's suggestion above, but it didn't work.



来源:https://stackoverflow.com/questions/2066343/wcf-service-reference-does-not-reuse-types-in-existing-assemblies-vs-2010-beta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!