Please consider the following scenario.

  • Launch Windows Powershell ISE (64 bit)
  • Create a new PowerShell Tab
  • Create a new PS script which loads a custom assembly by invoking [System.Reflection.Assembly]::LoadFrom

  • Create an instance of an object from your custom assembly by invoking the New-Object command

  • Run the script and verify that an instance of your custom object was created.
  • Close the PowerShell Tab. But, keep PowerShell ISE running. I would have expected PowerShell ISE to have completely unloaded the assembly.

However, the custom assembly is locked until PowerShell ISE is closed down completely.

I am developing a custom .NET library using Visual Studio .NET and PowerShell is a client application of this library. Since closing the Tab does not unlock the assembly, I have to close and re-start Powershell ISE every time I make a change in Visual Studio. This behaviour of PowerShell ISE is drastically slowing down my development time.

Is there a workaround to this issue?

Loading a custom assembly in ISE through reflection

Thanks, Sau

  • If you load a form you should verify you unload it.
    – Ramhound
    May 19, 2018 at 22:15
  • Hi @Ramhound, Just added a picture to better explain my scenario. I am not sure I understand by "unload". I am not creating a Windows Form. Just a plain C# class. I think the problem would show up even if it were a custom Windows Form because PowerShell has loaded the assembly in its AppDomain. I would have expected PowerShell to unload the AppDomain associated with the PowerShell Tab.
    – Sau001
    May 20, 2018 at 10:46
  • .NET assemblies cannot be unloaded. The only way to unload an assembly is to tear down the entire AppDomain.
    – Daniel B
    May 20, 2018 at 11:14
  • Hi @DanielB, Thanks for commenting. You are absolutely right. Do you know why PowerShell would not tear down the AppDomain when closing a Tab? I reckon this to be a bug. But, I would be surprised that Microsoft is not aware of this issue.
    – Sau001
    May 20, 2018 at 16:41
  • PowerShell does not use AppDomains. You can easily check with Process Explorer, in the .NET Assemblies tab of a process.
    – Daniel B
    May 20, 2018 at 22:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.