简体   繁体   中英

How do I protect my C# app from crashing when calling a method in an unmanaged DLL?

I have an unmanaged DLL written by another developer in unmanaged C++. My application is a WinForms application written in C#. I am using interop to call a method (function) in the native DLL. The call is causing my application to crash upon executing the method.

How does one safely call a method using interop, so that it does not bring the app down?

You could create a seperate AppDomain and load the unmanaged DLL in it. If the call crashes, it will just crash the AppDomain and your application will still live

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM