VB.NET project refrence C++ DLL

When I try to reference a C++ DLL from a VB.NET Project I get this error message.  

"A reference to '..... dll' could not be added.  This is not a valid assembly or COM Component.  Only assemblies with extension 'dll' and COM components can be referenced.  Please make sure that the file is accessible, and that it is a valid assembly of COM component."

I know the dll works because it is currently working in a VB.60 Project.  Any Ideas yet?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
You have to use p/invoke or a Declare Function/Sub for non-COM DLL's:


<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function LockWindowUpdate(ByVal hWndLock As IntPtr) As Int32
End Function


Private Declare Function LockWindowUpdate Lib "user32" (ByVal handle As IntPtr) As Int32


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ignacio Soler GarciaSolution Architech & Technical LeadCommented:
What I use to do in that situations is to create a VB6 DLL Wrapper to be used into VB.NET. That makes life much more simple.

At VB6 create a project that access the functions you need in the C++ DLL. The VB6 functions have to be dessigned with byref parameters and always with simple types (Int, String, etc). Then your VB.NET app talks only with the VB6 DLL without any trouble related to unmanaged code and so on ...

I've used this approach on several projects with success.

Hope it helps!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.