[英]Referenced VB.Net DLL not importing as expected to C# project
I've been using VB.Net for the last couple of years and am now switching over to C#. 在过去的两年中,我一直在使用VB.Net,现在正在切换到C#。 I have a few DLLs of projects which have been written in VB.Net that I'd like to import to my new C# solution. 我有一些用VB.Net编写的项目DLL,我想导入到我的新C#解决方案中。 I've referenced the DLLs but when I import with the 'using' keyword some features don't work as expected. 我已经引用了DLL,但是当我使用'using'关键字导入时,某些功能无法按预期工作。 I can use functions as I normally would but extension methods are not recognised. 我可以像往常一样使用函数,但是无法识别扩展方法。
I have read that in C# you can only import namespaces whereas in VB.Net you can import classes so I wonder if this is the issue as the VB.Net code is not namespaced. 我已经读过C#中只能导入名称空间,而在VB.Net中可以导入类,所以我想知道这是否是问题,因为VB.Net代码未命名空间。
Is there any way around this without having to go through and namespace the VB.Net class library (not really viable currently). 有什么办法可以解决这个问题,而不必遍历VB.Net类库(并没有真正可行的名称空间)。
EDIT: My extensions methods are in a VB.Net Public Module. 编辑:我的扩展方法在VB.Net公共模块中。
Thanks, Andy 谢谢,安迪
Public
. 确保您的VB 模块是Public
。 using
. 引用VB类库的命名空间( 有一个连你都没有手动设置)从的C#代码模块using
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.