.NET Remoting and Exceptions

J

Jeff

Hey

..NET 2.0

I'm developing a system which consist of a winservice and a client app. The
client app accesses the winservice via .NET Remoting.

In this winservice I'd like to add a method which does some processing and
if an exception occur it will be catched in the client app. (below is an
example code illustrate how I think about implement this). I'm unsure if an
exception is thrown in the winservice, will the client app's try/catch block
catch is exception?

in winservice:
public void HelloWorld()
{
try {
//do something here...
if (!something)
throw new Exception("Happy New Year");
}
catch (Exception e) { throw e}
}

In the client program:
static void Main(string[] args)
{
try
{
//calling remote service......
}
catch (Exception e) { System.Console.WriteLine(e.Message); }

}

If I do it like this will the client try/catch block catch an exception
occuring in the winservice?

any suggestions?
 
O

Olie

I am surprised you bothered to post about this, could you not just
have tried it?

The answer though is yes, in most cases exceptions thrown in the
remote procedural call will filter to the client. The only exception I
have found is if the thrown exception contains any extra information
that is not serializable. However in this case you will still get an
exception in the client it just will not be the original exception.
 

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