Use *.lib as reference

  • Thread starter Thread starter RF
  • Start date Start date
R

RF

Hi All,

How can I use the *.lib as a reference in a C# solution. Whenever I try to
add a "lib" file, VS throws an error explaining it must have a dll
extension?

Can anyone help?

Thankx,

RF
 
No, only .Net assemblies (DLL's) and COM DLLs can be referenced in a C#
project.

I think the only thing you could do here is to write a managed C++ class
libary wrapper around the .lib file and then reference the managed C++
assembly.

Adam Clauss
(e-mail address removed)
 
Hi RF,

RF said:
Hi All,

How can I use the *.lib as a reference in a C# solution. Whenever I try to
add a "lib" file, VS throws an error explaining it must have a dll
extension?
You *cannot* add references to static unmanaged/native libraries.
"Add reference..." is to add a [reference] to other .NET assemblies,
that resides in dynamic libraries.

If you want to use the content of a static library, I would advice you
to make a small wrapper project in C++, link with the library, expose
the needed functions (with a .def-file or alike), compile the whole lot
with the /clr compiler switch (Use Managed Extentions), and add a
reference to it.
 
Just to add to the other answers:

I assume that the .lib that you are looking to reference is something that
you inherited... OTOH, if it is a standard library, then there's probably
already a call in the .NET framework that replaces it.

Good Luck,
--- Nick
 
Back
Top