From 9577a4e2c2ea2679c96874498de037a88911962b Mon Sep 17 00:00:00 2001 From: Matt Graeber Date: Fri, 16 Aug 2013 06:28:47 -0400 Subject: Compiler parameters were not applied to Add-Type The compiler parameters were not being applied to Add-Type in Get-PEHeader. Derp. This led to unexpected errors when Visual Studio environment variables were defined. --- PETools/Get-PEHeader.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/PETools/Get-PEHeader.ps1 b/PETools/Get-PEHeader.ps1 index 551aac0..2f35292 100644 --- a/PETools/Get-PEHeader.ps1 +++ b/PETools/Get-PEHeader.ps1 @@ -525,12 +525,10 @@ PROCESS { } "@ - $location = [PsObject].Assembly.Location $compileParams = New-Object System.CodeDom.Compiler.CompilerParameters - $assemblyRange = @("System.dll", $location) - $compileParams.ReferencedAssemblies.AddRange($assemblyRange) + $compileParams.ReferencedAssemblies.AddRange(@('System.dll', 'mscorlib.dll')) $compileParams.GenerateInMemory = $True - Add-Type -TypeDefinition $code -passthru -WarningAction SilentlyContinue | Out-Null + Add-Type -TypeDefinition $code -CompilerParameters $compileParams -PassThru -WarningAction SilentlyContinue | Out-Null } function Get-DelegateType -- cgit v1.2.3