p/invoke calling C dll from c#
问题 this is my C code extern "C" { __declspec(dllexport) void DisplayHelloFromDLL(string a) { printf ("%s\n",a) } } this is my C# code class HelloWorld { [DllImport("TestLib.dll")] public static extern void DisplayHelloFromDLL(string a); static void Main () { string a = "Hello"; DisplayHelloFromDLL(a); } } It built successfully but crash like this: SO,how to use P/invoke to call my own C dll from C#? Please help,thanx in advance. 回答1: First of all your code is C++ rather than C. Your function