C# 无法加载文件或程序集...系统找不到指定的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1479803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# could not load file or assembly...system cannot find file specified
提问by Bruce
Writing a routine WinForms app that references a few custom libraries written by myself. I am building one particular library which depends on another library and, when I do, I get the following warning message:
编写一个例行的 WinForms 应用程序,其中引用了我自己编写的一些自定义库。我正在构建一个依赖于另一个库的特定库,当我这样做时,我收到以下警告消息:
"Could not load file or assembly 'RHLib' Version 1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified"
“无法加载文件或程序集 'RHLib' 版本 1.0.0.0,Culture=neutral,PublicKeyToken=null' 或其依赖项之一。系统找不到指定的文件”
The application functions, there are no error messages, but I am one of those that likes a completely clean compile - no errors, no warnings. And I cannot figure this one out.
应用程序功能,没有错误消息,但我是喜欢完全干净编译的人之一 - 没有错误,没有警告。我无法弄清楚这一点。
The library in question has a reference to the "missing" library, the "missing" library is compiled and lives in the Debug directory when VS finishes compiling, the build order places the "missing" library as the first item built and the "missing" library has no dependencies - its a small library built to get me out of a circular assembly problem.
有问题的库引用了“缺失”库,当 VS 完成编译时,“缺失”库被编译并位于 Debug 目录中,构建顺序将“缺失”库作为构建的第一项,“缺失” " 库没有依赖关系——它是一个小库,旨在让我摆脱循环装配问题。
Any ideas?
有任何想法吗?
采纳答案by Bruce
Even though the warning was coming from the library that used the "missing" library, adding a reference to the application which called the library which called the "missing" library removed the warning.
即使警告来自使用“丢失”库的库,添加对调用“丢失”库的应用程序的引用删除了警告。
Explanation:The original assembly (we'll call it AS0) called another assembly (we'll call this one AS1). AS1 was in the reference list of AS0, however, AS1 called still another assembly (we'll call it AS2) and, of course, AS2 is in the reference list of AS1 but NOT in the reference list of AS0. To solve the problem, I added AS2 to the reference list of AS0. That did the trick.
说明:原始程序集(我们称之为 AS0)调用了另一个程序集(我们称之为 AS1)。AS1 在 AS0 的引用列表中,但是,AS1 调用了另一个程序集(我们将其称为 AS2),当然,AS2 在 AS1 的引用列表中,但不在 AS0 的引用列表中。为了解决这个问题,我在AS0的引用列表中加入了AS2。这就是诀窍。
回答by lod3n
Did you right click on the project, and click Add Reference, and then add using RHLib;to the top of the file?
是不是在项目上右键,点击添加引用,然后使用RHLib添加;到文件的顶部?
回答by Jay
Edit the web.config file to remove the reference, which is not required for normal operation:
编辑 web.config 文件删除引用,正常操作不需要:
1 - Open the web.config file in the root of your site
1 - 打开网站根目录中的 web.config 文件
2 - Find the following line and comment it out():
2 - 找到以下行并将其注释掉():
<add assembly="xxxxx", Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
3 - Save and close the web.config file and try again
3 - 保存并关闭 web.config 文件,然后重试
参考链接:http: //manual.aspdotnetstorefront.com/p-1118-could-not-load-file-or-assembly-microsoftwebservices3-version3000-cultureneutral-publickeytoken31bf3856ad364e35.aspx