问题
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 i.e. "using myData;" and its giving me an error of "Type or namespace name could not be found"
Am I missing something??
回答1:
A clue about how your VB.NET project is organized. There are soem things that can go wrong and you obviouisly 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 i.e. "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 us whether "myData.dll" actually contains the namespce "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 cuold be VB.NET has wrapped another namesapce 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 Btrowser (Visual Studio Menu, "View", "ObjectBrowser") and look waht 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 abuot the classes and / or the namespace.
来源:https://stackoverflow.com/questions/5779206/dll-reference-of-one-project-into-another-project