Hi Renjith V Ramachandran,
thanks for posting here.
>>Is it the correct way. Some time i am getting crashes in clr!SafeReleasePreemp() while closing MyDlg.
In my opinion, you'd better not use delete to destruct managed object.
I have two suggestions for you.
1. Just call an method in c++ code but make the construction and destruction in your c# code. Use
GC::Collect
Method ()
or IDisposable
Interface.
2. Use C++/CLI wrapper to help you interop with c# code.
Here are some documents for you as a reference.
https://www.codeproject.com/articles/556582/usingplusc-23plusfromplusnativeplusc-2b-2bpluswith
https://code.msdn.microsoft.com/windowsdesktop/CppCLINativeDllWrapper-29c32acd
Hope this could be help of you.
Best Regards,
Sera Yu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.