访问冲突MSVCR80D.dll错误
我需要使用使用.NET框架创建的DLL。 此DLL使COM可见。
我想在使用Delphi 2006创建的应用程序中使用此DLL。我遵循以下步骤:
使用Delphi IDE导入类型库。 它创建_TLB.pas文件。 签名后在TLB文件中创建。
function TValidationRequest.Process(var meterBSN: WideString; var NICSerial: WideString;
var partNumber: WideString; var otherConfig: WideString;
out returnMessage: WideString): Smallint;
begin
Result := DefaultInterface.Process(meterBSN, NICSerial, partNumber, otherConfig, returnMessage);
end;
我试图使用下面的代码片段调用该方法。
procedure TForm1.buttonClick(Sender: TObject);
var
valReq: TValidationRequest;
s1, s2, s3, s4, s5: WideString;
o: WideString;
begin
valReq := TValidationRequest.Create (Self);
try
valReq.Process (s1, s2, s3, s4, o);
MessageDlg(o, mtInformation, [mbOK], 0);
finally
valReq := nil;
end;
end;
但是当Process方法被调用时,我得到以下错误。 替代文字http://i41.tinypic.com/2daf1ix.png
请你能提出任何解决方案?
尝试初始化WideStrings ( s1 , s2 , s3 , s4 ,甚至可能是o )。 如果我没有记错,那么在设置它们之前,它们在Delphi中是动态的,零(000000000)。
除了MarkusQ所说的之外,请注意,您对TValidationRequest对象的内存管理不太好。 使用Create(nil)然后在finally FreeAndNil(valReq)写入FreeAndNil(valReq)会更干净。 现在,您每次单击按钮时都会创建一个TValidationRequest对象,并且它们都将保留在内存中,直到您销毁表单。 至少你不会得到内存泄漏,因为你将Self传递给了构造函数,所以至少表单会照顾到销毁这些对象。 在你的例子中, TForm1.buttonClick方法结束后,实际上不需要保持对象的存在。
上一篇: Access violation in MSVCR80D.dll error
下一篇: How to make it so that the nodes simply do not have a parent
