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

标签 mono xamarin monomac xamarin.mac

在 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;

原始答案可以在这里找到:http://forums.xamarin.com/discussion/4805/system-nullreferenceexception-with-system-web-httputility-htmldecode#latest

并且可以在此处找到包含更完整解释的错误报告: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/

相关文章:

.net - x64 mono 是否需要 x64 类库?

macos - 在 Mac 上为 Mono 配置 PKG_CONFIG_PATH

linux - 使用 MONO 编译 - 引用 C# 库的 C#?

android - 在 Android 上,哪种方式最适合服务在 OnResume 上与我的应用程序通信

c# - 将构造函数参数绑定(bind)到 Xamarin.Forms 的 GoogleMaps

xamarin - xamarin 工作室中是否有包管理器控制台

macos - 使用 MonoMac 在 OSX 上进行屏幕捕获?

cocoa - 如何更改将鼠标悬停在应用程序图标上时显示的名称

cocoa - 无法让 NSScrollView 工作

asp.net-web-api - 无法在 Mono/xsp4 中加载类型 'System.Web.Http.WebHost.HttpControllerHandler'