2

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

  1. Suppress JIT optimization on module load(managed nly) by going into Tools -> Debugging -> General
  2. Added ref in the C# dLL import definition: public static extern int karacell_bridge(int argumentCount, ref string[] argContent);

Any help is appreciated! Thanks!

4

1 回答 1

0

问题是因为多个线程在 C# 程序中调用 karacell_bridge 函数。因此,一旦我处理了它,异常就修复了:)

于 2012-10-18T06:04:57.590 回答