when i use dllimport to invoke C++ function as below:
[DllImport("Test.dll", EntryPoint = "Init", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
public static extern int Init();
i use this function serveral months,after that,i add one line code in Init as below:
A* a = new A();
when i use VS2010 debug Run model is ok,but when i use double click to run exe,it throw error:
Try to read or write protected memory. This usually indicates that other memory is corrupt
i can't find any problem in the code,very confuse.
so post this question and hope someone met the same question and help me to solve.
thanks!
What I have tried:
I add two messagebox as below:
MessageBox(NULL,"111111!","OK!",MB_OK | MB_ICONINFORMATION);
A* a = new A();
MessageBox(NULL,"222222!","OK!",MB_OK | MB_ICONINFORMATION);
so compile code project,and double click EXE,"111111" can popup,but "22222" cann't be.
so i'm sure that new A() must be some error in.
A class consturct function as below:
A::A()
{
MessageBox(NULL,"333333!","OK!",MB_OK | MB_ICONINFORMATION);
ctx = new des_context();
ctx3 = new des3_context();
bDESKeyExists = false;
bDES3KeyExists = false;
}
i cann't see "333333" popup,very confuse,cann't find the question.