views:

56

answers:

1

I have a Com Object, setup/create/working from a DataModule.

creating/running/freeing the Datamodule from an Application works with out an issue.

but putting the datamodule into a DLL works fine the first time, runing the com object etc.. but after a few calls with out restarting the application, this error appears.

Error Message image

There is a fare bit of code in the App, so i cant post it all, I have tried MadExcept in both the Application and Dll, with no luck. The IDE Breaks at a point that does not seem much help...

alt text

this is the code that handles the DataModule, the same function is used in the Application and the Dll in both tests

function GetAmount( Amount : integer; var Info: PChar): integer; stdcall;
 var
  tempInfo: string;
   workerDM : TworkerDM;
 begin
  Result := 0;    
  workerDM := TworkerDM.Create(nil);
    try      
      tempInfo:= Info;
      Result := workerDM.GetAmount(Amount, tempInfo);
      StrPCopy(Info, tempInfo);
    finally
      workerDM.Free;
    end;
 end;

i would like to blame the Ole Object, but it works fine out of the Dll

I'm at a loss to even think where to start looking.

+1  A: 

In the finally, you are calling Free, but should call workerDM.Free.

Jeroen Pluimers
sorry that was a victim to copy/pasting and formatting for stackoverflow
Christopher Chase
@Christopher: no problem; I have bumped into a lot of real world code that was wrong that way, causing very hard to find bugs. Nice that your code did not suffer from it.
Jeroen Pluimers