【发布时间】:2015-09-03 04:38:00
【问题描述】:
我在这个网站上查看了很多讨论的问题,但没有直接回答这个问题。我有以下内容:
在Library.dll:
namespace LibraryNamespace
{
[ServiceContract]
public interface IService
{
[OperationContract]
void Operation();
}
}
在Implementation.dll:
namespace ImplementationNamespace
{
public class ServiceImplementation : IService
{
public void Operation()
{
// Do Something
}
}
}
在app.config:
<service name="ImplementationNamespace.ServiceImplementation">
<endpoint
address="ServiceImplementation"
binding="netTcpBinding"
contract="LibraryNamespace.IService" />
....
</service>
我一直收到contract="LibraryNamespace.IService" 的警告。程序运行了,但我感觉这个警告给我带来了更多的问题。
“合同”属性无效 - 值 'LibraryNamespace.IService' 根据其数据类型无效 'serviceContractType' - 枚举约束失败。
当ServiceContract 和服务实现在同一个程序集和命名空间中时它可以工作,但由于某种原因,它在这里不起作用。如何正确引用?
【问题讨论】:
-
为什么要将它们放在单独的 dll 中?有什么具体原因吗?
-
是的,基本上,我想创建一个通用的 ServiceContract,然后在不同的程序集中编写许多其他 ServiceImplementation 类,它们都遵循相同的服务合同。这样,我可以标准化我的 ServiceImplementations,并从客户端以标准方式调用它们。
标签: c# wcf namespaces app-config wcf-endpoint