Wednesday, 4 February 2015

PowerShell: How do I open a reference without locking it?

I was recently writing a C# dll to the invoked in PowerShell. As I tested the PowerShell script, I found that the dll was being locked and any re-compiles from Visual Studio were being rejected.

I used the following code to resolve the problem:

$bytesCommon = [System.IO.File]::ReadAllBytes("c:\folder\driver.dll")
$loadResultCommon = [System.Reflection.Assembly]::Load($bytesCommon)

No comments:

Post a comment