0

我在读取地址 0xfeeefeee 时不断遇到访问冲突,其中调试器在 Ntdll.NtRaiseException 上停止,我无法进一步调试,因为我得到一个循环条件告诉我应用程序在...处出现故障...使用步骤或运行...这让我回到了起点。这显然只发生在 IDE (Delphi XE2) 32 位中。我的应用程序正在使用以下代码

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) 加载的函数来解析在上面的 proc 中打开的 xml 文件。我的意图只是创建一个 csv 文件,然后使用 sqlldr 将数据导出到 oracle 数据库。在 IDE 之外找到所有工作,我可以让应用程序运行,只是在一夜之间在 sring 网格中显示数据,但在 ide 中它会在几分钟内崩溃。调用堆栈没有显示任何有用的信息。如您所见,我尝试过 TXMDocument.create 和 NewXML,但无济于事。我尝试将对象放在表单上并使用该实例无济于事。任何人请有任何想法。(Windows 7 64 位,但由于 oracle 依赖,我正在编译为 32 位)

编辑,即使打开了调试 dcus,调用堆栈也显示没有任何用处,只是对 ole32.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,但他们没有发现错误。

4

2 回答 2

0

您没有展示处理 XMLDoc 的所有代码;也许你正在释放它?

“当创建没有所有者的 TXMLDocument 时,它的行为类似于接口对象。也就是说,当释放对其接口的所有引用时,TXMLDocument 实例会自动释放。但是,当使用所有者创建 TXMLDocument 时,它的行为就像任何其他组件,并由其所有者释放。” 请参阅Delphi - 在运行时创建的 TXMLDocument 生成 AV,表单上的组件正在工作

完成后,设置 XMLDoc := nil;

于 2013-04-18T09:04:41.253 回答
0

感谢 Remy,问题解决了。这确实是没有调用 CoInitialize 的情况。我完全忘记了这件事。

于 2013-04-19T12:09:20.797 回答