How to reference .h files and .lib files in VB.Net project

J Trahair

Well-known member
May 14, 2008
Programming Experience
Hi everyone.

I need to reference some header and lib files (from a component SDK), and the project is entirely VB.Net based using Visual Studio 2005 Professional.

Is it possible to add in a VC# (or VC++) section into the project which will be able to reference these items for use in the rest of the project?

[The project is for installation into a Windows CE5.0 device to enable it to successfully connect to a Bluetooth printer using Atinav.]

Thank you.


VB.NET Forum Moderator
Staff member
Aug 17, 2004
Sydney, Australia
Programming Experience
VB and C# have no knowledge of C/C++ header files. C++.NET may but I can't say as I've never used it.

.NET apps can interact with unmanaged code in two ways:

1. COM Interop
2. Platform Invoke

COM Interop allows you to reference a COM component as though it was a .NET assembly. The system will generate a proxy Interop assembly. Your app deals with the Interop assembly and the Interop assembly deals with the COM component.

If you don't have a COM component to reference then you can't use that option. You'll need to use PInvoke. In that case, you write a proxy method with a signature that is compatible with the unmanaged function. The function body is left empty and you apply the DllImport attribute to tell the system where the real function is and how to call it. As long as the original library is in the same folder as the app or in the system folder it will work.

I'm no mobile developer so I'm not sure if there are any specific differences. You can look up PInvoke for more info.
Top Bottom