<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<br>
<br>
<blockquote type="cite"
cite="mid:4108c4a6-91a3-b9b2-4eb2-a1e6a8ab569e@googlemail.com">
<blockquote type="cite">
<blockquote type="cite">Please note that you won't be able to
catch such an exception with the type from within the
application, e.g.:
<br>
<br>
=== code begin ===
<br>
<br>
try
<br>
SomeLibraryFunction;
<br>
except
<br>
on e: TMyObject do
<br>
Whatever;
<br>
else
<br>
WhateverElse;
<br>
end;
<br>
<br>
=== code end ===
<br>
<br>
The above code would go to the first branch *inside* your
library, but it will *always* go to the else-branch outside
your library, cause the comparison is done on the pointer to
the VMT (the class type) which will be *different* between
library and application (even if you use the same unit!). This
is one of the main reasons why dynamic packages are needed for
comfortable use of libraries in Object Pascal, because it
allows such types to be shared across module boundaries.
<br>
<br>
</blockquote>
My situation is even worser :-)
<br>
Library DLL is writen in Pascal, but main application is C/C#.
<br>
</blockquote>
<br>
Then it will probably be caught as some external exception or
such... don't know, never tried it.
<br>
</blockquote>
<b>“System.Runtime.InteropServices.SEHException (0x80004005):
External component has thrown an exception.”</b><br>
<br>
<blockquote type="cite"
cite="mid:4108c4a6-91a3-b9b2-4eb2-a1e6a8ab569e@googlemail.com">
<br>
<blockquote type="cite">When I call in library RunError() then
whole application aborts.
<br>
I need throw exception in library which can be catched in
application.
<br>
<br>
I now use in unit which is used by library:
<br>
<br>
if System.IsLibrary then
<br>
raise TObject.Create // raise exception - type of exception
is not important ...
<br>
// can I call here also Windows's RaiseException()? ... so
it will be propagated to linking application?
<br>
else
<br>
System.RunError(w);
<br>
</blockquote>
<br>
"raise" internally uses . The only difference would be that you'd
have a bit more control of exception code and such if you want to
ensure that it's caught nicely by the C/C++/C# code.
<br>
</blockquote>
<br>
Ok, then if raise TObject.Create; calls RaiseException then I think
that I will use raise TObject.Create;<br>
Thanks<br>
L.<b><br>
</b><br>
</body>
</html>