Results 1 to 5 of 5

Thread: How to load/unload DLLs in Powershell ?

  1. #1
    Join Date
    May 2008
    Posts
    976

    How to load/unload DLLs in Powershell ?

    I created a new DLL on my own but when I use [System.Reflection.Assembly]::LoadFile("filename.dll"), everything locks on the DLL file and I had to quit PowerShell to get to normal. This is quiet annoying. So I want a way to just avoid this situation.

    Is there anyone who succeeded doing so in PowerShell?

  2. #2
    Join Date
    May 2008
    Posts
    913

    Re: How to load/unload DLLs in Powershell ?

    In general, you don't load DLL but instead you load assemblies. Once loaded they can't be unloaded until the life of the application. If you truly want to unload DLLs then you need to do heavy lifting yourself. After you are done with the DLL use FreeLibrary to unload the DLL.

  3. #3
    Join Date
    May 2008
    Posts
    1,196

    Re: How to load/unload DLLs in Powershell ?

    You may create the new AppDomain, load assembly into it and continue performing your operations. Once you have completed your work, you may unload the AppDomain and move further. But always remember that the assembly can be unloaded only with the parent AppDomain. You couldn't unload single assembly from the AppDomain.

    Refer http://msdn.microsoft.com/en-us/libr...appdomain.aspx for further details on AppDomain Class

  4. #4
    Join Date
    May 2008
    Posts
    611

    Re: How to load/unload DLLs in Powershell ?

    You can't just unload a dll externally though. You would have to ask a process to do it, which means said software has some way to successfully process such a request either through message or some sort of configuration read on start up.

    If I wrote a piece of software that used a dll, I can load it implicitly or explicitly. Usually implicit loads are for mandatory dlls, explicit for optional ones. If I'm loading a dll that means it's in my memory space and therefore should be inviolate, only the software that loaded it can unload it, it's the owner.

  5. #5
    Join Date
    May 2008
    Posts
    669

    Re: How to load/unload DLLs in Powershell ?

    1. Go to Start - Run and type regedit
    2. Navigate to the following key:
      HKEY_LOCAL_MACHINE - Software - Microsoft - Windows - CurrentVersion - Explorer - AlwaysUnloadDLL
      Note: If you do not have one then create a new sub-key named 'AlwaysUnloadDLL'
    3. Click on it and set the default value to '1'.
    4. Click OK and restart your computer

Similar Threads

  1. Replies: 7
    Last Post: 23-03-2012, 02:22 PM
  2. How to load unload an internal mc into an empty mc
    By Wannabe in forum Software Development
    Replies: 3
    Last Post: 15-09-2009, 06:18 PM
  3. Load dlls needed for kernel error in Windows XP
    By Coollin in forum Operating Systems
    Replies: 3
    Last Post: 17-08-2009, 08:46 AM
  4. Load dlls needed for kernel
    By Abhiraj in forum Operating Systems
    Replies: 4
    Last Post: 26-05-2009, 08:39 AM
  5. Windows XP can't start..Load needed DLLs..
    By Arlo1 in forum Windows XP Support
    Replies: 3
    Last Post: 24-01-2008, 07:27 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,883,169.34961 seconds with 16 queries