【发布时间】:2013-02-22 16:19:19
【问题描述】:
我正在尝试删除 WCF 项目的 app.config 文件,我需要将设置硬编码到我正在生成的 DLL 中。
我使用svcUtil 创建了我的代理类,当我使用App.config 时客户端工作正常
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="ManagementEndpoint">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://example.com/MyApp/DomainManagement"
binding="netTcpBinding" bindingConfiguration="ManagementEndpoint"
contract="MyApp.DomainManagementProxy.IDomainManagement"
name="DomainManagementEndpoint" />
</client>
</system.serviceModel>
但是,如果我删除我的 App.config 并将默认构造函数替换为以下内容
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class DomainManagementClient : System.ServiceModel.ClientBase<MyApp.DomainManagementProxy.IDomainManagement>, MyApp.DomainManagementProxy.IDomainManagement
{
public DomainManagementClient()
: base(new NetTcpBinding(SecurityMode.None, false),
new EndpointAddress("net.tcp://example.com/MyApp/DatabaseManagement"))
{
}
//(Snip)
当我在客户端调用第一个方法时,它会给我以下错误
由于 EndpointDispatcher 的 ContractFilter 不匹配,接收方无法处理带有 Action 'http://example.com/MyApp/DomainManagement/IDomainManagement/GetServerSetup' 的消息。这可能是因为合约不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。
我需要更改/放入我的构造函数以使绑定正常工作?
【问题讨论】:
标签: c# wcf .net-4.0 nettcpbinding