Board index » delphi » Raise exception in dll crash application!!!

Raise exception in dll crash application!!!

The main application calls a procedure in dll.  Within the procedure, I
stop the normal program flow by raise Exception.Create('Stop here').  The
application crash.  A message was given saying "Exception Exception in
module MyDll.DLL at 0006942F" (the error address is repeatable), instead of
raising an exception with the message "Stop here".  Is exception not
allowed in DLL?
 

Re:Raise exception in dll crash application!!!


Quote
Toh Hoon Ling wrote:

> The main application calls a procedure in dll.  Within the procedure, I
> stop the normal program flow by raise Exception.Create('Stop here').  The
> application crash.  A message was given saying "Exception Exception in
> module MyDll.DLL at 0006942F" (the error address is repeatable), instead of
> raising an exception with the message "Stop here".  Is exception not
> allowed in DLL?

Exceptions are allowed in DLLs. Note that you have to include the ShareMem
unit as the first entry in both the .dpr file of the main app and the dll
source. This is because Exceptions and the Message string they include are
objects from Delphi's heap. ShareMem coordinates heap usage between DLL and
main app.

HTH
-Michael

Re:Raise exception in dll crash application!!!


Is there any other way to an raise exception in DLL without using ShareMEM?
I have used some third party components in DLL without including ShareMEM
that raise exception properly.
Quote
Michael Winter <win...@foni.net> wrote:
>Exceptions are allowed in DLLs. Note that you have to include the ShareMem
>unit as the first entry in both the .dpr file of the main app and the dll
>source. This is because Exceptions and the Message string they include are
>objects from Delphi's heap. ShareMem coordinates heap usage between DLL and
>main app.

>HTH
>-Michael

Other Threads