我有一个C#应用程序,我使用远程处理。但是,一些客户最近报告了一个问题。我的代码中出现异常异常:
System.Net.Sockets.SocketException:请求的名称有效,但未找到所请求类型的数据。
创建新TcpChannel
时出现异常。我使用的代码是:
BinaryServerFormatterSinkProvider binaryServiceProvider = new BinaryServerFormatterSinkProvider();
binaryServiceProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider binaryclientProv = new BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["port"] = portNo;//PortNumber I use is 20052
props["name"] = "ApplicationName";
try
{
TcpChannel channel = new TcpChannel(props, binaryclientProv, binaryServiceProvider);
ChannelServices.RegisterChannel(channel, false);
}
catch (Exception a_Exception)
{
System.Diagnostics.Debug.WriteLine(a_Exception);
System.Diagnostics.Trace.WriteLine(a_Exception);
}