System.IO.FileNotFoundException:找不到部署应用程序时无法加载文件或程序集“X”或它的一个依赖 [英] System.IO.FileNotFoundException: Could not load file or assembly 'X' or one of its dependencies when deploying the application

查看:9133
本文介绍了System.IO.FileNotFoundException:找不到部署应用程序时无法加载文件或程序集“X”或它的一个依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

Starter.exe通常在本地mashine开始。然而,当我起动debug文件夹中的所有内容复制到虚拟mashine,并尝试启动它在那里,它有以下异常崩溃:

 未处理的异常信息:System.IO.FileNotFoundException:无法加载文件或程序
集'X'或它的一个依赖。指定的模块无法找到。
 

这没有任何意义,我,因为X是正确的,在同一个文件夹Starter.exe。

什么引起这个问题?

更新

我已经研究在反射器在目标机器上的依赖,这是能够找到文件,所有这一切。

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

更新

下面是从融合日志日志(位置:C:\ FusionLog \默认\ Starter.exe \ X,版本= 1.0.4538.22813文化=中性公钥= null.HTM):

  ***大会粘结剂日志条目(2012年6月4日@下午1点56分13秒)***

手术很成功。
绑定结果:HR =为0x0。操作已成功完成。

C:从装配​​经理装\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ clr.dll
下可执行的C运行:\的Documents and Settings \ Administrator的\桌面\ TMP \ K表;ķ\ Starter.exe
---详细的错误日志如下。

=== pre-绑定状态信息===
日志:用户= MENKAUR-7683827 \管理员
日志:显示名称= X,版本= 1.0.4538.22813文化=中性公钥=空
 (完全限定)
日志:应用平台=文件:/// C:/ Documents和设置/管理/桌面/ tmp目录/ K; K /
LOG:初始PrivatePath = NULL
日志:动基座= NULL
日志:缓存基地= NULL
LOG:AppName的= Starter.exe
调用汇编:入门,版本= 1.0.0.0,文化=中性公钥=空。
===
日志:此绑定从default加载上下文。
日志:正在使用应用程序配置文件:C:\ Documents和Settings \管理员\桌面\ TMP \ K表;ķ\ Starter.exe.Config
日志:使用主机配置文件:
日志:从C使用计算机配置文件:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ CONFIG \ machine.config中。
日志:政策不被应用到引用在这个时候(私人,自定义,局部的,或基于位置的程序集绑定)。
日志:新的URL文件试图下载:/// C:/ Documents和设置/管理/桌面/ tmp目录/ K; k / X.DLL。
日志:程序集下载成功。尝试安装文件:C:\ Documents和Settings \管理员\桌面\ TMP \ K表;ķ\ X.dll
日志:进入运行从源代码安装阶段。
日志:大会名称为:X,版本= 1.0.4538.22813文化=中性公钥=空
日志:绑定成功。返回组件从C:\的Documents and Settings \ Administrator的\桌面\ TMP \ K表;ķ\ X.dll。
日志:大会默认加载上下文中加载。
 

唯一的错误是在C:\ FusionLog \ NativeImage \ Starter.exe \目录下:

  ***大会粘结剂日志条目(2012年6月4日@下午1点56分13秒)***

操作失败。
绑定结果:HR = 0x80070002。该系统找不到指定的文件。

C:从装配​​经理装\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ clr.dll
下可执行的C运行:\的Documents and Settings \ Administrator的\桌面\ TMP \ K表;ķ\ Starter.exe
---详细的错误日志如下。

=== pre-绑定状态信息===
日志:用户= MENKAUR-7683827 \管理员
日志:显示名称= BookmarkWiz.Kernel,版本= 1.0.4538.22813文化=中性公钥=空
 (完全限定)
日志:应用平台=文件:/// C:/ Documents和设置/管理/桌面/ tmp目录/ K; K /
LOG:初始PrivatePath = NULL
日志:动基座= NULL
日志:缓存基地= NULL
LOG:AppName的= Starter.exe
调用汇编:入门,版本= 1.0.0.0,文化=中性公钥=空。
===
日志:启动本机映像的X结合,版本= 1.0.4538.22813文化=中性公钥=空。
警告:没有匹配的本机映像发现。
日志:IL汇编从C装:\的Documents and Settings \ Administrator的\桌面\ TMP \ K表;ķ\ X.dll。
 

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

解决方案
  

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

最有可能加载失败的另一个依赖。

您可以尝试检查依赖与依赖学步车。

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

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

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

下面参见:<一href="http://stackoverflow.com/questions/7326371/detected-dlls-that-are-from-the-internet-and-blocked-by-caspol">Detected DLL文件是从互联网和&QUOT;阻止&QUOT;通过CASPOL

I'm having a strange problem with deploying an application, which references an assembly, written in managed c++.

I've created an assembly X, compiled it and referenced it in an exe file, called Starter.

Starter.exe starts normally on local mashine. However, when I copy ALL contents of the starter debug folder to a virtual mashine, and try to start it there, it crashes with following exception:

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

This does not make any sense to me, because X is right in the same folder as Starter.exe.

What could be causing this problem?

UPDATE

I've examined the dependencies in Reflector on the target machine, and it was able to find files for all of those.

I've also changed the configurations to x86/win32 for all projects.

UPDATE

Here are the logs from Fusion Log (location: 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.

The only errors are in C:\FusionLog\NativeImage\Starter.exe\ directory:

*** 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.

I cannot sign the assembly, as it references several other assemblies, which are not signed

解决方案

... Could not load file or assembly 'X' or one of its dependencies ...

Most likely it fails to load another dependency.

you could try to check the dependencies with a dependency walker.

I.e: http://www.dependencywalker.com/

Also check your build configuration (x86 / 64)

Edit: I also had this problem once when I was copying dlls in zip from a "untrusted" network share. The file was locked by Windows and the FileNotFoundException was raised.

See here: Detected DLLs that are from the internet and "blocked" by CASPOL

这篇关于System.IO.FileNotFoundException:找不到部署应用程序时无法加载文件或程序集“X”或它的一个依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆