0

次の構成の C# .NET Framework 2 アプリケーションがあります。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0"/>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

Assembly Binding Log Viewer (fuslogvw.exe) を使用すると、.NET Framework 4.0 で次のようなエラーが発生します。

*** Assembly Binder Log Entry  ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\myprog.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = WINDOWS\Administrator
LOG: DisplayName = System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = myprog.exe
Calling assembly : myprog, Version=20.0.17510.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Start binding of native image System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
WRN: No matching native image found.

.NET Framework 4.5 を使用すると、操作は成功します。

*** Assembly Binder Log Entry  (2/28/2014 @ 3:35:59 AM) ***

The operation was successful. Bind result: hr = 0x1. Incorrect function.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under executable  C:\myprog.exe

--- A detailed error log follows. 

BEGIN : Native image bind.
END   : Incorrect function. (Exception from HRESULT: 0x00000001 (S_FALSE))


*** Assembly Binder Log Entry  (2/28/2014 @ 3:35:59 AM) ***

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

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\myprog.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = WINDOWS2\Administrator
LOG: DisplayName = System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = myprog.exe
Calling assembly : myprog, Version=20.0.17510.0, Culture=neutral, PublicKeyToken=null.
===
WRN: No matching native image found.


*** Assembly Binder Log Entry  (2/28/2014 @ 3:35:59 AM) ***

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

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\myprog.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = WINDOWS2\Administrator
LOG: DisplayName = System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = myprog.exe
Calling assembly : myprog, Version=20.0.17510.0, Culture=neutral, PublicKeyToken=null.
===
WRN: No matching native image found.

私は試しました: .csproj ファイルに追加します。

レジストリに次のエントリを追加します。

プロジェクトで C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\System.Management.Automation.dll を参照します。

追加する

<startup useLegacyV2RuntimeActivationPolicy="true">  

アプリケーション構成で。

奇妙なことに、これは .NET Framework 4.0、2.0、および 4.5 でのみ発生します。

任意の提案をいただければ幸いです。

ありがとうございました

4

0 に答える 0