2011-01-08 90 views
7

我想在遠程Powershell 2.0會話中使用[Reflection.Assembly] :: LoadFrom加載.Net 4.0程序集。由於我對powershell.exe.config文件進行了更改,它在本地工作,但在遠程會話中出現「此程序集由運行時更新......」異常失敗。Powershell 2.0 Remoting加載.Net 4.0 dll

涉及的兩臺計算機都具有.Net 2.0和4.0,並且對x86和x64位powershell可執行文件具有powershell.exe.config更改。我也試圖改變服務器的PowerShell註冊表項:HKLM :\軟件\微軟\ Powershell的\ 1 \ PowerShellEngine \ RuntimeVersion HKLM:\ SOFTWARE \ Wow6432Node \微軟\ Powershell的\ 1 \ PowerShellEngine \ RuntimeVersion

我必須錯過了一些東西,但我不知道它是什麼。

編輯: 以下是我正在執行的代碼的一個示例。

PS C:\>Enter-PSSession -ComputerName server1 
[server1]: PS C:\stuff> dir *.dll | foreach { [Reflection.Assembly]::LoadFrom($_.FullName) } 
+0

請顯示您正在使用的命令.. – 2011-01-08 01:59:15

回答

7

的解決方案是創建c:\ WINDOWS \ SYSTEM32 \ wsmprovhost.exe.config文件和交流:\ WINDOWS \ Syswow64資料\ wsmprovhost.exe.config文件,服務器,類似於一個上我發現在: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

相關問題