简体   繁体   中英

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.

I have added the compiled DLL and it's resources to a bin folder, and I have added the reference and added

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 :

"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.

The DLL will work completely fine from my VB.Net webpage so I know it cannot be a problem with the 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.

Thank you!

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.

C# won't automatically put "global" methods from VB.NET modules in scope. 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. Add this using statement:

using static my_DLL.YourModuleName;

Then you can just use the method as you were previously.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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