Prev: Determine framework version used by an application or a .dll
Next: How does the Application Domain affect the reliability for the Aspnet_wp.exe
From: Arne Vajhøj on 2 May 2010 15:48 On 02-05-2010 08:17, Tony Johansson wrote: > 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 ? Again. Application domains is for code separation - it is unrelated to processes and threads. My guess is that in most multiple app domains cases there will be started multiple threads. So code can execute independently. But the thread starting is not done automatically. Arne |