移动WCF合约以一个单独的DLL合约、WCF、DLL

2023-09-04 00:34:02 作者:战衣

我想移动WCF合约接口第三DLL,并开始从客户端占用他们的时候,我的手产生的代理。

I want to move WCF contracts interfaces to third DLL and start consuming them from clients when I am generating proxy by hand.

执行DLL中的这些接口都具有 [的ServiceContract] 属性,当我使用它们从客户端生成一个代理?

Do those interfaces in the DLL have to have the [ServiceContract] attribute when I consume them from the client to generate a proxy ?

任何知道什么是最好的命名的DLL,将只有合同和DTO的客户端和服务器之间共享。

Any idea what is the best naming for Dll that will have only contracts and the DTOs to share between client and the server.

推荐答案

这是非常普遍的做法是WCF数据服务合同分开组装。在我的previous项目中,我们使用像 Company.OurProject.Contracts.dll 命名。 我认为,产生与重用现有的类,你应该把你的接口服务合同(标有 [ServiceContractAttribute的] )和相​​应的数据合约,该程序集的代理。我会避免把服务有实际的执行情况。

It is very common practice to put WCF data and service contract to separate assembly. In my previous project we used naming like Company.OurProject.Contracts.dll. I think that to generate proxy with reusing existing classes you should put your interfaces for service contracts (those marked with [ServiceContractAttribute]) and corresponding data contracts to that assembly. I would avoid putting there actual implementation of the services.

下面是更深入地了解,当重用类型的引用的程序集所选内容可以重复使用的SO另一个伟大的回答:WCF服务参考产生自己的合同的接口,不会再用我的!

Here is another great answer on SO with more insight into what can be reused when "Reuse types in referenced assemblies" is selected: WCF Service Reference generates its own contract interface, won't reuse mine!