简体   繁体   English

将VB.NET DLL导入C#.Net Project

[英]Import VB.NET DLL into C#.Net Project

I am trying to get a VB.NET DLL used as a reference on a aspx.cs page. 我试图在aspx.cs页面上获得一个用作参考的VB.NET DLL。

I have added the compiled DLL and it's resources to a bin folder, and I have added the reference and added 我已将已编译的DLL及其资源添加到bin文件夹中,并添加了引用并添加

using my_DLL;

Then I go to call a function like this.... 然后我去调用这样的函数....

public string foobar = concat_function_DLL("foo" , "bar"); 

but, I get the red sqwiggles under concat_function_DLL (my DLL function) and this message : 但是,我得到concat_function_DLL(我的DLL函数)下的红色sqwiggles和这条消息:

"The name 'concat_function_DLL' does not exist in the current context

I have tried removing the bin folder, removing the reference, re-creating the bin folder and then re-adding the reference, but it still doesn't want to recognize anything from my DLL. 我已经尝试删除bin文件夹,删除引用,重新创建bin文件夹,然后重新添加引用,但它仍然不想从我的DLL中识别任何内容。

The DLL will work completely fine from my VB.Net webpage so I know it cannot be a problem with the DLL. DLL将在我的VB.Net网页上完全正常工作,所以我知道它不是DLL的问题。 Maybe there is some step I am missing? 也许我缺少一些步骤? I thought I read that .NET DLLs are interchangeable between both vb.net and c#.net. 我以为我读过.NET DLL在vb.net和c#.net之间可以互换。

Thank you! 谢谢!

public string foobar = concat_function_DLL("foo" , "bar"); public string foobar = concat_function_DLL(“foo”,“bar”);

You are calling a method, concat_function_DLL , but you aren't specifying the type that declares it. 您正在调用方法concat_function_DLL ,但您没有指定声明它的类型。

C# won't automatically put "global" methods from VB.NET modules in scope. C#不会自动从VB.NET模块中放入“全局”方法。 Use this: 用这个:

public string foobar = YourModuleName.concat_function_DLL("foo" , "bar"); 

Or, if you are using C# 6 (Visual Studio 2015), then you can use the VB.NET module and use it as you were before. 或者,如果您使用的是C#6(Visual Studio 2015),那么您可以使用VB.NET模块并像以前一样使用它。 Add this using statement: 使用以下语句添加:

using static my_DLL.YourModuleName;

Then you can just use the method as you were previously. 然后你可以像以前一样使用这个方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM