Google-Apps
Hauptmenü

Post a Comment On: the urban canuk, eh

"Running code in a separate AppDomain"

4 Comments -

1 – 4 of 4
Blogger Yort said...

Unhappily, it appears that from .Net 2.0 on app domains DO NOT isolate unhandled exceptions (do a Google search for the keywords "isolating exceptions in appdomains" for more info.

An *unhandled* exception in a secondary app domain will still cause the parent domain to unload and the app to shutdown, unless you enable legacy exception handling in the config file (which is generally not recommended). It also seems there is no way to prevent that behaviour.

If you really want to provide that level of isolation you need to host the clr yourself so you can change the way unhandled exceptions are processed. This seems like overkill for a lot of situtations.

You can reclaim memory (and unload assemblies) using appdomains like your post suggests though. So other than the suggestion that apddomains isolate exceptions, good article.

9:42 PM

Blogger bryan said...

Good point, Yort. I hadn't tried that out in this post, though it is possible to set up an exception handler for each app domain. I wonder if adding an anonymous delegate to swallow and mark the exception as handled would prevent it from bubbling up to the parent app domain.

9:37 AM

Blogger Kiquenet said...

What is IWidgetModule ? not found in code ?

10:13 AM

Blogger bryan said...

The IWidgetModule was a typo in the code sample, should have been IWidget which is defined above.

3:39 PM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot