views:

94

answers:

2

Hi all,

can someone give me some advice on where to start. I have quite a complex system built as a delphi Activeform. And it runs embedded in a webpage.

System runs great, except when closing down ie. after IE closes I get a bunch of error saying:

IEXPLORE.EXE - Application Error The instruction at "blahblah' referenced memory at "anotherblahblah". The memory could not be "read"

Hitting ok a couple times gets past this, but it is really annoying, and I dont know where to even begin debugging this. Any advice? Not even MadExcept helps me out here.

Thanks!

A: 

Never done it with an ActiveX, but can't you debug it from the IDE like you would with a regular DLL? In your Project, providing the host apllication (IExplore with needed parameters) and running it.

My wild guess would be some code in a finalization section or a using Free instead of Release on a Form that has still some event to process.

If nothing works, a (slow) way of testing it would be to start with a bare-bone ActiveX and start adding the different features until it happens again.

François
A: 

I've worked with Internet Explorer form Delphi before, and since this uses COM quite intensively, it's important to follow the reference-counters on the interfaces on your objects, especially when you keep extra copies of interface pointers in your Delphi code. The error you describe typically happens in closing when an object is prematurely destroyed, and a second destroy tries to call an already vanished object to clean up.

The hardest do-it-yourself way to debug the reference counting is implement the IUnknown interface yourself on your objects so you can put breakpoints in the _AddRef and _Release methods. See the basic TInterfacesObject implementation for an idea how to handle reference counting and patch through QueryInterface calls.

Stijn Sanders