3

我尝试在 PowerShell v2.0 中从.NET 4.0 beta2加载 PresentationFramework.dll 。但它失败并出现以下错误。

PS C:\Windows\system32> [Reflection.Assembly]::LoadFile("C:\Windows\Microsoft.NET\Framework\v4.0.21006\WPF\PresentationF ramework.dll")

使用“1”参数调用“LoadFile”的异常:“此程序集由比当前加载的运行时更新的运行时构建,无法加载。(来自 HRESULT 的异常:0x8013101B)”在第 1 行字符:32 + [ Reflection.Assembly]::LoadFile <<<< ("C:\Windows\Microsoft.NET\Framework\v4.0.21006\WPF\PresentationFramework.dll") + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId :点网方法异常

如何在 PowerShell 2.0 中加载此 DLL 文件?

4

3 回答 3

0

你不能加载它。PowerShell 正在使用 .NET 2.0 CLR,无法加载 4.0 DLL 文件。

重新配置 PowerShell 以在较新的 CLR 中运行或在 .NET 4.0 应用程序中托管 PowerShell 可能是可能的,但我不推荐其中任何一种。

于 2009-12-21T16:26:29.417 回答
0

在PowerShell的管理模式下运行此代码:

reg add hklm\software\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1
reg add hklm\software\wow6432node\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1
于 2014-06-11T12:33:45.500 回答
0

我在 Windows Server 2008(使用 PowerShell v2)上遇到了类似的问题,我通过安装这两个更新解决了:

微软 .NET 框架 4.5.1 https://www.microsoft.com/fr-fr/download/details.aspx?id=40779

PowerShell v4 https://www.microsoft.com/en-US/download/details.aspx?id=40855

于 2016-02-20T23:49:02.957 回答