简体   繁体   中英

Dll reference of one project into another project

I have 2 projects, one built in VB.NET and another in C#.NET. I want to use certain functionality of VB.NET into C#.NET and hence I have added the dll file of VB.NET solution into C#.NET as a reference by browsing the dll from my system.

Say dll name for VB.NET is myData.dll

In my C#.NET project I am trying to declare it as a namespace ie "using myData;" and its giving me an error of "Type or namespace name could not be found"

Am I missing something??

A clue about how your VB.NET project is organized. There are some things that can go wrong and you obviously are not aware of them, so lets find out.

According to our information the dll is added as reference.

Say dll name for VB.NET is myData.dll

Ok, so that is the DLL and you reference it.

declare it as a namespace ie using myData;

No, you do NOT declare "it as a namespace". You tell the compiler to also look in this namespace for classes. Now, you do NOT tell to compiler whether myData.dll actually contains the namespace myData . This is a totally different thing. You can do without using - if you prefix every class. Nothing in the using statement references a dll.

It could be VB.NET has wrapped another namespace around and it is myData.myData . No joke. It could also be you forgot to make the classes public.

To find out:

  • Open the DLL using Object Browser ("View", "ObjectBrowser") and look what namespace and classes are in the DLL.
  • Go and look for the class you want to use and see what it says there. You may be surprised about the classes and / or the namespace.

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