开发者

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

开发者 https://www.devze.com 2023-01-06 00:26 出处:网络
I have an unmanaged DLL written by another developer in unmanage开发者_如何学God C++. My application is a WinForms application written in C#. I am using interop to call a method (function) in the nati

I have an unmanaged DLL written by another developer in unmanage开发者_如何学God 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

0

精彩评论

暂无评论...
验证码 换一张
取 消