32

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);
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
HAdes
  • 16,713
  • 22
  • 58
  • 74

3 Answers3

38

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

Jake Berger
  • 5,237
  • 1
  • 28
  • 22
Gulzar Nazim
  • 51,744
  • 26
  • 128
  • 170
  • 1
    You might like to correct the missing angle brackets in the above XML for newer users who might be confused. Feel free to delete this comment once you've done so. – Drew Noakes Nov 11 '08 at 09:28
  • O should be capital in "off" ...without it being capital it wont work, I have literally pulled my hair for hours for that!!! – Sushant VS Jan 22 '19 at 17:22
5

In the server file, use:

RemotingConfiguration.CustomErrorsEnabled(bool);
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
sometimes
  • 51
  • 1
0

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.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
DOK
  • 32,337
  • 7
  • 60
  • 92