Powershell 2.0远程加载.Net 4.0 dll [英] Powershell 2.0 Remoting loading a .Net 4.0 dll
问题描述
我正在尝试在远程Powershell 2.0会话中使用[Reflection.Assembly] :: LoadFrom加载.Net 4.0程序集。由于我对powershell.exe.config文件进行了更改,因此它可以在本地运行,但是在远程会话中出现此程序集是由运行时更新的版本构建的……异常而失败。
I am trying to load a .Net 4.0 assembly, using [Reflection.Assembly]::LoadFrom, inside of a remote Powershell 2.0 session. It works locally, due to a change I made to the powershell.exe.config file, but fails with a "This assembly is built by a runtime newer ..." exception in a remote session.
所涉及的两台机器都具有.Net 2.0和4.0,并且对x86和x64位powershell可执行文件的powershell.exe.config进行了更改。我还尝试过更改服务器Powershell注册表项:
HKLM:\软件\Microsoft\Powershell\1\PowerShellEngine\RuntimeVersion
HKLM:\软件\Wow6432Node\ Microsoft\Powershell\1\PowerShellEngine\RuntimeVersion
Both machines involved have .Net 2.0 and 4.0, and have the powershell.exe.config change for the x86 and x64 bit powershell executables. I've also tried changing the server powershell registry keys: HKLM:\Software\Microsoft\Powershell\1\PowerShellEngine\RuntimeVersion HKLM:\Software\Wow6432Node\Microsoft\Powershell\1\PowerShellEngine\RuntimeVersion
我必须丢失某些内容,但我不知道它是什么。
I must be missing something, but I don't know what it is.
编辑:
以下是我正在执行的代码示例。
Following is an example of the code I am executing.
PS C:\>Enter-PSSession -ComputerName server1
[server1]: PS C:\stuff> dir *.dll | foreach { [Reflection.Assembly]::LoadFrom( $_.FullName ) }
推荐答案
解决方案是在计算机上的上创建ac:\windows\System32\wsmprovhost.exe.config文件和ac:\windows\SysWOW64\wsmprovhost.exe.config文件。服务器,类似于我在以下位置找到的服务器: http://poshcode.com/2045
The solution is to create a c:\windows\System32\wsmprovhost.exe.config file and a c:\windows\SysWOW64\wsmprovhost.exe.config file, on the server, similar to the one I found at: http://poshcode.com/2045
<?xml version="1.0" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0" />
</startup>
</configuration>
我发现以下文章,暗示wsmprovhost.exe需要像Powershell一样进行配置。 exe文件。
http://tfl09.blogspot.com/2010/ 08 / using-later-versions-of-net-framework.html
I found the following article, which hinted at wsmprovhost.exe needing to be configured just like the powershell.exe file. http://tfl09.blogspot.com/2010/08/using-later-versions-of-net-framework.html
这篇关于Powershell 2.0远程加载.Net 4.0 dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!