C# Visual Studio 找不到我引用的 DLL 的命名空间

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

Visual studio cannot find my referenced DLL's namespace

c#dllnamespaces

提问by Lee

This is a very frustrating problem. All of a sudden I cannot use referenced DLLs. I added an assembly reference to a project in the same solution and the namespace is unrecognised. I can even see the reference in the object viewer. I've also changed the projects to .NET 4 and 3.5 without the client profile to no avail.

这是一个非常令人沮丧的问题。突然间我无法使用引用的 DLL。我在同一解决方案中添加了对项目的程序集引用,但无法识别命名空间。我什至可以在对象查看器中看到引用。我还在没有客户端配置文件的情况下将项目更改为 .NET 4 和 3.5,但无济于事。

回答by Steve Danner

Based on your screenshot, you have references to the same "ServerLibrary" DLL in multiple projects, however, it looks like one referenced version is compiled in .NET 3.5 and the other referenced version (the project reference it appears), is compiled in .NET 4. Make sure all projects point to the same version of the DLL and recompile all. That should fix your problem.

根据您的屏幕截图,您在多个项目中引用了同一个“ServerLibrary”DLL,但是,看起来一个引用版本是在 .NET 3.5 中编译的,而另一个引用版本(它出现的项目引用)是在 .NET 中编译的。 NET 4. 确保所有项目都指向相同版本的 DLL 并重新编译所有项目。那应该可以解决您的问题。

回答by Muhammad Sohail

I faced this problem, and I solved it by closing visual studio, reopening visual studio, cleaning and rebuilding the solution. This worked for me. On some other posts, I have read the replies and most of users solved the problem by following this way.

我遇到了这个问题,我通过关闭visual studio,重新打开visual studio,清理和重建解决方案来解决它。这对我有用。在其他一些帖子上,我已经阅读了回复,大多数用户都按照这种方式解决了问题。

回答by Dana Sherman

I removed DLL name and namespace from the path where I was using it. And for some wierd reason it worked.

我从使用它的路径中删除了 DLL 名称和命名空间。出于某种奇怪的原因,它奏效了。

回答by nzrytmn

This is mostly cause becauese of using diffrent version of same packages at diffrent projects at same solution. I recommend to update all packages to lastest version at all projects.

这主要是因为在相同解决方案的不同项目中使用相同包的不同版本。我建议在所有项目中将所有包更新到最新版本。

Right click to project that has downgrade packages --> manage nuget packages --> click the updates tab --> check the 'select all packages' checkbox --> click the update

右键单击具有降级包的项目 --> 管理 nuget 包 --> 单击更新选项卡 --> 选中“选择所有包”复选框 --> 单击更新

Do this for all prjects at solution.

对解决方案中的所有项目执行此操作。