xezno
xezno

Reputation: 77

How can I integrate C# libraries into Visual Basic?

There are some libraries written in C# that I would like to use in Visual Basic, but I can't find any tutorials or anything giving me any clues as to how it is done. I have compiled (I think) the library, but I have looked everywhere (including the project properties) for a solution with no success.

Upvotes: 1

Views: 1301

Answers (3)

Ant P
Ant P

Reputation: 25221

If you have compiled your C# code into a DLL, you should be able to reference it in a VB.NET project as you would any other DLL. Include your DLL somewhere in your project's folder structure (typically in a "lib" folder), then do the following:

  • Open your C# project in Visual Studio.
  • Right click on "References" in the Solution Explorer and click on "Add Reference."
  • Select the "Browse" tab, then browse to - and select - the desired DLL.

For more information on adding and removing references, visit this article.

Upvotes: 3

Ehryk
Ehryk

Reputation: 1990

If they are in the same solution, just "Add Reference" and select the C# project. If not, compile them into a .dll and "Add Reference" -> select the path to it.

You should then be able to 'Include' / 'Import' methods, classes and objects from the C# projects / libraries.

Add Reference Dialog

Upvotes: 3

Adarsh Shah
Adarsh Shah

Reputation: 6775

You can just add it to your VB.Net project as reference and then use it. Once code is compiled (VB.Net or c#) its in IL(intermediate language) so there is no difference. Look at the example I gave in the answer of following question. I have done exactly what you are asking for.

Can C# compiler compile a VB.Net code?

You can find out how to add reference by going to below URL:

http://msdn.microsoft.com/en-us/library/7314433t(v=vs.90).aspx

Upvotes: 1

Related Questions