0

興味深い例外に遭遇しました。運用サーバーの 1 つで、次の例外が発生することがあります。

System.NullReferenceException: Object reference not set to an instance of an object.
    at System.Xml.DocumentXPathNavigator.get_NameTable()
    at System.Xml.Xsl.Runtime.XmlQueryContext.get_DefaultNameTable()
    at System.Xml.Xsl.Runtime.XmlQueryRuntime..ctor(XmlQueryStaticData data, Object defaultDataSource, XmlResolver dataSources, XsltArgumentList argList, XmlSequenceWriter seqWrt)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
    at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    at sftControls.SearchListLandingPage.getHtml(IXPathNavigable document, String Xsl, String headerLinks)

IL を開いて各メソッドを調べると、 DocumentXPathNavigator => this.document が null であることが示唆されます。奇妙なのは、この問題をローカルでもテスト サーバーでもまったく再現できないことです。

ちょっとした背景、これが鍵かもしれません...これは、XslCompiledTransform.Transform() に渡される XmlDocument をキャッシュする Web アプリケーション (.Net 3.5 を実行) です。当社のキャッシングは、分散型キャッシュ サーバーを通じて提供されます。XmlDocument はシリアル化されてキャッシュされるため、特定のオブジェクトへの参照が存在し続けることはありません。これにより、暗黙の XmlDocument -> DocumentXPathNavigator が発生したときに this.document が設定されないように何かが明示的に妨げられているか、Transform() の実行中にどこかの参照が削除されていると思われます。いずれにせよ、私は困惑しています。

だから、私の質問は次のとおりだと思います:

  1. 他の誰かがこれを見たことがありますか?
  2. 何が原因なのか、または対処方法を知っている人はいますか?

ありがとう

編集:
これについてさらに考えた後、意味のある唯一のことは、それが競合状態であることです。アプリケーションがオブジェクトを使用している間に、キャッシング アプライアンスが何らかの理由でオブジェクトを期限切れにしています。

編集/編集:
.Net 3.5、上記で参照されているアセンブリは 2.0 です

4

2 に答える 2

0

XslCompiledTransform 内で非常によく似た例外が発生しました。

   System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
      at MS.Internal.Xml.Cache.XPathDocumentNavigator.get_NodeType()
      at System.Xml.XPath.XPathNavigator.MoveToNonDescendant()
      at System.Xml.Xsl.Runtime.DescendantMergeIterator.MoveNext(XPathNavigator input)
      at <xsl:template name="SystemPartIncluded">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, IList`1 PartNumber, XPathNavigator Description, IList`1 DescriptionOverride, IList`1 Quantity, IList`1 ExtendedPrice, String LabelWhiteSpace)
      at <xsl:template name="compiler:generated"> (30)(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, XPathNavigator isBundledWithCanvas, XPathNavigator SoftwareExtendedPrice, XPathNavigator SoftwareUnitPrice, IList`1 PixelNet, IList`1 Revision_Date, IList`1 Catalyst)
      at <xsl:template name="compiler:generated"> (45)(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, XPathNavigator SoftwareUnitPrice, XPathNavigator HardwareExtendedPrice, XPathNavigator HardwareUnitPrice, XPathNavigator PixelNetUnitPrice, XPathNavigator FusionUnitPrice)
      at <xsl:template match="Quote">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last)
      at <xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)
      at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
      at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
      at MyApp.clsXML.XslTransformationToHtml(IQEntities DC, Int32 loggedOnUserID, IXPathNavigable input, String xslStylesheetFilePath, XsltArgumentList xslArgs, String XmlRepositoryVersion) in MyApp\App_Data\Static Classes\xml_routines.cs:line 510
      at MyApp.clsQuote.RenderOneQuote(IQEntities DC, Int32 loggedOnUserID, Int32 quoteID, Boolean booPrintFormat, Boolean booDiscount_Prices, Boolean booIs_Super_Administrator, Boolean isHostRep, String strOrganization_Table_Caption, Boolean showBottomLineOnly) in MyApp\App_Data\Static Classes\quote_routines.cs:line 476
      at MyApp.Pages.AJAX.BrowseQuotes.RenderSelectedQuote(Int32 quoteID) in MyApp\Pages\AJAX\BrowseQuotes.aspx.cs:line 66
      at MyApp.Pages.AJAX.BrowseQuotes.ucQuotePicker1_OnQuoteSelectedEvent(Object sender, Int32 quoteID) in b:\DotNet\IQ\WinMetrics.IQ\Pages\AJAX\BrowseQuotes.aspx.cs:line 56
      at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      at System.Web.UI.Page.HandleError(Exception e)
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      at System.Web.UI.Page.ProcessRequest()
      at System.Web.UI.Page.ProcessRequest(HttpContext context)
      at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

あなたと同じように、XPathDocument を Xsl 変換に渡し、XPathDocument を分散キャッシュから取得していました。残念ながら、XPathDocument はシリアル化できないため、分散キャッシュから取得した後は使用できません。XPathDocument の代わりに XmlDocument を使用し、SerializedXmlDocument を使用して次のようにシリアル化および逆シリアル化することで、問題を修正しました。

        public static XmlDocument CachedXmlDoc
        {
            get
            {
                lock (_locker)
                {
                    // maintain the Part XmlDocument in the distributed cache so that it can be reset from any production instance
                    SerializedXmlDocument serializedXmlDoc = Reliable.Application[Global.CACHED_XML_DOC] as SerializedXmlDocument;
                    XmlDocument cachedDoc = (serializedXmlDoc == null) ? null : serializedXmlDoc.XmlDocument;
                    if (cachedDoc == null)
                    {
                        cachedDoc = myController.CreateXmlDoc();
                        Reliable.Application[Global.CACHED_XML_DOC] = new SerializedXmlDocument(cachedDoc);
                    }
                    return cachedDoc;
                }
            }
            set
            {
                lock (_locker)
                {
                    if (value == null)
                    {
                        Reliable.Application[Global.CACHED_XML_DOC] = null;
                    }
                    else
                    {
                        throw new Exception("Tried to set the cached XmlDocument to something other than null.");
                    }
                }
            }
        }
于 2014-01-04T12:41:01.893 に答える