Load Type in DLL in a different AppDomain
-
Hi, First of all, excuse my English. My app (Compact Framework) loads 2 copies if the same dll (exactly the same DLL renamed) using reflection. The DLL should load the corresponding config file according to the DLL name (if the DLL is ModuleA.dll the config is ModuleA.txt, and so on). My problem is this: When I load the first DLL, everything goes OK, but when I load the second one when I do Assembly.LoadFrom( FullPath ) it loads the first DLL insteag of the 2nd one, despite the fact that FullPath contains the first DLL's path. In addition there are the variables which shoul be global to each DLL. As everything is loaded from the first DLL, the globals are the first DLL's ones. After looking for info I realised that what I need to do is to load each DLL in a different AppDomain, so they are isolated from each other. To summarize: One compilation: MyModule.dll 2 copies of the same DLL: MyModuleA.dll & MyModuleB.dll One config file for each DLL: MyModuleA.txt & MyModuleB.txt One appdomain for each DLL is needed. Anyone knows how to do this in Compact Framework?
-
Hi, First of all, excuse my English. My app (Compact Framework) loads 2 copies if the same dll (exactly the same DLL renamed) using reflection. The DLL should load the corresponding config file according to the DLL name (if the DLL is ModuleA.dll the config is ModuleA.txt, and so on). My problem is this: When I load the first DLL, everything goes OK, but when I load the second one when I do Assembly.LoadFrom( FullPath ) it loads the first DLL insteag of the 2nd one, despite the fact that FullPath contains the first DLL's path. In addition there are the variables which shoul be global to each DLL. As everything is loaded from the first DLL, the globals are the first DLL's ones. After looking for info I realised that what I need to do is to load each DLL in a different AppDomain, so they are isolated from each other. To summarize: One compilation: MyModule.dll 2 copies of the same DLL: MyModuleA.dll & MyModuleB.dll One config file for each DLL: MyModuleA.txt & MyModuleB.txt One appdomain for each DLL is needed. Anyone knows how to do this in Compact Framework?
hi use LoadFile instead of LoadFrom. this will help you more www.codeproject.com/KB/dotnet/AssemblyLoadFile.aspx cheers
-
hi use LoadFile instead of LoadFrom. this will help you more www.codeproject.com/KB/dotnet/AssemblyLoadFile.aspx cheers
-
Hi, First of all, excuse my English. My app (Compact Framework) loads 2 copies if the same dll (exactly the same DLL renamed) using reflection. The DLL should load the corresponding config file according to the DLL name (if the DLL is ModuleA.dll the config is ModuleA.txt, and so on). My problem is this: When I load the first DLL, everything goes OK, but when I load the second one when I do Assembly.LoadFrom( FullPath ) it loads the first DLL insteag of the 2nd one, despite the fact that FullPath contains the first DLL's path. In addition there are the variables which shoul be global to each DLL. As everything is loaded from the first DLL, the globals are the first DLL's ones. After looking for info I realised that what I need to do is to load each DLL in a different AppDomain, so they are isolated from each other. To summarize: One compilation: MyModule.dll 2 copies of the same DLL: MyModuleA.dll & MyModuleB.dll One config file for each DLL: MyModuleA.txt & MyModuleB.txt One appdomain for each DLL is needed. Anyone knows how to do this in Compact Framework?
Here's a snippet from one of my classes:
name = System.IO.Path.GetFileNameWithoutExtension ( Filename ) ; /\*\\ |\*| This is the common way to load an assembly: |\*| assm = System.Reflection.Assembly.LoadFrom ( Filename ) ; |\*| |\*| The following is my take on a technique suggested by Sacha Barber: \\\*/ assm = System.AppDomain.CreateDomain ( name ). Load ( System.IO.File.ReadAllBytes ( Filename ) ) ;
-
Here's a snippet from one of my classes:
name = System.IO.Path.GetFileNameWithoutExtension ( Filename ) ; /\*\\ |\*| This is the common way to load an assembly: |\*| assm = System.Reflection.Assembly.LoadFrom ( Filename ) ; |\*| |\*| The following is my take on a technique suggested by Sacha Barber: \\\*/ assm = System.AppDomain.CreateDomain ( name ). Load ( System.IO.File.ReadAllBytes ( Filename ) ) ;
I'm afraid this doesn't work on Compact Framework 2.0. Thankyou anyway. 'System.AppDomain' no contiene una definición para 'Load' 'System.IO.File' no contiene una definición para 'ReadAllBytes' In English: 'System.AppDomain' doesn't contain a definition for 'Load' 'System.IO.File' doesn't contain a definition for 'ReadAllBytes'