Dll reference of one project into another project

时间秒杀一切 提交于 2019-12-23 15:59:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!