Board index » delphi » global automation object inside another causes problem

global automation object inside another causes problem

I have a problem when using a global automationobject
interface as a global variable of another automation.
The DLL crashes telling me has too many consecutive
errors and leaves me insides TObject.Free.

I am sure this has something to do with the global,
because the problem is solved when I remove it,
but I really do need a global variable.

Isn't it safe to use global variables inside a
automation object implementation??

I am looking at it for hours and desperately need your
help..

 

Re:global automation object inside another causes problem


I have a problem when using a global automationobject
interface as a global variable of another automation.
The DLL crashes telling me has too many consecutive
errors and leaves me insides TObject.Free.

I am sure this has something to do with the global,
because the problem is solved when I remove it,
but I really do need a global variable.

Isn't it safe to use global variables inside a
automation object implementation??

I am looking at it for hours and desperately need your
help..

Re:global automation object inside another causes problem


Quote
> I have a problem when using a global automationobject
> interface as a global variable of another automation.
> The DLL crashes telling me has too many consecutive
> errors and leaves me insides TObject.Free.

> I am sure this has something to do with the global,
> because the problem is solved when I remove it,
> but I really do need a global variable.

> Isn't it safe to use global variables inside a
> automation object implementation??

> I am looking at it for hours and desperately need your
> help..

I am also part of OddesE's team and I found this snippit
of a post from Binh Ly (techvanguards.com):

"Most likely, your DLL has a global variable that still
holds an instance to a COM object at shutdown time. What's
happening is Win32 will unload your DLL (along with your
main EXE of course) long after CoUninitialize has been
called. Well, COM requires that you should interact with
COM only within the confines of CoInitialize and
CoUninitialize. Any COM interaction before or after that
is considered "invalid" - and if you try to release an
interface pointer (which is what is probably happening in
your DLL), then you should expect unpredictable results."

This exactly describes our situation. One autmationobject
TAutomationA having a global var IAutomationB. But would
is the solution/remedy? We need this global in one way or
another.

Other Threads