Groups | Blog | Home
all groups > dotnet remoting > august 2003 >

dotnet remoting : how to deal with an interrupted connection when remoting


Scott Bonds
8/29/2003 10:37:52 AM
I have created a server that has an object that can be referenced via
remoting. When I reference the object from the client, everything works
just fine until I shut down the server. Once the server is shut down, and
at the exact moment it stops listening on its port, the client generates a
"Object reference not set to an instance of an object" error *outside* the
main program thread "An unhandled exception of type
'System.NullReferenceException' occurred in
system.dll" ... "at System.Net.OSSOCK.WSAGetOverlappedResult" (so I don't
think I can even handle the exception with a try...catch block, it's
happening in a thread I did not explicitly create).

So, the million dollar question is: how does one handle a remoting server
being shut down while there is a client that still has a reference to one of
its remotely accessible objects? Is there a way to detect the problem
before it generates the exception? Short of that, is there any way to
handle the exception rather than have it crash the app? And how does one
shut down that reference's connection explicitly when they are done with it
(setting the client's object reference to the remote server object to
nothing didn't do it in my tests)?

I'll post a solution as soon as I find one...can anyone point me in the
right direction? Has anyone else run into this conundrum?

--
later,

Scott Bonds
scott@bondsc.com

Kumar Gaurav Khanna [.NET MVP]
8/31/2003 7:19:59 PM
Hi!

Use the AppDomain's "UnhandledException" event to handle all such
"unhandlable" exception. Ofcourse this will work "only" for the system
created AppDomain inwhich your code beings execution, not any AppDomains
that you create.

--

Regards,
Gaurav Khanna
----------------------------------------------------------------------------
----------------
Microsoft MVP - .NET, MCSE Windows 2000/NT4, MCP+I
WinToolZone - Spelunking Microsoft Technologies
http://www.wintoolzone.com/
[quoted text, click to view]

AddThis Social Bookmark Button