1

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.

3
  • In your project, add the library (project or binary) as a reference. The former is preferred, as it will allow you to debug the library code. Commented Dec 29, 2013 at 21:51
  • I think adding the dlls will be enough. Commented Dec 29, 2013 at 21:51
  • How do I add the dll files? Commented Dec 29, 2013 at 21:51

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

1

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

1 Comment

If you are looking on how to add reference you can go to the msdn link I provided but if you want to understand how c# and vb.net compiler works go to the first (SO) link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.