System.IO.FileNotFoundException:找不到部署应用程序时无法加载文件或程

2019-05-17 06:07发布

我在与部署应用程序,它引用了一个装配,用托管C ++一个奇怪的问题。

我创建了一个组装X,编译它,并在一个exe文件,称为启动引用它。

Starter.exe当地mashine正常启动。 然而,当我启动调试文件夹的所有内容复制到虚拟mashine,并尝试那里开始它,它崩溃与以下情况除外:

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。

这可能是造成这个问题?

UPDATE

我检查了依赖于目标机器上反射,这是能够找到的文件,所有这些的。

我也改变了配置,以86 / win32的所有项目。

UPDATE

下面是来自Fusion日志的日志(位置:C:\ FusionLog \默认\ Starter.exe \ X,版本= 1.0.4538.22813文化=中性公钥= 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.

我无法登录大会,因为它引用了其他几个组件,未签署

Answer 1:

...未能加载文件或程序集“X”或它的一个依赖 ...

最有可能无法加载另一个依赖。

你可以尝试用的Dependency Walker检查的依赖关系。

即: http://www.dependencywalker.com/

另外,请检查您的构建配置(86/64)

编辑:我也有这个问题,一旦当我从一个“不可信”的网络共享复制拉链的DLL。 该文件被Windows锁住,FileNotFoundException异常升高。

在这里看到: 检测到的DLL是从互联网和CASPOL“封杀”



Answer 2:

我通过重命名DLL解决了这个问题。 该DLL就当它被上传到它的共享位置手动改名(版本号被附加到文件名)。 从下载的文件中删除版本号解决了这个问题。



Answer 3:

我遇到过同样的问题。 对我来说,它有助于去除.VS目录中的项目文件夹。



文章来源: System.IO.FileNotFoundException: Could not load file or assembly 'X' or one of its dependencies when deploying the application