S
S
Samyrro0542020-04-21 10:00:39
C++ / C#
Samyrro054, 2020-04-21 10:00:39

How to catch an exception from unmanaged code?

Hello. I wrote a program based on a third-party dll library (specifically, Telegram.Bot.dll). Instead of WebHook, I use Bot.OnUpdate, which constantly polls the server. Everything works fine, but every couple of days the program crashes, displaying the standard CLR. The error refers to System.Web.HttpRequest.dll. Maybe the server did not respond temporarily, or something else happened, I don’t know which exceptions in the library are not handled. The question is how to catch an exception from unmanaged code? I can't edit the dll in any way. Theories I've read a lot - everyone recommends using an external exception, but how to use it? It is the code, where to connect it, what needs to be written so that the program does not crash, but, for example, stupidly ignores and continues to work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2020-04-21
@Samyrro054

https://docs.microsoft.com/ru-ru/dotnet/api/system... You
can catch it using a regular try-catch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question