C# 调用System.Web.HttpUtility.HtmlCode抛出StackOverflowException

C# 调用System.Web.HttpUtility.HtmlCode抛出StackOverflowException,c#,html,stack-overflow,system.web,C#,Html,Stack Overflow,System.web,我继承了一些代码,其中调用如下: var test = HttpUtility.HtmlDecode("google"); 导致堆栈溢出。在同一位置调用WebUtility.HtmlDecode可以正常工作。我在谷歌上搜索过,但没有找到任何关于为什么会发生这种情况的信息 它不是一个web应用程序——我看到有人说在这种情况下使用WebUtility——但其他来源说,我可以只向System.web添加一个引用,它会工作得很好——例如,我已经构建了一个测试应用程序,对HtmlDecode的相同调用也

我继承了一些代码,其中调用如下:

var test = HttpUtility.HtmlDecode("google");
导致堆栈溢出。在同一位置调用WebUtility.HtmlDecode可以正常工作。我在谷歌上搜索过,但没有找到任何关于为什么会发生这种情况的信息

它不是一个web应用程序——我看到有人说在这种情况下使用WebUtility——但其他来源说,我可以只向System.web添加一个引用,它会工作得很好——例如,我已经构建了一个测试应用程序,对HtmlDecode的相同调用也可以工作得很好

堆栈跟踪是:

System.Web.dll!System.Web.HttpRuntime.StaticInit()  Unknown
System.Web.dll!System.Web.HttpRuntime.HttpRuntime() Unknown
[Native to Managed Transition]  
[Managed to Native Transition]  
System.Web.dll!System.Web.HttpRuntime.FusionInited.get()    Unknown
System.Web.dll!System.Web.Compilation.BuildManager.InitializeBuildManager() Unknown
System.Web.dll!System.Web.Compilation.BuildManager.GetType(string typeName = "System.Web.Util.HttpEncoder", bool throwOnError = true, bool ignoreCase = false)  Unknown
System.Web.dll!System.Web.Configuration.ConfigUtil.GetType(string typeName = "System.Web.Util.HttpEncoder", string propertyName = "encoderType", System.Configuration.ConfigurationElement configElement = {System.Web.Configuration.HttpRuntimeSection}, System.Xml.XmlNode node = null, bool checkAptcaBit = true, bool ignoreCase = false)   Unknown
System.Web.dll!System.Web.Configuration.ConfigUtil.GetType(string typeName = "System.Web.Util.HttpEncoder", string propertyName = "encoderType", System.Configuration.ConfigurationElement configElement = {System.Web.Configuration.HttpRuntimeSection}, bool checkAptcaBit = true, bool ignoreCase = false)   Unknown
System.Web.dll!System.Web.Configuration.ConfigUtil.GetType(string typeName = "System.Web.Util.HttpEncoder", string propertyName = "encoderType", System.Configuration.ConfigurationElement configElement = {System.Web.Configuration.HttpRuntimeSection}, bool checkAptcaBit = true)    Unknown
System.Web.dll!System.Web.Configuration.ConfigUtil.GetType(string typeName = "System.Web.Util.HttpEncoder", string propertyName = "encoderType", System.Configuration.ConfigurationElement configElement = {System.Web.Configuration.HttpRuntimeSection})   Unknown
System.Web.dll!System.Web.Util.HttpEncoder.GetCustomEncoderFromConfig() Unknown
mscorlib.dll!System.Lazy<System.Web.Util.HttpEncoder>.CreateValue() Unknown
mscorlib.dll!System.Lazy<System.Web.Util.HttpEncoder>.LazyInitValue()   Unknown
mscorlib.dll!System.Lazy<System.Web.Util.HttpEncoder>.Value.get()   Unknown
System.Web.dll!System.Web.Util.HttpEncoder.Current.get()    Unknown
System.Web.dll!System.Web.HttpUtility.HtmlDecode(string s = "Google")   Unknown
System.Web.dll!System.Web.HttpRuntime.StaticInit()未知
System.Web.dll!System.Web.HttpRuntime.HttpRuntime()未知
[本机到托管转换]
[管理到本机转换]
System.Web.dll!System.Web.HttpRuntime.FusionInited.get()未知
System.Web.dll!System.Web.Compilation.BuildManager.InitializeBuildManager()未知
System.Web.dll!System.Web.Compilation.BuildManager.GetType(string typeName=“System.Web.Util.HttpEncoder”,bool throwOnError=true,bool ignoreCase=false)未知
System.Web.dll!System.Web.Configuration.ConfigUtil.GetType(string typeName=“System.Web.Util.HttpEncoder”,string propertyName=“encoderType”,System.Configuration.ConfigurationElement configElement={System.Web.Configuration.HttpRuntimeSection},System.Xml.XmlNode节点=null,bool checkAptcaBit=true,bool ignoreCase=false)未知
System.Web.dll!System.Web.Configuration.ConfigUtil.GetType(string typeName=“System.Web.Util.HttpEncoder”,string propertyName=“encoderType”,System.Configuration.ConfigurationElement configElement={System.Web.Configuration.HttpRuntimeSection},bool checkAptcaBit=true,bool ignoreCase=false)未知
System.Web.dll!System.Web.Configuration.ConfigUtil.GetType(string typeName=“System.Web.Util.HttpEncoder”,string propertyName=“encoderType”,System.Configuration.ConfigurationElement configElement={System.Web.Configuration.HttpRuntimeSection},bool checkAptcaBit=true)未知
System.Web.dll!System.Web.Configuration.ConfigUtil.GetType(string typeName=“System.Web.Util.HttpEncoder”,string propertyName=“encoderType”,System.Configuration.ConfigurationElement configElement={System.Web.Configuration.HttpRuntimeSection})未知
System.Web.dll!System.Web.Util.HttpEncoder.GetCustomEncoderFromConfig()未知
mscorlib.dll!System.Lazy.CreateValue()未知
mscorlib.dll!System.Lazy.LazyInitValue()未知
mscorlib.dll!System.Lazy.Value.get()未知
System.Web.dll!System.Web.Util.HttpEncoder.Current.get()未知
System.Web.dll!System.Web.HttpUtility.HtmlDecode(string s=“Google”)未知

如果有人知道答案,我想了解问题的根源

stackoverflow的本质不是没有堆栈跟踪吗?您提供的堆栈跟踪看起来不太“溢出”。可能这是VS2015的一个功能-我肯定有溢出异常和堆栈跟踪!stackoverflow的本质不是没有堆栈跟踪吗?您提供的堆栈跟踪看起来不太“溢出”。可能这是VS2015的一个功能-我肯定有溢出异常和堆栈跟踪!