Resolving PowerShell V3 ISE error with Invoke-Sqlcmd
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.
1.Create a config file for the powershell_ise.exe called powershell_ise.exe.config and place this in the PowerShell directory:
2. Add the following to your powershell_ise.exe.config file:
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.