3

I have a VB.Net Windows form application. I have added a C# class library to the solution that has VB.Net Windows form application. I compiled C# class library and have added reference to VB.Net windows form application. However when I am trying to add namespace of C# class library it just doesn't show up in the intellisense. Hence I was unable to access C# class and it's functions as well. Someone please tell me a fix for this. Thank you

5
  • What are the .NET framework versions of each project? Commented Sep 26, 2018 at 16:22
  • Find the reference in the solution explorer (make sure there is no yellow exclamation). Right click, View In Object Browser. Expand it, and see what namespace is there, if any. Commented Sep 26, 2018 at 16:23
  • It would've helped if you could give us a link where to download this project so that we can try it ourselves. I found a project using the namespace ScreenToPDF on CodeProject, but it was a WinForms project and not a class library (DLL). Commented Sep 26, 2018 at 21:05
  • I tried converting the CodeProject project (.NET 2.0) into a class library and referencing it in a VB.NET WinForms application (.NET 4.0). It worked without a problem. As others already have mentioned, make sure to check the Framework version of the other project and try setting it to the same as your project (if it isn't already). Commented Sep 26, 2018 at 21:08
  • Try building the solution, and pay very close attention to the error or warning messages that issue. In general, if there is a problem, the build system will issue a message about it, but sometimes it won't be clear (until you fix it) that a particular message was the root of the problem. Commented Sep 27, 2018 at 13:46

1 Answer 1

5

Assuming the dll in question is CLS compliant and compiled against the same runtime version, you should be able to use it without a problem.

If either (or both) of these conditions are not met, you will not be able to use the imported DLL.

Make sure the Import directive uses the namespace as defined in the assembly metadata - look at your C# project properties to see what the default namespace is, that's what you need to import.

Sign up to request clarification or add additional context in comments.

10 Comments

Hi, Thank you for your reply. The C# class library Default Namespace as it is shown in it's properties is "ScreenToPDF". This is the same namespace I tried to use in Imports of VB.Net windows form application. But it just doesn't show up in the intellisense.
@sam Do you add dll reference??
Yes, I did add dll reference. Still it is not showing up in namespace.
@sam So you have to rewrite your namespace and using that. Or write the method or class name of C# dll in the method or class of vb, after that the compiler suggest you to import the c# dll
@sam like this: using testdll.test
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.