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