16 Jan 2013 @ 8:11 AM 

Whenever you’re writing aPowerShell SnapIn you may encounter an error when you try to load the PSSnapIn.
Specifically, when the error states:

Add-PSSnapin : Cannot load Windows PowerShell snap-in because of the following error: Could not load file or assembly or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Now this is a nasty little thing to find the cause of so I’ve decided to write this blog post.
The solution for this, at least in my case, was to create a powershell.exe.config file in the PowerShell folder (for x86 ‘%windir%\System32\WindowsPowerShell\V1.0‘ and for x64 ‘%windir%\Syswow64\WindowsPowerShell\V1.0′).
In this file, place the following content:

<CONFIGURATION>
  <STARTUP useLegacyV2RuntimeActivationPolicy="true">
    <SUPPORTEDRUNTIME version="v4.0.30319"></SUPPORTEDRUNTIME>
    <SUPPORTEDRUNTIME version="v2.0.50727"></SUPPORTEDRUNTIME>
  </STARTUP>
</CONFIGURATION>

Now restart your PowerShell console (if it’s opened at that time) and you’re set :-)

Post to Twitter

Posted By: Jeff Wouters
Last Edit: 16 Jan 2013 @ 08:12 AM

EmailPermalink
Tags
Categories: DuPSUG, PowerShell



 Last 50 Posts
 Back
Change Theme...
  • Users » 1
  • Posts/Pages » 251
  • Comments » 430
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.

Contact



    No Child Pages.