When to use one application domain instead of several

T

Tony Johansson

Hi!

Assume that have an assembly called myAssembly.exe and this must be running
in two instances then I have two alternatives.
1. Let this myAssembly.exe be running in two threads in one application
domain.
2. Let this myAssembly.exe be running in two appliaction domain using a one
thread in each.

So my question is that I will almost find it much better to use one
application domain for each assembly because
of isolation between application domain.

So when is there an advantage to use only one application domain running
several *.exe assemblies ?

//Tony
 
A

Arne Vajhøj

Assume that have an assembly called myAssembly.exe and this must be running
in two instances then I have two alternatives.
1. Let this myAssembly.exe be running in two threads in one application
domain.
2. Let this myAssembly.exe be running in two appliaction domain using a one
thread in each.

So my question is that I will almost find it much better to use one
application domain for each assembly because
of isolation between application domain.

So when is there an advantage to use only one application domain running
several *.exe assemblies ?

There are a performance penalty of using multiple app domains
because all calls between app domains get serialized.

There is a functional difference because static fields
will exist in multiple instances - one in each app domain.

You should only use multiple app domains if you really need
to isolate some code.

My guess is that 80% of .NET developers have never had a reason
to create a new app domain (not counting .NET frameworks that
create app domains for them).

Arne
 

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