无法加载文件或程序集系统找不到指定的文件 [英] Could not load file or assembly The system cannot find the file specified

查看:356
本文介绍了无法加载文件或程序集系统找不到指定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个dll,它引用了第二个DLL。我在第一个dll的项目中添加了第二个dll作为参考,转到属性>共同属性>框架和参考>添加新参考>浏览



我从第三方的源代码编译了第二个DLL。这两个项目都是C ++ / CLI。
每当我的主应用程序尝试调用第一个dll中包含对第二个dll的调用的函数时,我会收到以下错误:


未知模块中出现未处理的类型System.IO.FileNotFoundException
的异常。



附加信息:无法加载文件或程序集 NBIS,
Version = 1.0.5156.29834,Culture = neutral,PublicKeyToken = null'或一个
的依赖关系。系统找不到指定的文件。


我有一个第二个dll的副本在与我的主要exe相同的目录,我甚至尝试在第一个dll旁边保留一个副本,没有效果。



第二个dll引用了几个静态库,但它包含的唯一程序集引用是


系统



System.Data



System.Drawing



System.XML


所有这些我作为汇编引用添加到第一个dll。



我可以做些什么来让我的应用程序找到并加载第二个dll?

解决方案

正如评论中所指出的,SysInternals的过程监视器是一个有价值的诊断DLL解决问题的工具。告诉你当第三方DLL有一个你不知道的依赖关系时,还会告诉你Windows在找到你的硬盘驱动器的错误角落找到错误的一个。



装载机快照是Windows内置的诊断工具。但是进程监视器更方便。



它生成的信息很多,从跟踪底部开始,或者在正确的时间启用跟踪。您经常需要使用其过滤工具来转换相关涓涓the。。。。值得你花时间弄清楚,这个工具属于任何程序员的黑带。


I am building a dll, which references a second dll. I have added the second dll as a reference in the first dll's project by going to Properties > Common Properties > Framework and References > Add New Reference > Browse

I compiled the second dll from a third party's source code. Both projects are C++/CLI. Whenever my main application tries to call a function in the first dll which contains a call to the second dll, I get the following error:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.

Additional information: Could not load file or assembly 'NBIS, Version=1.0.5156.29834, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

I have a copy of the second dll in the same directory as my main exe, and I've even tried keeping a copy next to the first dll as well, to no avail.

The second dll references several static libraries, but the only Assembly References it contains are

System

System.Data

System.Drawing

System.XML

All of which I have added as assembly references in the first dll.

What can I do to get my application to find and load the second dll?

解决方案

As pointed out in the comments, SysInternals' Process Monitor is a valuable tool to diagnose DLL resolution problems. Tells you when a 3rd party DLL has a dependency you don't know about, also tells you when Windows is looking in the wrong corner of your hard drive for the file or finds the wrong one.

Loader snaps is the built-in diagnostic tool for Windows. But Process Monitor is far more convenient.

It does generate rather a lot of information, start from the bottom of the trace or enable tracing at just the right time. You often need to use its filtering tools to turn the firehose in a relevant trickle. Worth the hour of your time to figure it out, this tool belongs on any programmer's black belt.

这篇关于无法加载文件或程序集系统找不到指定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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