views:

5832

answers:

3

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);
+23  A: 

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

<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

Gulzar
That done it, now i see the errors, thanks.
HAdes
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
Thanks Drew. Corrected.
Gulzar
A: 

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 ` 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.`

DOK
+3  A: 

In the server file use:

RemotingConfiguration.CustomErrorsEnabled(bool);

sometimes