vb.net编译错误'abc'在命名空间“xyz”中不明确;

发布于 2024-08-17 04:51:42 字数 541 浏览 2 评论 0原文

我有另一个开发人员创建的 VB.Net 解决方案,我试图在我们的构建机器上编译它(它在他们的机器上编译),但在其中一个项目中,我收到一条错误消息,内容如下:

Imyinterface 在命名空间 anamespaceassemble 中不明确。

我尝试过但没有成功:

  • 检查引用以查看是否
  • 删除了任何明显的错误,并重新添加了有问题的程序集
  • 在系统中搜索相同的 dll
  • 尝试编译原始 deve 的 src (.v 源代码控制版本)
  • 使用 ildasm.exe 检查程序集

我通常用 C# 编写代码,之前没有见过此错误(至少以这种形式),不是它是 VB.Net 特定的,但添加/查看引用的 UI 略有不同,所以我认为 VB.Net 可能会对引用做一些不同的事情。

我也尝试在另一台机器上编译,编译没问题。所以我认为这是构建机器的问题,但我不确定是什么。项目未引用其他冲突的程序集,这可能吗?

有什么想法吗?

I have a VB.Net solution that another developer created and I'm trying to compile it on our build machine (it compiles on their machine) but with one of the projects I get an error saying something along the lines of:

Imyinterface is ambiguous in the namespace anamespaceassembly.

I have tried with no success:

  • examined the references to see any obvious errors
  • removed and re-added the assembly in question
  • searched the system for the same dll
  • attempted to compile the original deve's src (.v the source control version)
  • examined the assembly with ildasm.exe

I usually code in C# and have not seen this error before (in this form at least), not that it is VB.Net specific but the UI for adding/viewing references is slightly different so I thought maybe VB.Net might do something different with references.

I also tried to compile on another machine, and it compiles ok. So I assume it is something with the build machine but I'm not sure what. Other conflicting assemblies somehow not referenced by the project, is that possible??

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我偏爱纯白色 2024-08-24 04:51:43

如果您有同一引用的两个版本(例如 Microsoft.ReportViewer.Webforms 版本 10.0.0.0 和 Microsoft.ReportViewer.Webforms 8.0.0.0),请检查您的引用,您将收到此错误。删除最旧的,你应该就好了。我一直对自己这样做。

Check your references if you have two versions of the same reference (eg. Microsoft.ReportViewer.Webforms version 10.0.0.0 and Microsoft.ReportViewer.Webforms 8.0.0.0) You will get this error. Delete the oldest and you should be good. I do this to myself all of the time.

仄言 2024-08-24 04:51:43

导致此错误的原因可能有多种。在 VB 中,您应该意识到,在没有类规范的情况下,可以使用比 C# 中习惯的更多名称。另外,在 VB 中大小写并不重要,这可以进一步比喻碰撞的可能性。

即使您没有找到实际的冲突问题,您也可以像在 C# 中一样解决此问题:在 Imports 语句中重命名它:

Imports IM = yourAssembly.Imyinterface

然后更改代码,以便使用Imyinterface 替换为 IM

注意:如果错误没有指向特定行,则冲突可能超出您的控制范围。通常,完整的清理解决方案和重建会有很大帮助,但有时,行为不当的文件(即另一个错误)会导致在没有明确来源的情况下首先弹出此错误。尝试将最近的更改回滚到它起作用的地方。

你还说它在另一台机器上工作。您的计算机可能装有不同版本的 MS Visual Studio 或 .NET。检查并比较确切的版本。

There can be a few causes for this error. In VB, you should be aware that more names then you're used to from C# are available without class specification. Also, case does not matter in VB, which can further liken the chances on collisions.

Even in the event that you don't find the actual conflicting issue, you can resolve this in the same way you would in C#: rename it in the Imports statement:

Imports IM = yourAssembly.Imyinterface

Then change the code such that uses of Imyinterface are replace with IM.

NOTE: If the error does not point to a particular line, the conflict may be out of your hand. Normally, a full Clean Solution and Rebuild helps a lot, but occasionally a misbehaving file (i.e., another error) causes this error to popup first without clear source. Try to rollback recent changes to the place where it did work.

You also say it worked on another machine. Chances are that your machine is having a different version of MS Visual Studio or .NET. Check and compare the exact versions.

递刀给你 2024-08-24 04:51:43

我面临着同样的问题。我将应用程序从 vb6 升级到 vb.net,当我将构建配置从 DEBUG 更改为 RELEASE 时,我收到了模糊错误。
我在解决方案资源管理器中发现了重复的引用文件夹。我删除了那些重复的引用并成功构建。我希望它可以帮助其他人。

I was facing same issue. I upgraded my application from vb6 to vb.net and when i change the build configuration from DEBUG to RELEASE then i got AMBIGUOUS errors.
I found dulicate references folder in solution Explorer. I removed those duplicate referecnces and Build sucessfully. I Hope it may help others.

转身以后 2024-08-24 04:51:43

感谢您的回复!我尝试了每一个,但仍然遇到问题。

我在最初的问题中遗漏的一点信息是 VB.net 项目是 VB6 项目的升级。当时我认为这无关紧要。

经过进一步调查后,构建机器也被用来构建 VB6 项目。所以我在 vb6 dll 上运行“reg32 /u”,这似乎解决了 VB.net 问题。

不完全确定为什么会修复它,因为我没有引用 VB6 dll,我猜测与注册表中混淆 vb.net 项目的不明确条目有关。

Thanks for the responses! I tried each but still was having issues.

One point of info I left out of the original question was that the VB.net projects are upgrades from VB6 projects. At the time I did not think that was relevant.

After investigating further the build machine was used to build the VB6 projects also. So I ran 'reg32 /u' on the vb6 dlls and that seemed to fix the VB.net issue.

Not exactly sure why this fixed it since I was not referencing the VB6 dlls, I'm guessing something to do with ambiguous entries in the registry confusing the vb.net project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文