相关疑难解决方法(0)

Powershell - 在应用程序配置文件中找不到程序集绑定重定向

这里有问题......

我有一个Powershell CmdLet,它在32位模式下运行时运行,在64位模式下运行失败.问题是原因是什么以及如何解决.

情况

Powershell CmdLet引用'OutlookHelper.Common.dll'.最新版本是2.0.0.0 CmdLet还使用日志记录和引用'Logging.dll'.
Logging.dll也引用'OutlookHelper.Common.dll',仅针对版本1.0.0.0进行编译.

我如何使它工作,这部分工作

在Powershell的应用程序配置文件中使用程序集绑定重定向:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0.30319"/> 
    <supportedRuntime version="v2.0.50727"/> 
  </startup> 
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="OutlookHelper.Common" publicKeyToken="5e4553dc0df45306"/>
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)

Powershell 32位工作得很好

在64位计算机上运行时,使用"Windows Powershell(x86)"可以正常运行.程序集管理器找到程序集绑定重定向:

The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Windows\syswow64\Windowspowershell\v1.0\powershell.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = MYDOMAIN\testuser
LOG: DisplayName = …
Run Code Online (Sandbox Code Playgroud)

.net powershell 32bit-64bit assembly-binding-redirect

11
推荐指数
3
解决办法
5184
查看次数