T
Tony Johansson
Hi!
I know that Application is about isolation code in an assembly.
It is useful because it can improve reliability and Efficiency.
But there is one thing that I still have some doubt about and that is if you
can have multiple assemblies in an Application Domain. For example in the
code example below I load three assemblies(AssemblyA,AssemblyB and
AssemblyC) into the Application Domain named New Domain.
I got the following answer to this question when I asked this question on a
thread.
"My reading of the docs, along with a simple experiment, show that the
code ExecuteAssemblyByName does not return until the executable (such as
AssemblyA.exe) is finished. There is no threading nor switching as they
are executed in order. They are not executed in parallel."
This mean that you can only have one and only assembly running in the
Application Domain at any given time.
The strange thing is that in the Microsoft Press(exam 70-536) book that I
read is two things that talk in favour that you can have multiple assemblies
in an Application Domain and that is the following two points.
1. There is a figure drawn in the book that shows two assemblies in an
Application Domain
2.There is a method in Appdomain that is named GetAssemblies that says "Gets
the assemblies that have been loaded into the execution context of this
application domain."
static void Main(string[] args)
{
AppDomain myAppDomain = AppDomain.CreateDomain("New Domain");
myAppDomain.ExecuteAssemblyByName("AssemblyA");
myAppDomain.ExecuteAssemblyByName("AssemblyB");
myAppDomain.ExecuteAssemblyByName("AssemblyC");
}
I have also tested this small main and it's true that AssemblyB will not
start executing until AssembyA has finished executing.
Normally books are correct so I want to be sure what is right in this matter
if an Application Domain can have multiple assemblies or not ?
//Tony
I know that Application is about isolation code in an assembly.
It is useful because it can improve reliability and Efficiency.
But there is one thing that I still have some doubt about and that is if you
can have multiple assemblies in an Application Domain. For example in the
code example below I load three assemblies(AssemblyA,AssemblyB and
AssemblyC) into the Application Domain named New Domain.
I got the following answer to this question when I asked this question on a
thread.
"My reading of the docs, along with a simple experiment, show that the
code ExecuteAssemblyByName does not return until the executable (such as
AssemblyA.exe) is finished. There is no threading nor switching as they
are executed in order. They are not executed in parallel."
This mean that you can only have one and only assembly running in the
Application Domain at any given time.
The strange thing is that in the Microsoft Press(exam 70-536) book that I
read is two things that talk in favour that you can have multiple assemblies
in an Application Domain and that is the following two points.
1. There is a figure drawn in the book that shows two assemblies in an
Application Domain
2.There is a method in Appdomain that is named GetAssemblies that says "Gets
the assemblies that have been loaded into the execution context of this
application domain."
static void Main(string[] args)
{
AppDomain myAppDomain = AppDomain.CreateDomain("New Domain");
myAppDomain.ExecuteAssemblyByName("AssemblyA");
myAppDomain.ExecuteAssemblyByName("AssemblyB");
myAppDomain.ExecuteAssemblyByName("AssemblyC");
}
I have also tested this small main and it's true that AssemblyB will not
start executing until AssembyA has finished executing.
Normally books are correct so I want to be sure what is right in this matter
if an Application Domain can have multiple assemblies or not ?
//Tony