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. AppDomain and unloading assemblies

AppDomain and unloading assemblies

Scheduled Pinned Locked Moved C#
helptutorial
7 Posts 4 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.
  • M Offline
    M Offline
    mirano
    wrote on last edited by
    #1

    Hi everybody. I load an assembly into another AppDomain, not a default one. As there is no way to unload the assembly, I need to unload the domain. This is where the app hangs. The problem is this assembly has references to one dll, currently not performing any work. I tried this: 1. Setting the assembly to null, 2. Implementing a ClassFactory and returning an interface of the object, then removing it, 3. Making assembly to implement the IDisposable interface. None of this works. All examples on the Net just shows how to create AppDomains, load assemblies and then unload the AppDomain. None of those show what happens if the assembly has referenced assemblies. Thank you for your help. Sarajevo, Bosnia

    D S 2 Replies Last reply
    0
    • M mirano

      Hi everybody. I load an assembly into another AppDomain, not a default one. As there is no way to unload the assembly, I need to unload the domain. This is where the app hangs. The problem is this assembly has references to one dll, currently not performing any work. I tried this: 1. Setting the assembly to null, 2. Implementing a ClassFactory and returning an interface of the object, then removing it, 3. Making assembly to implement the IDisposable interface. None of this works. All examples on the Net just shows how to create AppDomains, load assemblies and then unload the AppDomain. None of those show what happens if the assembly has referenced assemblies. Thank you for your help. Sarajevo, Bosnia

      D Offline
      D Offline
      David Stone
      wrote on last edited by
      #2

      I believe you also must unload the referenced assemblies. Is there a reason you cannot do this?


      Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..." -Jörgen Sigvardsson

      M 1 Reply Last reply
      0
      • D David Stone

        I believe you also must unload the referenced assemblies. Is there a reason you cannot do this?


        Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..." -Jörgen Sigvardsson

        M Offline
        M Offline
        mirano
        wrote on last edited by
        #3

        There is no way to unload the assembly at all. You can do this under Framework 2.0 but not under 1.1. The only way is to unload the AppDomain, and it is clearly said that way at the Microsoft site. The main assembly does not "realize" the AppDomain it is in is getting unloaded, so that it can do a clean up or something. Also important to note is that no unmanaged code is accessed anywhere, so this is not the reason. Thanks. Sarajevo, Bosnia

        D 1 Reply Last reply
        0
        • M mirano

          There is no way to unload the assembly at all. You can do this under Framework 2.0 but not under 1.1. The only way is to unload the AppDomain, and it is clearly said that way at the Microsoft site. The main assembly does not "realize" the AppDomain it is in is getting unloaded, so that it can do a clean up or something. Also important to note is that no unmanaged code is accessed anywhere, so this is not the reason. Thanks. Sarajevo, Bosnia

          D Offline
          D Offline
          David Stone
          wrote on last edited by
          #4

          Right, I was just saying that you could load the referenced assembly in the same appdomain and then upload that appdomain.


          Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..." -Jörgen Sigvardsson

          L 1 Reply Last reply
          0
          • D David Stone

            Right, I was just saying that you could load the referenced assembly in the same appdomain and then upload that appdomain.


            Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..." -Jörgen Sigvardsson

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            David Stone wrote: then upload that appdomain ya riiiiiight :laugh: xacc-ide 0.0.99-preview2 (now with integrated debugger)

            M 1 Reply Last reply
            0
            • L leppie

              David Stone wrote: then upload that appdomain ya riiiiiight :laugh: xacc-ide 0.0.99-preview2 (now with integrated debugger)

              M Offline
              M Offline
              mirano
              wrote on last edited by
              #6

              Okay, he probably meant AppDomain.Unload, but this is not working. I will try today to impement a WaitHandle to set a ManualResetEvent so that the assembly stop processing if the service singals that it should stop, so hopefully the unload will work. The funny thing is that this area is much improvedin Framework 2.0, you can do anything with unloading single assemblies from the AppDomain. Thanks. Sarajevo, Bosnia

              1 Reply Last reply
              0
              • M mirano

                Hi everybody. I load an assembly into another AppDomain, not a default one. As there is no way to unload the assembly, I need to unload the domain. This is where the app hangs. The problem is this assembly has references to one dll, currently not performing any work. I tried this: 1. Setting the assembly to null, 2. Implementing a ClassFactory and returning an interface of the object, then removing it, 3. Making assembly to implement the IDisposable interface. None of this works. All examples on the Net just shows how to create AppDomains, load assemblies and then unload the AppDomain. None of those show what happens if the assembly has referenced assemblies. Thank you for your help. Sarajevo, Bosnia

                S Offline
                S Offline
                S Senthil Kumar
                wrote on last edited by
                #7

                I've tried loading assemblies that in turn refer to other assemblies in an AppDomain and it worked.

                mirano wrote:

                This is where the app hangs.

                Have you implemented any finalizers in your code? It's very much possible that one of the finalizers hung and that resulted in the hang? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

                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