HAd*_*des 31 .net c# remoting custom-errors
当我尝试使用远程连接到我的服务器应用程序时出现以下错误:
连接到远程服务器时似乎出现了问题:
服务器遇到内部错误.有关更多信息,请关闭服务器.config文件中的customErrors.
这是我的服务器应用程序上的代码:
TcpChannel tcpChannel = new TcpChannel(999);
MyRemoteObject remObj = new MyRemoteObject (this);
RemotingServices.Marshal(remObj, "MyUri");
ChannelServices.RegisterChannel(tcpChannel);
Run Code Online (Sandbox Code Playgroud)
它似乎第一次工作,但除非重新启动服务器应用程序,否则会发生错误.
我猜想有些东西没有被正确清理,但我不确定是什么因为customError仍然存在.
我开始的任何想法.谢谢.
[编辑] - 感谢Gulzar,我将上面的代码修改为以下内容,现在显示错误:
RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
TcpChannel tcpChannel = new TcpChannel(999);
MyRemoteObject remObj = new MyRemoteObject (this);
RemotingServices.Marshal(remObj, "MyUri");
ChannelServices.RegisterChannel(tcpChannel);
Run Code Online (Sandbox Code Playgroud)
Gul*_*zim 37
对于.Net 1.0/1.1,您需要一个用于远程服务器的配置文件
如果您没有<ServerEXE>.config
文件,请创建一个文件并将其包含在其中:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<customErrors mode="off" />
</system.runtime.remoting>
</configuration>
Run Code Online (Sandbox Code Playgroud)
对于.Net 2.0,您可以使用RemotingConfiguration.CustomErrorsMode属性
小智 5
在服务器文件中,使用:
RemotingConfiguration.CustomErrorsEnabled(bool);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
29734 次 |
最近记录: |