Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Load Type in DLL in a different AppDomain

Load Type in DLL in a different AppDomain

Scheduled Pinned Locked Moved C#
helptutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nandiator
    wrote on last edited by
    #1

    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?

    J P 2 Replies Last reply
    0
    • N Nandiator

      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?

      J Offline
      J Offline
      JoeSharp
      wrote on last edited by
      #2

      hi use LoadFile instead of LoadFrom. this will help you more www.codeproject.com/KB/dotnet/AssemblyLoadFile.aspx cheers

      N 1 Reply Last reply
      0
      • J JoeSharp

        hi use LoadFile instead of LoadFrom. this will help you more www.codeproject.com/KB/dotnet/AssemblyLoadFile.aspx cheers

        N Offline
        N Offline
        Nandiator
        wrote on last edited by
        #3

        Thanks for your answer, but i'm afraid it doesn't work in compact framework (mobile), at least in NETCF 2.0. Thankyou anyway.

        1 Reply Last reply
        0
        • N Nandiator

          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?

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          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 ) ) ;
          
          N 1 Reply Last reply
          0
          • P PIEBALDconsult

            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 ) ) ;
            
            N Offline
            N Offline
            Nandiator
            wrote on last edited by
            #5

            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'

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups