From: Tony Johansson on 1 May 2010 08:56 Hi! I'm reading about Application Domain and trying to understand how it works. This example below is not from the book but only a test from me to see what would happened. Here I have tried to start notepad from an Application Domain that I have created but I get an Exception. A translation from native language to english is "BadImageFormatExcption was unhandled It's not possible to read in the file after assembly file:///C\WINDOWS\notepad.exe or one of its dependencis. The module expected contain an assemblymanifest" static void Main(string[] args) { AppDomain d = AppDomain.CreateDomain("newDomain"); Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName); d.ExecuteAssembly(@"C:\WINDOWS\notepad.exe"); } //Tony
From: Family Tree Mike on 1 May 2010 09:36 On 5/1/2010 8:56 AM, Tony Johansson wrote: > Hi! > > I'm reading about Application Domain and trying to understand how it works. > This example below is not from the book but only a test from me to see what > would happened. > Here I have tried to start notepad from an Application Domain that I have > created but I get an Exception. A translation from native language to > english is > "BadImageFormatExcption was unhandled > It's not possible to read in the file after assembly > file:///C\WINDOWS\notepad.exe or one of its dependencis. The module expected > contain an assemblymanifest" > > static void Main(string[] args) > { > AppDomain d = AppDomain.CreateDomain("newDomain"); > > Console.WriteLine("Host domain: " + > AppDomain.CurrentDomain.FriendlyName); > d.ExecuteAssembly(@"C:\WINDOWS\notepad.exe"); > } > > //Tony > > Tony, Notepad.Exe is not a .Net assembly. The method you are calling is intended to run a .Net assembly only. The MSDN docs describe the exceptions that can be thrown by the method, and the possible reasons for each exception. http://msdn.microsoft.com/en-us/library/sxx9f4c2.aspx -- Mike
From: Tony Johansson on 1 May 2010 10:45 Hi! The assembly where this Main is located in is called AppDomainDemo. This process AppDomainDemo is creating the new Application Domain called "New Domain" and then start the assembly that is reference by "ShowBootIni". All this works good. If I start the same assembly in this way instead System.Diagnostics.Process.Start(@"F:\C#\AppDomainTest\Lesson1-ShowBootIni-CS\ShowBootIni\ShowBootIni\bin\Debug\ShowBootIni.exe"); then I can easily stop the process from task manager but when I use the Application Domain I don't have that possibility to do so. So how can I stop the assembly(process) that has been started in an Application Domain ? static void Main(string[] args) { AppDomain myAppDomain = AppDomain.CreateDomain("New Domain"); myAppDomain.ExecuteAssemblyByName("ShowBootIni"); } //Tony
From: Arne Vajhøj on 1 May 2010 20:48 On 01-05-2010 10:45, Tony Johansson wrote: > The assembly where this Main is located in is called AppDomainDemo. > This process AppDomainDemo is creating the new Application Domain called > "New Domain" and then start the assembly that is reference by "ShowBootIni". > All this works good. > If I start the same assembly in this way instead > System.Diagnostics.Process.Start(@"F:\C#\AppDomainTest\Lesson1-ShowBootIni-CS\ShowBootIni\ShowBootIni\bin\Debug\ShowBootIni.exe"); > then I can easily stop the process from task manager > but when I use the Application Domain I don't have that possibility to do > so. > > So how can I stop the assembly(process) that has been started in an > Application Domain ? > > static void Main(string[] args) > { > AppDomain myAppDomain = AppDomain.CreateDomain("New Domain"); > myAppDomain.ExecuteAssemblyByName("ShowBootIni"); > } ExecuteAssemblyByName does not start a process - it does not even start a thread. So you need to just stop your app. In case you would want to stop it programmatically then use: myAppDomain.Unload() Arne
|
Pages: 1 Prev: Timers and Threads Next: A Review question from the Microsoft book(exam 70-536) |