Works in Delphi 3 but not Delphi 4

I have a project that uses DLL's That I have also Created.  But If I complie
them all in Delphi 3 It works fine but in Delphi 4 when I run the Program,
Load a Dll call my function etc.. then free the DLL I get flooded by
EAccessErrors and I mean Flooded over 100 !

I have found how to Prevent it but it is far from being a Proper way to
prevent the error.  Here how it works.

  I run My program and When I want to access a special function I explicitly
load my DLL.  I call the function within the DLL.  This DLL Function in turn
creates a Form, using ShowModal displays the form and finally it Free the
form (Obviously when the user closes the form).  Then My function is done, I
return to the main program and the DLL is freed.  Now somehow when it gets
to the (DLL) Form.Free I get flooded with the EAccessViolation error.

  I have already figured out that Delphi 4 requires you to use a New DLL
along with ShrareMem if you use strings and that is not the problem.

I have also Discovered that If I put a SLEEP(1000) Statment right after my
(DLL) Form1.Free statment the errors go away But I am sure everyone will
agree that this is not a very good way of handling Errors(Hum lets just wait
a bit and see if the error will go away).  So someone might say Use
Form1.Release instead of From1.Free since it waits to make sure the All the
events are finished before actually releasing the form.  And Personally I
think that this is the right solution But,  If I do this, the form closes no
problem, the DLL is Freed AND MY Application TERMINATES (Without any
errors!!!)
So it looks like something is not right here,

Do you have any Idea of the Proper way to get rid of my EAccessViolation
error and why if I use a Form1.Release on a Form that s not the Project Main
form (Actually it is not part of the project at all but part of a DLL called
by the application) closes the WHOLE application?

eric jodoin
ejod...@inetex.com