新 pc 在 VB.NET 中导致“导入中指定类型的命名空间不包含任何公共成员”

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

New pc causing "namespace of type specified in the imports doesn't contain any public member" in VB.NET

vb.netnamespacespublicmemberimport

提问by jtaylor___

I just got a new PC (Win 7) with VS 2010 (same version as my old PC). I got a VB.NET solution from source control that contains two projects. One of the projects builds fine. The other project flags every non-MS Imports statement with:

我刚买了一台装有 VS 2010 的新 PC(Win 7)(与我的旧 PC 版本相同)。我从包含两个项目的源代码管理中获得了一个 VB.NET 解决方案。其中一个项目构建良好。另一个项目将每个非 MS 导入语句标记为:

Namespace or type specified in the Imports &1 doesn't contain any public members or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

Imports &1 中指定的命名空间或类型不包含任何公共成员或无法找到。确保命名空间或类型已定义并且至少包含一个公共成员。确保导入的元素名称不使用任何别名。

The ironic thing is that the working project within the same solution references all the same DLL's. I've removed and re-added the DLL's so I know they're there, and I can expand them in Object Browser, so I know they contain public methods.

具有讽刺意味的是,同一解决方案中的工作项目引用了所有相同的 DLL。我已经删除并重新添加了 DLL,所以我知道它们在那里,我可以在对象浏览器中扩展它们,所以我知道它们包含公共方法。

I've ran out of ideas of things to try. Can someone throw me a bone, plz?

我已经没有什么可以尝试的想法了。有人可以扔给我一根骨头吗?

回答by Tim Goodwin

I had the same problem which I fixed by changing the Project Properties->Compile->Advanced Compile Options->Target Framework value from .Net Framework 4.0 Client Profile to .Net Framework 4.0

我遇到了同样的问题,我通过将项目属性->编译->高级编译选项->目标框架值从 .Net Framework 4.0 Client Profile 更改为 .Net Framework 4.0

回答by Bo Flexson

I had this happen. For me, the new DLL was targeting Dot Net 4.5, while the project which referenced it was only targeting 4.0. Switching the new dll to match fixed the issue.

我遇到过这种情况。对我来说,新 DLL 的目标是 Dot Net 4.5,而引用它的项目只针对 4.0。切换新的 dll 以匹配修复了该问题。

回答by Jeff Beese

I've had a similar issue as this before. In my case the problem was that the dll's were located on a network share drive (which in my system showed as q:) so when I referenced them the file path was q:\folder structure\file.dll. Upon switching machines, my system no longer referenced that share drive as q:\ but by another drive letter, causing my program to error out similarly.

我以前也遇到过类似的问题。就我而言,问题是 dll 位于网络共享驱动器上(在我的系统中显示为 q:),因此当我引用它们时,文件路径为 q:\folder structure\file.dll。在切换机器时,我的系统不再将该共享驱动器引用为 q:\ 而是引用另一个驱动器号,导致我的程序类似地出错。

In my case, I was able to correct this issue and prevent it from happening again by changing the way I referenced the dll from the drive letter it was assigned by my local system to the network path (\SERVER NAME\Drive Letter\file path\file.dll).

就我而言,我能够通过更改我从本地系统分配的驱动器号到网络路径(\SERVER NAME\Drive Letter\file path \file.dll)。

回答by LBW

I was experiencing the same issue. The DLL I was referencing was built in framework 3.5. The project I was referencing the DLL was being built in 2.0. I switched the referring project to 3.5 and it built perfectly.

我遇到了同样的问题。我引用的 DLL 是在框架 3.5 中构建的。我引用 DLL 的项目是在 2.0 中构建的。我将参考项目切换到 3.5 并且它完美构建。

回答by Set

I had this problem with projects which were referencing the same version of the framework. I solved it with the following steps.

我在引用相同版本框架的项目中遇到了这个问题。我通过以下步骤解决了它。

  1. Remove reference to DLL
  2. Clean and ReBuild DLL
  3. Clean and ReBuild Project
  4. ReAdd Reference.
  1. 删除对 DLL 的引用
  2. 清理并重建 DLL
  3. 清理和重建项目
  4. 重新添加参考。