I have a C++/CLI (VS 2008) mixed mode library that creates native objects and calls methods in then. Native dll is written in pure c++. Now in my C++/CLI wrapper methods if I declare object of native classes in c++ way as
ClassA obj;
Obj.Method();
and use it, it works but, I get System.AccessViolationException: Attempt to read or write protected memory
when the program exists.
But if I do it this way
ClassA *obj = new ClassA();
Obj->Method();
it works fine.
So my question is why cant I declare a object just on stack the C++ way ?
Destructor
in the native code is declared virtual. Is that the reason ?