2011-02-01 137 views
1

任何人都可以解释此异常吗?在 '/ eims_web' 应用空引用异常堆栈

服务器错误:

Object reference not set to an instance of an object. 

说明:

An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

异常详细信息:

System.NullReferenceException: Object reference not set to an instance of an object. 

源错误:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

堆栈跟踪:

[NullReferenceException: Object reference not set to an instance of an object.] 
    System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +24 
    System.Xml.XmlDocument.Load(XmlReader reader) +108 
    System.Web.UI.WebControls.XmlDataSource.PopulateXmlDocument(XmlDocument document, CacheDependency& dataCacheDependency, CacheDependency& transformCacheDependency) +342 
    System.Web.UI.WebControls.XmlDataSource.GetXmlDocument() +253 
    System.Web.UI.WebControls.XmlHierarchicalDataSourceView.Select() +51 
    System.Web.UI.WebControls.Menu.DataBindItem(MenuItem item) +326 
    System.Web.UI.WebControls.Menu.PerformDataBinding() +99 
    System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect() +126 
    System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +125 
    System.Web.UI.WebControls.Menu.DataBind() +29 
    System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +104 
    System.Web.UI.WebControls.Menu.EnsureDataBound() +70 
    System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +43 
    System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e, Boolean registerScript) +89 
    System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e) +63 
    System.Web.UI.Control.PreRenderRecursiveInternal() +200 
    System.Web.UI.Control.PreRenderRecursiveInternal() +322 
    System.Web.UI.Control.PreRenderRecursiveInternal() +322 
    System.Web.UI.Control.PreRenderRecursiveInternal() +322 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4837 
+0

它看起来像你的XmlDocument未能加载。确保你的xml声明是正确的,并且xml结构中没有错误。 – 2011-02-01 05:54:37

回答

1

没有看到你的代码,这将是很难说的,而是由堆栈跟踪的长相,我会打赌猜测,说你有一个绑定到一个TreeView /菜单一个XmlDataSource

很明显,在数据绑定过程中出现了问题,但又没有看到代码填充XmlDataSource,它几乎不可能为您提供进一步的帮助。

1

XmlReader例如从XmlDocument.Load传递给XmlLoader.Load是空的,这意味着XmlDataSource.PopulateXmlDocument经过一个空读者XmlDocument.Load,其发生时XmlDataSource.GetReader返回NULL。

唯一代码路径,其中发生这种情况要求XmlDataSource.DataFile为空白或空XmlDataSource.Data为null,空的或只有空白字符的成本。

+0

+1 - 您是否从MSDN Docs中获取了该信息? – Josh 2011-02-01 13:17:35