使用IXMLDocument在NTDLL中访问冲突

时间:2013-04-18 08:57:40

标签: delphi txmldocument

我在读取地址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和其他相关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,但他们没有发现错误。

2 个答案:

答案 0 :(得分:0)

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

“当创建没有所有者的TXMLDocument时,它的行为就像一个接口对象。也就是说,当释放对其接口的所有引用时,将自动释放TXMLDocument实例。当使用所有者创建TXMLDocument时,它会表现出来像任何其他组件一样,并由其所有者释放。“见Delphi - TXMLDocument created at run-time generates AV, with component on the form is working

完成后,设置XMLDoc:= nil;

答案 1 :(得分:0)

感谢雷米,问题解决了。这确实是CoInitialize未被调用的情况。我完全忘了这件事。