C#远程处理 - 如何关闭的customErrorscustomErrors

2023-09-03 10:38:40 作者:带泪的鱼

我收到以下错误,当我尝试使用远程连接到我的服务器应用程序:

  

的问题似乎已发生,同时连接到远程服务器:   服务器遇到一个内部错误。欲了解更多信息,请关闭的customErrors服务器的config文件。的

这是对我的服务器应用程序中的code:

 的TcpChannel的TcpChannel =新的TcpChannel(999);
MyRemoteObject remObj =新MyRemoteObject(本);
RemotingServices.Marshal(remObjMyUri);
ChannelServices.RegisterChannel(的TcpChannel);
 

看来工作的第一次,但除非服务器应用程序重新启动的错误。

我猜的东西没有被正确清理,但我不知道是什么的customError还亮着。

在那里我开始任何想法。谢谢你。

- 由于古勒扎尔,我修改了code以上以下,现在的错误显示:

  RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
的TcpChannel的TcpChannel =新的TcpChannel(999);
MyRemoteObject remObj =新MyRemoteObject(本);
RemotingServices.Marshal(remObjMyUri);
ChannelServices.RegisterChannel(的TcpChannel);
 
怎样在远程关闭Win7系统

解决方案

对于.NET 1.0 / 1.1,你需要一个配置文件用于远程服务器

如果你没有一个< ServerEXE>的.config 文件,创建一个和它有这样的:

 < XML版本=1.0编码=UTF-8&GT?;
<结构>
   < system.runtime.remoting>
      <的customErrors模式=关/>
   < /system.runtime.remoting>
< /结构>
 

对于.NET 2.0,你可以使用RemotingConfiguration.CustomErrorsMode物业

I getting the following error when I try to connect to my server app using remoting:

A problem seems to have occured whilst connecting to the remote server: Server encountered an internal error. For more information, turn off customErrors in the server's .config file.

This is the code on my server app:

TcpChannel tcpChannel = new TcpChannel(999);
MyRemoteObject remObj = new MyRemoteObject (this);
RemotingServices.Marshal(remObj, "MyUri");
ChannelServices.RegisterChannel(tcpChannel);

It seems to work the first time, but unless the server app is restarted the error occurs.

I would guess something isn't being cleaned up properly but I'm not sure what as the customError is still on.

Any ideas where I start. Thanks.

[EDIT] - Thanks to Gulzar, I modified my code above to the following and now the errors are shown:

RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
TcpChannel tcpChannel = new TcpChannel(999);
MyRemoteObject remObj = new MyRemoteObject (this);
RemotingServices.Marshal(remObj, "MyUri");
ChannelServices.RegisterChannel(tcpChannel);

解决方案

For .Net 1.0/1.1 , you need a config file for remoting server

If you don't have a <ServerEXE>.config file, create one and have this in it:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <system.runtime.remoting>    
      <customErrors mode="off" />
   </system.runtime.remoting>
</configuration>

For .Net 2.0, you can use RemotingConfiguration.CustomErrorsMode property

相关推荐
 
精彩推荐
图片推荐