这是我运行 WCF 主机的方式:
var baseAddress = new Uri("net.tcp://localhost:2222/blah");
var binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.Transport;
var sh = new ServiceHost(typeof(MyServiceImpl), baseAddress);
sh.AddServiceEndpoint(typeof(IMyService), binding, baseAddress);
sh.Open();
这是我的客户:
Uri uri = new Uri("net.tcp://localhost:2222/blah");
var address = new EndpointAddress(uri);
var binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.Transport;
var client = new MyServiceClient(binding, address);
client.Open();
当我使用 Mono 2.10 运行时执行客户端和服务器时,一切正常。但是当服务器在 .NET 4.0 上运行时,我得到一个System.IO.IOException: Read failure ---> System.Exception: An existing connection was forcibly closed by the remote host
. 我还验证了binding.Security.Mode = SecurityMode.None
一切正常。我是否有可能以某种方式使这两个运行时与正常工作的安全性互操作?