日期:2014-05-17  浏览次数:21454 次

尝试读取或写入受保护的内存。这通常指示其他内存已损坏
本帖最后由 mogli129 于 2012-12-20 21:04:38 编辑
C++ DLL声明为:
HRESULT WINAPI GetParam(HANDLE pDataHandle,  LPCTSTR paramName,  LPTSTR ParamValue, UINT nMaxValueLenth)
我的代码声明为:
        [DllImport("TEST.dll", CharSet = CharSet.Ansi,
            SetLastError = false, CallingConvention = CallingConvention.StdCall, EntryPoint = "GetParam")]
        public static extern int GetParam(IntPtr pDataHandle, string paramName, ref StringBuilder paramValue, uint nMaxValueLenth);

可是调用报如题的错,求助!
------解决方案--------------------
http://msdn.microsoft.com/en-us/library/s9ts558h(v=vs.71).aspx

去掉ref看看。