Passing c# string to unmanaged c++ DLL
问题 I have a simple application that loads an unmanaged dll and passes a few string values to it from C#. But in the C++ dll application, I receive an exception :: Tried to access a read/write protected memory. My DLL Import looks like this: [DllImport("X.dll", CallingConvention = CallingConvention.Cdecl) ] public static extern int DumpToDBLogFile([MarshalAs(UnmanagedType.I4)]int loggingLevel, [MarshalAs(UnmanagedType.I4)]int jobId, int threadId, [MarshalAs(UnmanagedType.LPStr)]string procName,