Handle Exception over Remoting

R

riz

Hi

I use Framework 2.0, .Net Remoting, Client with WinForms and a Server.

Everything works fine, but i can't catch Exceptions on the Client, which
have been thrown on the Server.

I would like to catch the ArgumentOutOfRangeException on the Client (if
there is no Person), but it stopps in FindPerson() on the Server.

ArgumentOutOfRangeException is Serializable by default. If i test
FindPerson(1) on the Server with a Test Class. I can catch the
Exception, as it should be. Does anybody know, what i am doing wrong?
Has it something to do with the Interface?


Client communicates with Server like this:
------------------------------------------

IServer server = (IServer)Activator.GetObject(type, url);


//get a Person
try{
server.FindPerson(1);
...
}

//I can't catch it here, but i would like to
catch (ArgumentOutOfRangeException ex) {
MessageBox.Show(ex.Message);
}


Server: IServer
---------------

public Person FindPerson(int id){
try{
return coll.GetPerson(id)[0];
}
catch(Exception e){
throw;
}

}

IServer
-------
public interface IServer {
Person FindPerson (int i);
}



thx
riz
 
D

Dave Sexton

Hi Riz,
I would like to catch the ArgumentOutOfRangeException on the Client (if
there is no Person), but it stopps in FindPerson() on the Server.

What do you mean by stops?

What happens on the client?

--
Dave Sexton

riz said:
Hi

I use Framework 2.0, .Net Remoting, Client with WinForms and a Server.

Everything works fine, but i can't catch Exceptions on the Client, which
have been thrown on the Server.

I would like to catch the ArgumentOutOfRangeException on the Client (if
there is no Person), but it stopps in FindPerson() on the Server.

ArgumentOutOfRangeException is Serializable by default. If i test
FindPerson(1) on the Server with a Test Class. I can catch the Exception,
as it should be. Does anybody know, what i am doing wrong? Has it
something to do with the Interface?


Client communicates with Server like this:
------------------------------------------

IServer server = (IServer)Activator.GetObject(type, url);


//get a Person
try{
server.FindPerson(1);
...
}

//I can't catch it here, but i would like to
catch (ArgumentOutOfRangeException ex) {
MessageBox.Show(ex.Message);
}


Server: IServer
---------------

public Person FindPerson(int id){
try{
return coll.GetPerson(id)[0];
}
catch(Exception e){
throw;
}

}

IServer
-------
public interface IServer {
Person FindPerson (int i);
}



thx
riz
 
R

riz

Hi Dave,

i just found out. When i run the .exe, it's working. In Visual Studio,
Debugger catches ArgumentOutOfRangeException occurs and i have
to press "continue", then it throws the exception. So i have to use
"Start Without Debugging" CTRL + F5
 

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