2

I have inherited some code where a call like:

var test = HttpUtility.HtmlDecode("google");

causes a stackoverflow. A call to WebUtility.HtmlDecode in the same place works fine. I've Googled around but not found anything about why this might be happening.

It is not a web application - and I see MSDN says to use WebUtility in this case - but other sources say I can just add a ref to System.Web and it will work fine - e.g. C# HTMLDecode without System.Web possible? I have built a test app and the same call to HtmlDecode works fine.

The stack trace is:

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

I'd like to understand the source of the problem if anyone knows the answer!

2
  • Isn't the nature of a stackoverflow that you don't get a stack trace? The stack trace you provide doesn't look very "overflowy". Commented Apr 15, 2016 at 11:28
  • Maybe it is a feature of VS2015 - I definitely have both an overflow exception and a stack trace! Commented Apr 19, 2016 at 11:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.