[英]C# Remoting - How to turn off CustomErrors
當我嘗試使用遠程連接到我的服務器應用程序時出現以下錯誤:
連接到遠程服務器時似乎出現了問題:
服務器遇到內部錯誤。 有關更多信息,請關閉服務器.config文件中的customErrors。
這是我的服務器應用程序上的代碼:
TcpChannel tcpChannel = new TcpChannel(999);
MyRemoteObject remObj = new MyRemoteObject (this);
RemotingServices.Marshal(remObj, "MyUri");
ChannelServices.RegisterChannel(tcpChannel);
它似乎第一次工作,但除非重新啟動服務器應用程序,否則會發生錯誤。
我猜想有些東西沒有被正確清理,但我不確定是什么因為customError仍然存在。
我開始的任何想法。 謝謝。
[編輯] - 感謝Gulzar,我將上面的代碼修改為以下內容,現在顯示錯誤:
RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
TcpChannel tcpChannel = new TcpChannel(999);
MyRemoteObject remObj = new MyRemoteObject (this);
RemotingServices.Marshal(remObj, "MyUri");
ChannelServices.RegisterChannel(tcpChannel);
對於.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>
對於.Net 2.0,您可以使用RemotingConfiguration.CustomErrorsMode屬性
在服務器文件中,使用:
RemotingConfiguration.CustomErrorsEnabled(bool);
要關閉customErrors,請打開服務器上的web.config file
。 如果有customErrors
標記,請更改它。 如果沒有,請添加它。
為此,它應該是<customErrors mode="Off"/>
。
如果您確實使用自定義錯誤頁面,則在找到問題后,您將需要更改此設置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.