The PowerShell ISE is much improved in V3, needless to say I am really enjoying writing scripts with this tool! It is however, not without hiccups.

I was trying to run the Invoke-Sqlcmd cmdlet when I got the following error in the PowerShell ISE

Mixed mode assembly is built against version ‘v2.0.50727’ of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

Basically just means PowerShell has support for side-by-side runtime, and we need to specify an activation policy in a config file. The config file name must be placed in the same directory as your exe file, and must be named the same as your exe file, plus a .config extension.

Solution

1.Create a config file for the powershell_ise.exe called powershell_ise.exe.config and place this in the PowerShell directory:
C:\Windows\System32\WindowsPowerShell\v1.0

2. Add the following to your powershell_ise.exe.config file:

<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" /> </startup> <runtime> <generatePublisherEvidence enabled="false" /> </runtime> </configuration>

Thanks to Richard Fennel’s post “Mixed mode assembly is built against version ‘v2.0.50727’ error using .NET 4 Development Web Server”, which helped me fix this issue.

VN:F [1.9.22_1171]
Rating: 10.0/10 (5 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Resolving PowerShell V3 ISE error with Invoke-Sqlcmd, 10.0 out of 10 based on 5 ratings
Be Sociable, Share!