Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 09-02-2009
Member
 
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?
Reply With Quote
  #2  
Old 09-02-2009
Member
 
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.
Reply With Quote
  #3  
Old 09-02-2009
Member
 
Join Date: May 2008
Posts: 1,180
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
Reply With Quote
  #4  
Old 09-02-2009
Member
 
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.
Reply With Quote
  #5  
Old 09-02-2009
Member
 
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
    Quote:
    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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to load/unload DLLs in Powershell ?"
Thread Thread Starter Forum Replies Last Post
WD Caviar Green WD30EZRX Load/unload Cycle count getting very High #4 Hardware Peripherals 7 23-03-2012 02:22 PM
How to load unload an internal mc into an empty mc Wannabe Software Development 3 15-09-2009 06:18 PM
Load dlls needed for kernel error in Windows XP Coollin Operating Systems 3 17-08-2009 08:46 AM
Load dlls needed for kernel Abhiraj Operating Systems 4 26-05-2009 08:39 AM
Windows XP can't start..Load needed DLLs.. Arlo1 Windows XP Support 3 24-01-2008 07:27 PM


All times are GMT +5.5. The time now is 10:35 AM.