Question

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);
Was it helpful?

Solution

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

OTHER TIPS

In the server file, use:

RemotingConfiguration.CustomErrorsEnabled(bool);

To turn off customErrors, open the web.config file on the server. If there is a customErrors tag, change it. If there isn't one, add it.

It should be <customErrors mode="Off"/> for this purpose.

If you are indeed using a custom error page, you will want to change this setting once you've found your problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top