I've read the whole thread about running PowerShell under .NET 4.0, including the 开发者_运维问答warnings about what happens when using the registry keys to make the scripts run under that framework.
So far, I only get the desired result with the registry keys. Is anyone aware of a way to make this work without changing the registry keys? When I checked PowerGUI's discussion boards, even they pointed to the stackoverflow thread. Has anyone come up with something better since April 2010?
1- Go to: "C:\Program Files (x86)\PowerGUI" and create a "ScriptEditor.exe.config" file.
2- Paste this xml in the file
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
3- Enjoy
This way, your change won't alter the whole machine.
RE "something better" - short of PowerGUI being recompiled to target .NET 4.0 - no. Out of curiousity, what .NET 4.0 feature are you trying to access in .NET 4?
I'm not a dev but maybe you create a config file for powergui. Check this page:
http://poshcode.org/1971
精彩评论