Groups | Blog | Home
all groups > dotnet distributed apps > november 2006 >

dotnet distributed apps : AppDomains and Exceptions


rjh
11/19/2006 10:42:01 AM
I use application domains to load third party DLL's. Ideally, if one of these
DLL's throws an exception, I do not want the exception to take down my
application. It seems that Application Domains are designed to isolate code.
I have researched quite a bit on this and there does not seem to be a way to
detect an exception in an app domain and report this error. What I want to do
is report the error, unload the DLL, then re-load it again. I can detect the
error with the UnHandledException handler in my main app, but by then its to
late, my app will then quit. Am I stuck? This is with .NET 2.0.

Thanks,

Michael Nemtsev
11/20/2006 12:00:00 AM
Hello rjh,

You can't unload specific assembly.
just unload/load whole appdomain

r> I use application domains to load third party DLL's. Ideally, if one
r> of these DLL's throws an exception, I do not want the exception to
r> take down my application. It seems that Application Domains are
r> designed to isolate code. I have researched quite a bit on this and
r> there does not seem to be a way to detect an exception in an app
r> domain and report this error. What I want to do is report the error,
r> unload the DLL, then re-load it again. I can detect the error with
r> the UnHandledException handler in my main app, but by then its to
r> late, my app will then quit. Am I stuck? This is with .NET 2.0.
r>
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

rjh
11/20/2006 5:06:02 AM
Thanks for the reply. I understand that I can load/unload the appdomain. The
problem is this: The DLL's that I am loading/unloading are "plug-ins" to our
main app. There could be hundreds of these, and most are third party. Some
create their own threads. If there is an exception in one of their threads,
and they don't handle it, my application gets an UnHandledException event and
my application dies. This obviously is not acceptable. I need to way to
totally isolate these plug-ins. It looks like AppDomains is not going to work
for me?

-Rich

[quoted text, click to view]
Michael Nemtsev
11/20/2006 6:01:49 PM
Hello rjh,

Sorry, but .NET 2.0 CLR design is that the most of exeptions leads to appdomain
unloading, albeit UnhandledException and ThreadAbortException are being
notified.

But, u can use legacyUnhandledExceptionPolicy flag of runtime version to
return the 1.1 behaviour

Read more about this there http://msdn2.microsoft.com/en-us/library/ms228965.aspx

http://msdn2.microsoft.com/en-us/library/ms228965.aspx
r> Thanks for the reply. I understand that I can load/unload the
r> appdomain. The problem is this: The DLL's that I am loading/unloading
r> are "plug-ins" to our main app. There could be hundreds of these, and
r> most are third party. Some create their own threads. If there is an
r> exception in one of their threads, and they don't handle it, my
r> application gets an UnHandledException event and my application dies.
r> This obviously is not acceptable. I need to way to totally isolate
r> these plug-ins. It looks like AppDomains is not going to work for me?
r>
r> -Rich
r>
[quoted text, click to view]
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch

AddThis Social Bookmark Button