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.
-
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.chue x– chue x2013-12-29 21:51:14 +00:00Commented Dec 29, 2013 at 21:51
-
I think adding the dlls will be enough.AbhinavRanjan– AbhinavRanjan2013-12-29 21:51:27 +00:00Commented Dec 29, 2013 at 21:51
-
How do I add the dll files?xezno– xezno2013-12-29 21:51:57 +00:00Commented Dec 29, 2013 at 21:51
3 Answers
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
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
