System.NullReferenceException: Object reference not set to an instance of an object in System.Web.HttpUtility.HtmlDecode

StackOverflow https://stackoverflow.com/questions/16922952

سؤال

In Xamarin.Mac i get the next exception:

Unhandled Exception:
    System.NullReferenceException: Object reference not set to an instance of an object
      at System.Web.Util.HttpEncoder.GetCustomEncoderFromConfig () [0x00000] in <filename unknown>:0 
      at System.Lazy`1[System.Web.Util.HttpEncoder].InitValue () [0x00000] in <filename unknown>:0 
    [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
      at System.Web.Util.HttpEncoder.GetCustomEncoderFromConfig () [0x00000] in <filename unknown>:0 
      at System.Lazy`1[System.Web.Util.HttpEncoder].InitValue () [0x00000] in <filename unknown>:0 

When i try to use the static method: System.Web.HttpUtility.HtmlDecode(string);, and only if the Mono Runtime is included in the bundle, when is not included, works perfect. Any idea of what is happening?

هل كانت مفيدة؟

المحلول

The problem can be solved, adding this line of code before the call of the method: System.Web.HttpUtility.HtmlDecode(string);

HttpEncoder.Current = HttpEncoder.Default;

The original answare can be found here: http://forums.xamarin.com/discussion/4805/system-nullreferenceexception-with-system-web-httputility-htmldecode#latest

And the report of the bug with a more complete explanation, can be found here: https://bugzilla.xamarin.com/show_bug.cgi?id=12565

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top