Remoting problems

G

Gomez

I have 2 independent problems with remoting-
1. If I use remoting from the client side and it fails, though the code runs
inside a try/catch block(code follows the questions), it never arrives to
the catch block but rather invokes a system exception (of type
System.Net.WebExeception)with the following message-
Unable to connect to the remote server
try

{

obj2.General_Remote_Method("serve_new_client",

client_ip_address, client_port, out out_paramter);


}

catch (IOException ioExcep)

{

Console.WriteLine("Remote IO Error" +

"\nException:\n" + ioExcep.ToString());

}

How can I modify the code in order to pass through the catch block?

2. A second problem that I have is, trying to run the server code and the
client on the same application I get the message

the channel 'http' is already registered

Running on different instances of the application works fine.

Can someone help me with any of these problems?

Regards

Gomez
 
N

Nicholas Paldino [.NET/C# MVP]

Gomez,

Well, why should it? WebException derives from
InvalidOperationException (which doesn't have IOException in it's chain) and
you are trying to catch IOException. There is no reason that this catch
block will catch a WebException. You need to create a catch block which
will catch WebException, or any exception.

As for the second question, can you show how you are setting up the
client and server?

Also, if you are in the same app, one would wonder why you need to set
up an HTTP channel to communicate between those objects.
 
G

Gomez

Thanks Mr. Paldino,
Please follow my answers inside..
Regards
Gomez
Nicholas Paldino said:
Gomez,

Well, why should it? WebException derives from
InvalidOperationException (which doesn't have IOException in it's chain)
and you are trying to catch IOException. There is no reason that this
catch block will catch a WebException. You need to create a catch block
which will catch WebException, or any exception.

As for the second question, can you show how you are setting up the
client and server?
here is the client side. It fails in the last line that is showed, in
ChannelServices.RegisterChannel(chan2);
if (!registered_http_chanel1)

{

HttpChannel chan3 = new HttpChannel();

ChannelServices.RegisterChannel(chan3);

..........

Here is the server initialization(please, ignore the tcp channel)
public void InitializeServer()

{

Console.WriteLine("HelloServer activated");

TcpChannel chan1 = new TcpChannel(8085);

HttpChannel chan2 = new HttpChannel(8086);

ChannelServices.RegisterChannel(chan1);

ChannelServices.RegisterChannel(chan2);

RemotingConfiguration.RegisterWellKnownServiceType(

typeof(HelloServer),

"SayHello",

WellKnownObjectMode.SingleCall);

}

Also, if you are in the same app, one would wonder why you need to set
up an HTTP channel to communicate between those objects.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gomez said:
I have 2 independent problems with remoting-
1. If I use remoting from the client side and it fails, though the code
runs inside a try/catch block(code follows the questions), it never
arrives to the catch block but rather invokes a system exception (of type
System.Net.WebExeception)with the following message-
Unable to connect to the remote server
try

{

obj2.General_Remote_Method("serve_new_client",

client_ip_address, client_port, out out_paramter);


}

catch (IOException ioExcep)

{

Console.WriteLine("Remote IO Error" +

"\nException:\n" + ioExcep.ToString());

}

How can I modify the code in order to pass through the catch block?

2. A second problem that I have is, trying to run the server code and the
client on the same application I get the message

the channel 'http' is already registered

Running on different instances of the application works fine.

Can someone help me with any of these problems?

Regards

Gomez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top