vb.net Visual Studio 找不到引用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17468422/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 14:09:11  来源:igfitidea点击:

Visual Studio won't find references

vb.netvisual-studiodllreference

提问by Zed_Blade

I'm working with some application handed over by another person in which I must document the requirements, build and deploy processes.

我正在处理由另一个人移交的一些应用程序,我必须在其中记录需求、构建和部署过程。

The problem here is that Visual Studio (2005) is throwing a lot of errors since it can't find the references for the dlls. This obviously won't let VS build the project.

这里的问题是 Visual Studio (2005) 抛出了很多错误,因为它找不到 dll 的引用。这显然不会让 VS 构建项目。

Everything works fine on the persons computer but not on mine, even though the project references the same folder where the dlls are, the bin folder.

在个人计算机上一切正常,但在我的计算机上却没有,即使该项目引用了 dll 所在的同一文件夹,即 bin 文件夹。

How can I circumvent these problems and get VS to properly reference the dlls?

如何规避这些问题并让 VS 正确引用 dll?

The following printscreen shows the references screen for the project.

以下打印屏幕显示了项目的参考屏幕。

enter image description here

在此处输入图片说明

回答by Siebe Bosch

My guess is that your DLL uses a more recent .NET framework than your application does.

我的猜测是您的 DLL 使用比您的应用程序更新的 .NET 框架。

Check the properties for your DLL source (right-click on the DLL code in the solution explorer and choose Properties). Go to Application - Target .NET framework and compare the version to the one the application itself uses (right-click on the project code). Note: under your application properties check both the settings under Application - Target .NET framework AND under Publish - Prerequisites.

检查 DLL 源的属性(右键单击解决方案资源管理器中的 DLL 代码并选择属性)。转到应用程序 - 目标 .NET 框架并将版本与应用程序本身使用的版本进行比较(右键单击项目代码)。注意:在您的应用程序属性下,检查应用程序 - 目标 .NET 框架和发布 - 先决条件下的设置。

回答by Vince Pike

For what it's worth, even after changing the .vbproj file and removing many lines about hard coded values, I eventually checked out the project again removed all references to the given DLL and then added it using the GUI.

对于它的价值,即使在更改了 .vbproj 文件并删除了许多关于硬编码值的行之后, 我最终还是再次检查了该项目,删除了对给定 DLL 的所有引用,然后使用 GUI 添加了它。

Lesson learned, don't try to change out one DLL for a newer version without using VB2005 GUI. The easiest solution will probably be to transfer everything to another project. It will be incredibly time consuming to find where visual studio has left the hard coded path at.

吸取的教训,不要尝试在不使用 VB2005 GUI 的情况下为更新版本更改一个 DLL。最简单的解决方案可能是将所有内容转移到另一个项目。找到 Visual Studio 离开硬编码路径的位置将非常耗时。

WOOT!!!! Compile the DLL file to a lower version of the .NET framework, and it will fix the problem!!!!

哇!!!!把DLL文件编译到.NET框架的低版本,问题就解决了!!!!

回答by David Osborne

The paths in the project file cannot be the same or the assemblies referenced have a different version.

项目文件中的路径不能相同或引用的程序集版本不同。

It might be worth unloading your project and the editing it to inspect where it's looking and for what version.

卸载您的项目并对其进行编辑以检查它正在查找的位置和版本可能是值得的。

回答by Peter

I had the same problem with an older Visual Studio Project that I opened in Visual Studio 2008. I tried to add new references to the project and got permanent errors that the dll's cannot be found. After the migration of the Project to Visual Studio 2010 I got the following error message when I tried to add a new reference:

我在 Visual Studio 2008 中打开的旧 Visual Studio 项目遇到了同样的问题。我尝试向该项目添加新引用,但遇到了无法找到 dll 的永久性错误。将项目迁移到 Visual Studio 2010 后,当我尝试添加新引用时收到以下错误消息:

'mySample.dll' or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project. You can change ...

“mySample.dll”或其依赖项之一需要比项目中指定的版本更高的 .NET Framework 版本。你可以改变 ...

After changing the projects .NET Framework to a newer version everything works fine.

将项目 .NET Framework 更改为更新版本后,一切正常。

回答by DdW

Good suggestions in other answers. In my case, it was because the libraries weren't copied (downloaded) successfully: the files existed, but were 0 kB.

其他答案中的好建议。就我而言,这是因为库没有成功复制(下载):文件存在,但为 0 kB。

回答by SuperRoo

Did a clean, which removed all the DLL's and then VS2008 complained it couldn't find the references (Duh!!!) and wouldn't rebuild....luckily I had and old version of the dll's and replaced them in the directory AND THENdid a rebuild to replace them...all references are now OK and we're back to normal....good old VS 2008

做了一个清理,删除了所有的 DLL,然后 VS2008 抱怨它找不到引用(Duh !!!)并且不会重建......幸运的是我有旧版本的 dll 并在目录中替换它们然后进行了重建以替换它们...所有参考现在都正常,我们恢复正常....旧的 VS 2008