Using PowerShell with .NET 3.5 runtime/libraries

安稳与你 提交于 2019-12-05 04:43:38

If you have 3.5 installed on your system, that is what you'll get when you run PowerShell.

PowerShell is only "requires" 2.0 but 3.0 and 3.5 are compatible and autoforward when installed. In PowerShell V2, we actually look to see what version you have and "light up" certain features (e.g. PowerShell_ISE and Out-GridView are available when you have 3.51).

Experiment! Enjoy! Engage!

Jeffrey Snover [MSFT] Windows Management Partner Architect

As long as your get your fully qualified name right, I don't see why this wouldn't work:

[System.Reflection.Assembly]::Load("System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")

I only used Linq as that was the first one to come to mind. At that point, the ddl is loaded, and you can create/use objects out of that.

PowerShell was built against 2.0, so you don't have any options but to have 2.0 present at least. But like James says, you can load 3.0 and 3.5 functionality by loading the appropriate assembly. LINQ is a good example from 3.5, but you can also do WPF (3.0) from PowerShell. Be mindful of STA and MTA for WPF though, as only PowerShell v2 has full support for WPF (full support for thread affinity).

3.5 is effectively an ADD-ON for 2.0. That is to say, there are no superceded classes in 3.5; it is not a replacement. The CLR (common language runtime) is still v2.0.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!