VB.NET:不存在歧义时出现歧义类名错误
我们的一位客户报告说,当尝试在 VB.NET 中使用我们的 .NET .DLL 时,他们收到错误:
错误 BC31429:“OurClass”不明确,因为命名空间“our.company.nspace”中存在多种具有此名称的成员
我还能够使用包含单行的虚拟项目重现错误,
Dim x as our.company.nspace.OurClass
通常这是因为有有几种类型,名称仅大小写不同。但在这种情况下,就不存在这样的歧义了。 OurClass
不仅在特定命名空间中,而且在整个程序集以及项目引用的任何其他程序集中都是唯一的名称。反射器也显示了这一点。也没有同名的类成员,这也经过 Reflector 验证。
还有一个奇怪的事情是,在我创建虚拟项目后,错误并没有立即出现,然后它突然出现,现在它不再消失了。事实上,在两次重新编译之间我什至没有改变任何东西,第一次编译可以工作,而第二次则不能。
那么...给出了什么?
(注意:.DLL 使用并引用 vjslib (J#),如果有任何相关性的话)
A client of ours reported that when trying to use our .NET .DLL in VB.NET they receive the error:
error BC31429: 'OurClass' is ambiguous because multiple kinds of members with this name exist in namespace 'our.company.nspace'
I've also been able to reproduce the error with a dummy project containing the single line of
Dim x as our.company.nspace.OurClass
Normally this is because there are several types with names differing only in case. But in this case there is no such ambiguity. OurClass
is a unique name not only in the specific namespace but in the whole assembly and any other assemblies referenced by the project. Reflector also shows this. There are also no class members with the same name, also verified by Reflector.
Also a weird thing is that the error wasn't there immediately after I created the dummy project, and then it suddenly appeared and now it doens't go away anymore. In fact I didn't even change anything between the two recompiles from which the first one worked, and the second didn't.
So... what gives?
(Note: the .DLL uses and references vjslib (J#), if that is of any relevance)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否尝试过使用 Global.前缀?例如,请
参阅 http://msdn.microsoft.com/en -us/library/k701czy1(VS.90).aspx
Have you tried using the Global. prefix? e.g.
See http://msdn.microsoft.com/en-us/library/k701czy1(VS.90).aspx
发现问题了。有两个类的名称重复,一个小写(标记为“过时”),一个大写,但都保留在代码中。显然不符合 CLS,并且会破坏不区分大小写的 VB.Net。
生成并生成
generateAsync 和GenerateAsync
今天的解决方案是从GitHub 下载,删除小写违规者,重新编译并手动添加到项目中,至少直到在其末端发布更新的修复程序。
Found the issue. There are two classes with duplicate names one lowercase (marked as "obsolete") and one uppercase but both left in the code. Not CLS compliant obviously and blows up VB.Net which is not case sensitive.
generate and Generate
generateAsync and GenerateAsync
Solution for today is to download from GitHub, remove the lowercase offenders, recompile and manually add to project at least until an updated fix is posted on their end.
我之前在部署网络应用程序时遇到过这个问题。我在开发环境中没有收到错误,但是当我尝试将其部署到测试服务器时,出现了不明确的命名空间错误。我必须从
bin
文件夹中删除所有 DLL,然后重新部署应用程序。听起来这可能是一个参考问题。也许客户只需要删除并重新添加对 DLL 的引用,然后对其解决方案进行重建?
I've had this issue when deploying a web app before. I wasn't getting the error in my development environment, but when I tried to deploy it to a test server I got the ambiguous namespace error. I had to delete all of the DLLs from the
bin
folder and then redeploy the application.It sounds like it could be a reference issue. Perhaps the client just needs to remove and re-add the reference to your DLL and then do a Rebuild on their solution?