44

マネージ C++ で記述されたアセンブリを参照するアプリケーションのデプロイで奇妙な問題が発生しています。

アセンブリ X を作成し、それをコンパイルして、Starter という exe ファイルで参照しました。

Starter.exe は、ローカル マシンで正常に起動します。ただし、スターター デバッグ フォルダーのすべてのコンテンツを仮想マシンにコピーして、そこで起動しようとすると、次の例外でクラッシュします。

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or 
assembly 'X' or one of its dependencies. The specified module could not be found.

X は Starter.exe と同じフォルダーにあるため、これは私には意味がありません。

この問題の原因は何ですか?

アップデート

ターゲット マシンの Reflector の依存関係を調べたところ、それらすべてのファイルを見つけることができました。

また、すべてのプロジェクトの構成を x86/win32 に変更しました。

アップデート

Fusion Log のログは次のとおりです (場所: C:\FusionLog\Default\Starter.exe\X、Version=1.0.4538.22813、Culture=neutral、PublicKeyToken=null.HTM):

*** Assembly Binder Log Entry  (6/4/2012 @ 1:56:13 PM) ***

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:\Documents and Settings\Administrator\Desktop\tmp\k;k\Starter.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = MENKAUR-7683827\Administrator
LOG: DisplayName = X, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Documents and Settings/Administrator/Desktop/tmp/k;k/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Starter.exe
Calling assembly : Starter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Documents and Settings\Administrator\Desktop\tmp\k;k\Starter.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Documents and Settings/Administrator/Desktop/tmp/k;k/X.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Documents and Settings\Administrator\Desktop\tmp\k;k\X.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: X, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null
LOG: Binding succeeds. Returns assembly from C:\Documents and Settings\Administrator\Desktop\tmp\k;k\X.dll.
LOG: Assembly is loaded in default load context.

エラーは C:\FusionLog\NativeImage\Starter.exe\ ディレクトリにあります。

*** Assembly Binder Log Entry  (6/4/2012 @ 1:56:13 PM) ***

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

Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Documents and Settings\Administrator\Desktop\tmp\k;k\Starter.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = MENKAUR-7683827\Administrator
LOG: DisplayName = BookmarkWiz.Kernel, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Documents and Settings/Administrator/Desktop/tmp/k;k/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Starter.exe
Calling assembly : Starter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Start binding of native image X, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null.
WRN: No matching native image found.
LOG: IL assembly loaded from C:\Documents and Settings\Administrator\Desktop\tmp\k;k\X.dll.

署名されていない他のいくつかのアセンブリを参照しているため、アセンブリに署名できません

4

6 に答える 6

25

... ファイルまたはアセンブリ 'X' またはその依存関係の 1 つを読み込めませんでした ...

ほとんどの場合、別の依存関係のロードに失敗します。

依存関係ウォーカーで依存関係を確認してみてください。

すなわち: https://www.dependencywalker.com/

ビルド構成も確認してください (x86 / 64)

編集:「信頼されていない」ネットワーク共有からzipでdllをコピーしていたときに、この問題も1回発生しました。ファイルが Windows によってロックされ、FileNotFoundException が発生しました。

こちらを参照してください:インターネットから検出され、CASPOL によって「ブロック」された DLL

于 2012-06-04T08:50:43.023 に答える
1

Windowsサービスをインストールしようとしたときにも同じ問題が発生しました。私の場合、サービス.exeへのフォルダーパスの空白を削除することで問題を解決できました。以下は、コマンドプロンプトで機能したコマンドです。

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

Enter キーを押して作業ディレクトリを変更します

InstallUtil.exe C:\MyService\Release\ReminderService.exe

ENTER を押します

于 2020-01-31T19:16:56.957 に答える