This is my DLL Import statement:
[DllImport("KaracellLib.dll", EntryPoint = "karacell_bridge@8", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, ExactSpelling = true)]
public static extern int karacell_bridge(int argumentCount, string[] argContent);
The actual function definition in the native C code (which is converted to a DLL):
int __stdcall karacell_bridge(int argumentCount, char ** argContent )
When I try to call the DLL in my C# code more than once, I get the error mentioned.
I have tried the following to resolve the error
- Suppress JIT optimization on module load(managed nly) by going into Tools -> Debugging -> General
- Added ref in the C# dLL import definition:
public static extern int karacell_bridge(int argumentCount, ref string[] argContent);
Any help is appreciated! Thanks!