Landin Martens
Landin Martens

Reputation: 3333

can't call C++ function from C#

I have a DLL with a set of functions. The DLL was used with "themidia" to make it safe.

When I try to call the functions, C# spits out errors due to the functions names.

[DllImport("safety.dll", CallingConvention=CallingConvention.StdCall, ExactSpelling=true)]
private static extern IntPtr _encryptLogin@8(string string_0, string string_1);

If I remove the @8 and remove ExactSpelling=true, it just returns an exception saying no entry point.

What exactly am I doing wrong?

Upvotes: 0

Views: 218

Answers (2)

svick
svick

Reputation: 245036

As an alternative to specifying EntryPoint as rfmodulator suggested, you can use extern "C" in your C++ source, which will make the exported function names the same as their names in your C++ source.

C++ compiler normally mangles the names of functions, so that you can have overloaded functions (functions with the same name bu different parameters).

Upvotes: 0

rfmodulator
rfmodulator

Reputation: 3738

Remove the "@", and in your attribute add EntryPoint="_encryptLogin@8"

Upvotes: 3

Related Questions