开发者

Dll reference of one project into another project

开发者 https://www.devze.com 2023-03-01 01:59 出处:网络
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 referenc

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 missi开发者_运维技巧ng 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 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 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.
0

精彩评论

暂无评论...
验证码 换一张
取 消