.net – Using a COM DLL in delphi – Access violation in MSVCR80D.dll error


I need to use a DLL created using .NET framework. This DLL is made COM visible.

I want to use this DLL in an application created using Delphi 2006. I have followed following steps:

  1. Registered the DLL using regscr32.
  2. Imported the type library using
    Delphi IDE. It created
    _TLB.pas file. Following signature was created in TLB file.

    function TValidationRequest.Process(var meterBSN: WideString; var NICSerial: WideString; 
                                        var partNumber: WideString; var otherConfig: WideString; 
                                        out returnMessage: WideString): Smallint;
      Result := DefaultInterface.Process(meterBSN, NICSerial, partNumber, otherConfig, returnMessage);
  3. I tried to call the method using
    following code snippet.

procedure TForm1.buttonClick(Sender: TObject);
  valReq: TValidationRequest;
  s1, s2, s3, s4, s5: WideString;
  o: WideString;
  valReq := TValidationRequest.Create (Self);
    valReq.Process (s1, s2, s3, s4, o);
    MessageDlg(o, mtInformation, [mbOK], 0);
    valReq := nil;

But I get following error when Process method is called.
alt text

Please can you suggest any solution?

Best Solution

Try initializing the WideStrings (s1,s2,s3,s4, and maybe even o). If I recall correctly, they are dynamic in Delphi and nil (000000000) before you set them up.

Related Question