Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.IO.FileNotFoundException:无法加载文件或程序集';X';或部署应用程序时的一个依赖项 我在部署一个应用程序时遇到了一个奇怪的问题,它引用了一个用托管C++编写的程序集。_C#_.net_Deployment_.net Assembly_Managed C++ - Fatal编程技术网

C# System.IO.FileNotFoundException:无法加载文件或程序集';X';或部署应用程序时的一个依赖项 我在部署一个应用程序时遇到了一个奇怪的问题,它引用了一个用托管C++编写的程序集。

C# System.IO.FileNotFoundException:无法加载文件或程序集';X';或部署应用程序时的一个依赖项 我在部署一个应用程序时遇到了一个奇怪的问题,它引用了一个用托管C++编写的程序集。,c#,.net,deployment,.net-assembly,managed-c++,C#,.net,Deployment,.net Assembly,Managed C++,我创建了一个程序集X,编译它并在一个名为Starter的exe文件中引用它 Starter.exe在本地mashine上正常启动。但是,当我将starter debug文件夹的所有内容复制到虚拟mashine并尝试在那里启动它时,它会崩溃,出现以下异常: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'X' or one of its dependencies. The

我创建了一个程序集X,编译它并在一个名为Starter的exe文件中引用它

Starter.exe在本地mashine上正常启动。但是,当我将starter debug文件夹的所有内容复制到虚拟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位于同一文件夹中

是什么导致了这个问题

更新

我已经检查了目标机器上Reflector中的依赖项,它能够找到所有这些依赖项的文件

我还将所有项目的配置更改为x86/win32

更新

以下是Fusion日志中的日志(位置:C:\FusionLog\Default\Starter.exe\X,版本=1.0.4538.22813,区域性=中性,PublicKeyToken=null.HTM):

唯一的错误在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.
我无法对程序集进行签名,因为它引用了其他几个未签名的程序集

。。。无法加载文件或程序集“X”或其依赖项之一

很可能它无法加载另一个依赖项

您可以尝试使用依赖项查询器检查依赖项

即:

还要检查生成配置(x86/64)

编辑: 有一次,当我从一个“不受信任”的网络共享复制zip中的DLL时,我也遇到了这个问题。该文件已被Windows锁定,并引发FileNotFoundException


请参见此处:

我通过重命名DLL解决了此问题。DLL在上载到其共享位置时已手动重命名(文件名后附加了版本号)。从下载的文件中删除版本号解决了问题。

我也遇到了同样的问题。对我来说,它有助于删除项目文件夹中的.vs目录

我在尝试安装Windows服务时也遇到了同样的问题,在我的情况下,我通过删除service.exe文件夹路径中的空格解决了问题,下面是在命令提示符下为我使用的命令

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

按ENTER键更改工作目录

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


按ENTER键,我从windows资源管理器中启动了应用程序(双击)。然后它立刻坠毁了


然后,我打开windows的
事件查看器
,查看
应用程序
,它显示了完整的错误跟踪。stacktrace显示与位图或图像的关系。后来证明,这是由于找不到应用程序图标造成的。

我在每个论坛上都读到了关于这个主题的文章,但我仍然遇到了问题(在试图从git进行项目时出现了问题)

经过4个小时和大量的咒骂,我自己解决了这个问题,只需更改项目属性中的目标框架设置(右键单击project->properties)->应用程序,并将目标框架从.net core 3.0更改为.net 5.0。我希望它能帮助任何人


happy coding gl hf nerds

请查看我的更新答案,并检查您的DLL是否因来源不可靠而被阻止。听起来您应该使用Fusion日志进行调查-这对我的情况没有帮助。@ArsenZahray那么您是如何解决此问题的?我面临着类似的问题<代码>System.IO.FileNotFoundException:无法加载文件或程序集“日志记录,版本=7.7.0.0,区域性=中性,PublicKeyToken=null”或其依赖项之一。@vaibhav:您可以附加到程序集。解决事件以找出缺少的程序集:
*** 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.