Avatar of josgood
josgoodFlag for United States of America

asked on 

C# Project Reference Unmanaged C++ .LIB

I have an unmanaged C++ .LIB, built by VS2003.  I would like to add a reference to it in my VS2005 C# project.  I can't, of course.

I have full source and both development environments.

I could build the library with managed C++.  I could write a project that builds a DLL instead of the .LIB.  The field is wide open.

What is the best way to add this .LIB's functionality to my C# project?
C#C++

Avatar of undefined
Last Comment
josgood
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of josgood
josgood
Flag of United States of America image

ASKER

jaime, thank you.  These are good references.  Each expects to be working with a .DLL, not a .LIB.  At least, that's how I read them.

Since I have an unmanaged .LIB, not .DLL, it seems to me that my choices are
1)  Write an unmanaged C++ project that creates an unmanaged .DLL, either directly from the sources or by linking with the .LIB, or
2)  Write a managed C++ project that builds the sources, resulting in a class library.

I'd like to avoid making any source changes, to simplify acceptance by QA.  I don't know that I'd encounter any of the managed/unmanaged differences in building  these sources with managed C++, but I don't know that I won't, either.

For simplicity, it seems best to build an unmanaged DLL with a project that simply links in the .LIB.  I'm comfortable with using PInvoke in C#.

Would you agree with me, or do you have a different view?  Am I missing something?
you cannot use a .lib directly into your .net project, you have to build a dll so you can use interop marshalling.
 
Avatar of josgood
josgood
Flag of United States of America image

ASKER

Thank you, jaime.  I have it working now.

Joe
C#
C#

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

98K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo