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. unload DLL

unload DLL

Scheduled Pinned Locked Moved C#
csharpc++helptutorialquestion
10 Posts 5 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.
  • W Offline
    W Offline
    wb
    wrote on last edited by
    #1

    my problem: I have to port a Project from C++ to C# there is a DLL, i can load [DllImport("blabla.dll")] public extern static void CancelSearch(); . . . and use it... and then end the programm BUT there is a deadlock, cause the FreeLibrary(); is never called by C# :( (if I remove the FreeLibrary(); in C++ then the C++ App hangs too) any idea how to unload the DLL?

    N P L 3 Replies Last reply
    0
    • W wb

      my problem: I have to port a Project from C++ to C# there is a DLL, i can load [DllImport("blabla.dll")] public extern static void CancelSearch(); . . . and use it... and then end the programm BUT there is a deadlock, cause the FreeLibrary(); is never called by C# :( (if I remove the FreeLibrary(); in C++ then the C++ App hangs too) any idea how to unload the DLL?

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      At the command line prompt change to the directory the .dll is registered in and then type the following: regsvr32 -u blabla.dll You should get a prompt saying it has been unregistered. HTH Nick Parker


      W 1 Reply Last reply
      0
      • N Nick Parker

        At the command line prompt change to the directory the .dll is registered in and then type the following: regsvr32 -u blabla.dll You should get a prompt saying it has been unregistered. HTH Nick Parker


        W Offline
        W Offline
        wb
        wrote on last edited by
        #3

        no, the DLL is not registered.. its just a normal DLL ... it waits till I call the FreeLibrary(); function .... but I have no idea how to do this in C#

        N 1 Reply Last reply
        0
        • W wb

          my problem: I have to port a Project from C++ to C# there is a DLL, i can load [DllImport("blabla.dll")] public extern static void CancelSearch(); . . . and use it... and then end the programm BUT there is a deadlock, cause the FreeLibrary(); is never called by C# :( (if I remove the FreeLibrary(); in C++ then the C++ App hangs too) any idea how to unload the DLL?

          P Offline
          P Offline
          Philip Fitzsimons
          wrote on last edited by
          #4

          trying use app domains - put the dll calling code in a sep domain - then when you unload the domain the dll should get unload as well...


          "When the only tool you have is a hammer, a sore thumb you will have."

          W 1 Reply Last reply
          0
          • W wb

            my problem: I have to port a Project from C++ to C# there is a DLL, i can load [DllImport("blabla.dll")] public extern static void CancelSearch(); . . . and use it... and then end the programm BUT there is a deadlock, cause the FreeLibrary(); is never called by C# :( (if I remove the FreeLibrary(); in C++ then the C++ App hangs too) any idea how to unload the DLL?

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

            As far as i know the dll never gets loaded, u can only call static methods and the dll gets used to perform the function by Interop Services. Any dll (assembly) that gets loaded will be written to the debug console when they are loaded. MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D

            1 Reply Last reply
            0
            • W wb

              no, the DLL is not registered.. its just a normal DLL ... it waits till I call the FreeLibrary(); function .... but I have no idea how to do this in C#

              N Offline
              N Offline
              Nick Parker
              wrote on last edited by
              #6

              So are you only trying to call the FreeLibrary(); function from this .dll? If so and it is non .NET then you will need to use COM Interop. HTH Nick Parker


              C 1 Reply Last reply
              0
              • P Philip Fitzsimons

                trying use app domains - put the dll calling code in a sep domain - then when you unload the domain the dll should get unload as well...


                "When the only tool you have is a hammer, a sore thumb you will have."

                W Offline
                W Offline
                wb
                wrote on last edited by
                #7

                thanks! I think this may work.... but I can't find any sample code with AppDomains do you know a link?:-O

                P 1 Reply Last reply
                0
                • W wb

                  thanks! I think this may work.... but I can't find any sample code with AppDomains do you know a link?:-O

                  P Offline
                  P Offline
                  Philip Fitzsimons
                  wrote on last edited by
                  #8

                  see msdn article^


                  "When the only tool you have is a hammer, a sore thumb you will have."

                  1 Reply Last reply
                  0
                  • N Nick Parker

                    So are you only trying to call the FreeLibrary(); function from this .dll? If so and it is non .NET then you will need to use COM Interop. HTH Nick Parker


                    C Offline
                    C Offline
                    Christopher Lord
                    wrote on last edited by
                    #9

                    Normal DLL's dont use COM, and thus COM-interop will not be useful here.

                    N 1 Reply Last reply
                    0
                    • C Christopher Lord

                      Normal DLL's dont use COM, and thus COM-interop will not be useful here.

                      N Offline
                      N Offline
                      Nick Parker
                      wrote on last edited by
                      #10

                      Christopher Lord wrote: Normal DLL's dont use COM, and thus COM-interop will not be useful here. Isn't it :((. I must have been spacing off when I was typing my response, please forgive. Nick Parker


                      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