Using c++ library in c#

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.


If it's a straight C++ library then it's not possible to reference it in this way.

You have two options, you can compile the C++ library as an assembly an expose the unmanaged code with a C++/CLI wrapper.

-or-

You can use some p/invoke calls if the library exposes it's functionality via a C API.

Could you expand the question a bit to include some details about how you normally call imaging.dll from c++?


if it is a unmanaged dll you cannot add a reference to it. You have to invoke it using pinvoke or the likes of it:

public classFoo

{

[DllImport("myunmanaged.dll", CharSet = CharSet.Ansi)]

private extern static int UnmanagedFunction(int type, int dest);

}

If you wanna convert it to a managed dll take a look here: http://msdn.microsoft.com/en-us/library/aa446538.aspx

If you wanna know some more about pinvoke and dllimport take a look here: http://msdn.microsoft.com/en-us/library/aa288468.aspx

Cheers