天天看点

IIS 访问出现 EntityName 时出错读取xml文件"分析 EntityName 时出错"的解决方案

“/”应用程序中的服务器错误。

--------------------------------------------------------------------------------

分析 EntityName 时出错。 第 20 行,位置 22。 

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.Xml.XmlException: 分析 EntityName 时出错。 第 20 行,位置 22。

源错误: 

执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  

堆栈跟踪: 

[XmlException: 分析 EntityName 时出错。 第 20 行,位置 22。]

   System.Xml.XmlTextReaderImpl.Throw(String res, String arg) +195

   System.Xml.XmlTextReaderImpl.ParseEntityName() +3401923

   System.Xml.XmlTextReaderImpl.ParseEntityReference() +64

   System.Xml.XmlTextReaderImpl.Read() +7409741

   System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) +101

   System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +74

   System.Xml.XmlDocument.Load(XmlReader reader) +144

   System.Xml.XmlDocument.Load(String filename) +205

   ZinEngine.Framework.ZinConfiguration..ctor(String path) +112

   Patrix.Web.PatrixConfig.Register(String path) +1852

   Patrix.Web.Global.Application_Start() +507

[HttpException (0x80004005): 分析 EntityName 时出错。 第 20 行,位置 22。]

   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12584905

   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175

   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304

   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404

   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12601936

   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159

   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12441597

版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.34009 

查询原因得知以上都是因为配置文件里DB的密码出现了特殊字符引起的

处理方法为: 替换编码或者重新更改密码,最好是更改一个不含特殊字符的密码

 在涉及到xml与xslt编程的过程中,经常会碰到"分析 EntityName 时出错"的提示,这个不是程序错误,是因为xml文件中使用了一些特殊符号导致的。

    XML 节点中不能包含这些特殊字符,“&”,“<”,“>”,不然解析时此XML会报错,如果你配置文件中的节点内容包含了下面特殊符号,请用对应替换编码替换掉即可。

特殊字符

特殊含义

替换编码

>

>  

<

< 

"

双引号 

 "

'

 单引号

' 

&

"&"字符 

&  

本文转自 holy2009 51CTO博客,原文链接:http://blog.51cto.com/holy2010/1948186