在我的 WCF 服务App.config
中,我有:
<services>
<service behaviorConfiguration="MyServiceWcfBehavior" name="MyService">
<clear />
<endpoint address="net.tcp://localhost:9999/MyService" binding="customBinding" bindingConfiguration="MyServiceTcpBinding" name="MyServiceWcfTcpEndpoint" contract="MyService.Contracts.Interfaces.IMy" />
</service>
</services>
在我的测试客户端中,App.config
我有:
<client>
<endpoint address="net.tcp://localhost:9999/MyService" behaviorConfiguration="MyServiceEndpointBehavior" binding="customBinding" bindingConfiguration="MyServiceCustomTcpBinding" contract="MyService.Contracts.Interfaces.IMy" name="MyServiceWcfTcpEndpoint" />
</client>
然后我ServiceHost
像这样实例化我的:
var host = new ServiceHost(typeof(MyService),new Uri(net.tcp://localhost:9999/MyService));
host.Open();
但是在运行我的服务然后使用我的客户端进行测试(调用我的服务中定义的通道端点)时,我得到运行时异常:
System.ServiceModel.FaultException`1 未处理 Action= http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault HResult=-2146233087 Message=方法或操作未实现。Source=mscorlib StackTrace:服务器堆栈跟踪:在 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime 操作,ProxyRpc& rpc) 在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime操作)在 System.ServiceModel.Channels。