Thursday, April 3, 2014

How to load .Net 4 compiled dll in Powershell ?

Do you get error like :

Exception calling "LoadFile" with "1" argument(s): "This assembly is built by a runtime
newer than the currently loaded runtime and cannot be loaded. (Exception from HRESULT:

OK ,  MS may be mute on this but you have to get your work going .  SImple sweet solution is go to C:\Windows\System32\WindowsPowerShell\v1.0  and create a file named powershell.exe.config   ,  content like :

<?xml version="1.0"?>
 <startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0.30319"/>
  <supportedRuntime version="v2.0.50727"/>

After all this did you make sure your powershell is running from C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe  ?

1 comment:

  1. […] of all please read , this script uses .Net 4.0 dll $message = “”; # I just wanted to post a url no message […]