YakovE
YakovE

Reputation: 21

Enable to call unmanaged method - "Unable to find an entry point named 'XXX' in DLL 'XXX.dll'."

I trying to use a method in a dll written in C in a C# console app project. this is the method signature in h file I got :

DLL_PUBLIC sint AshrAPI_TranRecToRefunISO(char* TranRec , byte* RefunISO , usint* ISOLength);

I used P/Invoker to create the corresponding method in C#:

[DllImport(@"Ashrait.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.I2)]
        internal static extern short AshrAPI_TranRecToRefunISO([MarshalAs(UnmanagedType.LPStr)] string TranRec, [MarshalAs(UnmanagedType.LPArray)] byte[] RefunISO, ushort ISOLength);

but no matter which UnmanagedType I try to use, I always get the same exception : Unable to find an entry point named 'XXX' in DLL 'XXX.dll

can anyone see something wrong ?

Upvotes: 0

Views: 332

Answers (1)

YakovE
YakovE

Reputation: 21

so found out the issue! since I loaded the dll to project as an item and not as a reference, I've put it in resources folder inside the project. once I moved the dll to root project folder everything started working :)

Upvotes: 1

Related Questions