我在读取地址0xfeeeee时不断遇到访问冲突,调试器在Ntdll上停止。NtRaiseException,我不能进一步调试,因为我得到一个循环条件告诉我应用程序在…使用step或run…这让我回到了开头。这显然只发生在32位IDE (Delphi XE2)中。我的应用程序正在使用以下代码位
Var
XMLDoc: IXMLDocument;
Begin
If FOD.Execute Then //File Open Dialog
Begin
Try
Try
XMLdoc := NewXMLDocument(); //TXMLDocument.Create(Nil);
Result := FOD.FileName;
XMLDoc.FileName := XMLFilename;
XMLDoc.Active := True;
文件打开时,我调用从xml数据绑定向导(file New Other xml)加载的函数来解析在上述过程中打开的xml文件。我的意图只是创建一个csv文件,然后使用sqldr将数据导出到oracle数据库。在IDE之外,所有工作都可以找到,我可以让应用程序运行,只是在一个字符串网格中显示数据,但在IDE中,它在几分钟内崩溃。调用堆栈没有显示任何有用的内容。正如您所看到的,我已经尝试了TXMDocument。create,以及NewXML,但都无济于事。我试过把对象放在形式上,并使用该实例无济于事。有人有什么想法吗?(Windows 7 64位,但我抱怨到32位由于oracle的依赖)
编辑,即使打开了调试开关,调用堆栈也没有显示任何使用,只是引用了ol32 .dll和其他nt相关的dll
应用程序的代码如下所示(部分代码)
Function TXMLForm.OpenFile: String;
Var
XMLDoc: IXMLDocument;
Begin
If FOD.Execute Then
Begin
Try
Try
XMLdoc := NewXMLDocument(); //TXMLDocument.Create(Nil);
Result := FOD.FileName;
XMLDoc.FileName := XMLFilename;
XMLDoc.Active := True;
SB1.Panels[1].Text := FOD.Filename;
Finally
// xmldoc := nil;
End;
Except
On E: Exception Do
ShowMessage('Excpetion in Opening or creating XML Document. ' + E.Message);
End;
End
Else
Result := '';
End;
openfile被这样的过程调用
Procedure TXMLForm.StandardProfile1Click(Sender: TObject);
Var
Stand: Standard.IXMLProfileData;
I, X: Integer;
Begin
XMLFileName := Openfile;
If Xmlfilename <> '' Then
Begin
Stand := Standard.LoadProfileData(XMLFileName);
SG1.RowCount := Stand.Count;
Sg1.ColCount := Stand.Device[Stand.Count - 1].Count + 7;
// SG1.ColCount := 55;
SG1.Cells[0, 0] := 'SERIALNO';
SG1.Cells[1, 0] := 'MFGSERIALNO';
SG1.Cells[2, 0] := 'SUPPLYTYPE';
SG1.Cells[3, 0] := 'SERVICEPOINTNO';
SG1.Cells[4, 0] := 'PARAMETERCODE';
SG1.Cells[5, 0] := 'INTERVALPERIOD';
SG1.Cells[6, 0] := 'STARTTIME';
// For X := 0 To 47 Do
// SG1.Cells[7 + X, 0] := 'INTERVAL' + Inttostr(X);
For X := 0 To Stand.Device[Stand.Count - 1].Count - 1 Do
SG1.Cells[7 + X, 0] := 'INTERVAL' + Inttostr(X);
For I := 0 To Stand.Count - 1 Do
Begin
SG1.Cells[0, I + 1] := Stand.Device[I].SerialNo;
SG1.Cells[1, I + 1] := Stand.Device[I].MfgSerialNo;
SG1.Cells[2, I + 1] := Stand.Device[I].SupplyType;
SG1.Cells[3, I + 1] := Stand.Device[I].ServicePointNo;
SG1.Cells[4, I + 1] := Stand.Device[I].ParameterCode;
SG1.Cells[5, I + 1] := Stand.Device[I].IntervalPeriod;
SG1.Cells[6, I + 1] := Stand.Device[I].StartTime;
// For X := 0 To 47 Do
For X := 0 To Stand.Device[Stand.Count - 1].Count - 1 Do // 47
Begin
If Stand.Device[I].Interval[X] = '' Then
SG1.Cells[7 + X, I + 1] := 'TRUE'
Else
SG1.Cells[7 + X, I + 1] := Stand.Device[I].Interval[X];
End;
End;
End;
End;
如前所述,我已经尝试使用TXMDocument、IXMLDocument和使用Create和NewXMDocument,但这仍然给出错误。DEbug dcus'没有区别。我已经厌倦了在项目头和MadExcept中使用FastMM4,但它们没有捕获错误。
没有显示处理XMLDoc的所有代码;也许你在释放它?
"当创建没有所有者的TXMLDocument时,它的行为就像一个接口对象。也就是说,当对其接口的所有引用被释放时,TXMLDocument实例将自动被释放。但是,当使用Owner创建TXMLDocument时,它的行为与任何其他组件一样,并由其Owner释放。"参见Delphi - TXMLDocument在运行时创建生成AV,窗体上的组件正在工作
同样,设置XMLDoc:= nil;
多亏了Remy,问题才得以解决。这确实是未调用CoInitialize的情况。我完全忘了这个