Exceptions break the application even within try...catch... Why?

  • Thread starter Thread starter ThunderMusic
  • Start date Start date
T

ThunderMusic

Hi,
I use remoting in a Windows app... this remoting call a ServerA and using
ServerA get an object (marshaled) from ServerB... if I call a method on the
object gotten from ServerB and this ServerB has shut down it's service, I
get an exception and this exception stop the application event if it's
inside a try-catch structure... I mean, it does exactly the same as if it
was not in a try-catch structure. Is there a reason it's behaving this way?

I could send a code snippet, but it would not be useful... I get the ServerA
object, I get the ServerB object by calling a method on ServerA's object, I
open a try structure (try { ), I call a method on ServerB's object... if
the ServerB is running, everything is fine, if ServerB is not running, the
exception is thrown exactly the same way as if it were not in a try-catch
structure...

Why? and Is there a way around it?

Thanks

ThunderMusic
 
I solved this with a messaging structure ,,,,, if the server is shutting
down it will broadcast a message to the clients and vice versa .


maybe this is an idea for you to ??


regards

Michel Posseth
 
ok, so I'm not the only one to get this behavior... Is this by design? I
mean, is it normal behavior?

Thanks for the messaging suggestion, I'll probably try to use it... ;)

ThunderMusic
 
Hello,

I am also experiencing this problem, although I would describe it as
follows:
- if you have a server application that experiences any kind of error,
you'd expect the error to be prolonged to the caller AppDomain, e.g.
back to the client. This *does* occur actually, however the server is
then terminated even if the client calls within try/catch brackets. Is
this what you see?

Further investigations brought me to a (not very elegant) solution. This
behaviour was introduced with .NET 2.0 due to a policy change for
unhandled exceptions in different threads than main (e.g. if you create
new objects on the server rather than using existing ones). If your
intention is to keep the service running, you have to open
machine.config and add this to the "runtime" tag:
<runtime>
<legacyUnhandledExceptionPolicy enabled="true" />
</runtime>

This will keep the server running.

However, if any experts know more about this phenomenon or could supply
a more elegant way to solve this (like telling *only* the server to
behave like this), this would be very helpful.

I think this behaviour is generally positive as it points e.g. to
Windows Forms threading errors rather than just ignoring them and
possibly leading to an undefined application state. With remoting, I
always wondered why there were so few articles discussing this.
Best regards,
Helge

ThunderMusic schrieb am 27.07.2006 22:14:
 
Back
Top