未经处理的异常: System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
啊拉丁的鱼 2013-05-21 05:51:38 未经处理的异常: System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
如题:我用C++生成的一个DLL,用C#调用,结果在DOS窗口下运行出现了上面这个错误。但是能编译通过,直接按F5也能正常运行,没有报错!
错误提示如下:
“
未经处理的异常: System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
在 .TradeApi.reqUserLogin(String BROKER_ID, String INVESTOR_ID, String PASSWORD)
在 .TradeApi.UserLogin() 位置 D:\Users\huige\documents\visual studio 2010\Projects\CTP\SN_CTP\TradeApi.cs:行号 110
在 .FormTrade.tradeApi_OnFrontConnect() 位置 D:\Users\huige\documents\visual studio 2010\Projects\CTP\SN_CTP\FormTrade.cs:行号 1039
”
C#中的调用语句如下:
public int UserLogin() { return reqUserLogin(this.BrokerID, this.InvestorID, this.passWord); }
[DllImport(dllName, EntryPoint = "ReqUserLogin", CallingConvention = CallingConvention.Cdecl)]
static extern int reqUserLogin(string BROKER_ID, string INVESTOR_ID, string PASSWORD);
这是怎么回事呢?求高手解答!