There is an unmanaged library written in Delphi, and a graphical shell written in C #. It is necessary to make so that the library on Delphi could throw an exception which could be processed at the level C #. Now the Delphi library throws a custom exception, but a .NET comes with a SEHException
, which the try/catch
does not act on. What should I throw on Delphi to make it work?
|
1 answer
Exceptions in Delphi and exceptions in .NET are two big differences, they are not compatible at all. The only way I see it is to modify your Delphi DLL so that the methods return error codes instead of exceptions (just like WinAPI does) and then write a .NET wrapper that will translate these error codes into exceptions.
There is another option for extremes - rewrite your DLL-ku to Delphi in the COM library, and zayuzat it in .NET via COM Interop. It seems to me that exceptions should be caught there all, but I did not try it myself.
But I would choose the first option, cheap and cheerful.
|
try { /*код*/ } catch {}
(exactly, and notcatch (Exception)
) doesn't help? How does interop work for you? - VladDLoadLibrary
desired function is loaded (the user can select it), thenMarshal.GetDelegateForFunctionPointer
and run. Blockcatch
and so on without a specific exception. - ModusSEHException
and be caught along with all the others. Try this , maybe the problem is here. - VladD