【问题标题】:Xamarin.iOS - Error processing Custom Renderer methodXamarin.iOS - 处理自定义渲染器方法时出错
【发布时间】:2021-06-22 14:27:09
【问题描述】:

我一直在尝试使用 Visual Studio 和“与 Mac 配对”功能为 IOS 归档构建。 但是,当我尝试进行发布构建时,出现此错误:

处理程序集“TextFlowMobile.iOS.exe”中的方法“System.Void ProjectName.iOS.Renderers.IOSWebViewRenderer::.ctor()”时出错:对象引用未设置为对象 TextFlowMobile.iOS 的实例

我的这个渲染器的代码,也就是 WKWebView 的代码如下:

namespace TextFlowMobile.iOS.Renderers
{
    public class IOSWebViewRenderer : WkWebViewRenderer
    {
        public override WKNavigation LoadHtmlString(NSString htmlString, NSUrl baseUrl)
        {
            try
            {
                if(htmlString != null && baseUrl != null)
                {
                    // Add additional HTML to ensure fonts scale correctly and don't appear extremely small and almost unreadable
                    var iOSHtmlWithScaling = htmlString.ToString().Insert(0, "<meta name='viewport' content='width=device-width,initial-scale=1,maximum-scale=1' />");
                    return base.LoadHtmlString((NSString)iOSHtmlWithScaling, baseUrl);
                }
                else
                {
                    return base.LoadHtmlString(htmlString, baseUrl);
                }
            }
            catch (Exception)
            {
                //System.Diagnostics.Debug.WriteLine(ex);
                return base.LoadHtmlString(htmlString, baseUrl);
            }
        }
    }
}

如您所见,我根本没有重写构造函数。我真的不明白为什么会发生这种情况,特别是因为它构建(并部署在连接的 Mac 上的模拟器上)非常适合调试。

我当前的配置是 Release |苹果手机 |项目名称.iOS |远程设备

非常感谢任何帮助!

【问题讨论】:

  • 将 XF 升级到最新版本。

标签: xamarin.forms deployment xamarin.ios release custom-renderer


【解决方案1】:

发生此错误是因为我在代码的发布版本上运行了混淆器。当我尝试存档时,我想它无法正确编译这个渲染器,因为它被混淆了。

【讨论】:

    猜你喜欢
    • 2017-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-24
    • 1970-01-01
    • 1970-01-01
    • 2017-06-09
    相关资源
    最近更新 更多