Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using c++ library in c#

I am trying include c++ library (DLL) in my c# project but every time I do that I get following error message in VS2008, any suggestions?

EDIT: It's a C++ MFC DLL

---------------------------
Microsoft Visual Studio
---------------------------
A reference to 'C:\Users\cholachaguddapv\Desktop\imaging.dll' could not be added. Please make sure that the file is accessible, and
that it is a valid assembly or COM component.
like image 558
Prashant Cholachagudda Avatar asked Apr 21 '09 10:04

Prashant Cholachagudda


People also ask

What is C type library in C?

The ctype. h header file of the C Standard Library declares several functions that are useful for testing and mapping characters. All the functions accepts int as a parameter, whose value must be EOF or representable as an unsigned char.

How do libraries work in C?

C libraries store files in object code; during the linking phase of the compilation process ( Compilation Process) files in object code are accessed and used. It is faster to link a function from a C library than to link object files from a separate memory sticks or discs.

What is the use of C standard library?

The C standard library provides macros, type definitions and functions for tasks such as string handling, mathematical computations, input/output processing, memory management, and several other operating system services.

Is there library in C?

A library in C is a collection of header files, exposed for use by other programs. The library therefore consists of an interface expressed in a . h file (named the "header") and an implementation expressed in a .


1 Answers

If it is a "normal" DLL (not COM, not managed C++), you cannot add a reference like this. You have to add p/invoke signatures (external static method definitions) for the exports you want to call in your DLL.

[DllImport("yourdll.dll")]
public static extern int ExportToCall(int argument);

Have a look at the DllImport attribute in the online help.

like image 193
Lucero Avatar answered Oct 12 '22 23:10

Lucero