在 Xamarin.Mac 中,我遇到了下一个异常:
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
当我尝试使用静态方法时:System.Web.HttpUtility.HtmlDecode(string);
,并且仅当 Mono Runtime 包含在 bundle 中时,如果不包含,则效果完美。知道发生了什么吗?
最佳答案
问题可以解决,在方法调用前添加这行代码:System.Web.HttpUtility.HtmlDecode(string);
HttpEncoder.Current = HttpEncoder.Default;
并且可以在此处找到包含更完整解释的错误报告:https://bugzilla.xamarin.com/show_bug.cgi?id=12565
关于mono - System.NullReferenceException : Object reference not set to an instance of an object in System. Web.HttpUtility.HtmlDecode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16922952/