Xamarin 链接器:未找到 Crillous.CrossCore.IoC.MvxPropertyInjector 类型的默认构造函数 [英] Xamarin Linker : Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector

查看:22
本文介绍了Xamarin 链接器:未找到 Crillous.CrossCore.IoC.MvxPropertyInjector 类型的默认构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 HotTuna 包中的 FirstView 框架项目,并将构建链接器行为设置为链接所有程序集",我收到以下错误:

With a skeleton project with FirstView from HotTuna package, and with Build linker behavior set to "Link all assemblies", I get the following error:

System.MissingMethodException: 未找到 Crillous.CrossCore.IoC.MvxPropertyInjector 类型的默认构造函数

System.MissingMethodException: Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector

对所有 MvvmCross(4 个包)使用 NuGet 包 v3.1.1

Using NuGet package v3.1.1 for all MvvmCross (4 packages)

LinkerPleaseInclude 文件确实有一行[MonoTouch.Foundation.Preserve(AllMembers = true)]

LinkerPleaseInclude file does have the line [MonoTouch.Foundation.Preserve(AllMembers = true)]

使用最新的稳定版本:

在电脑上:适用于 VS 1.12.278 的 XamarinXamarin.iOS 1.12.278

On PC: Xamarin for VS 1.12.278 Xamarin.iOS 1.12.278

麦克:Xamarin.iOS 7.2.2.2

Mac: Xamarin.iOS 7.2.2.2

当然,仅使用 SDK 的链接器行为,它运行良好.任何人有什么建议吗?

Of course with Linker behavior of SDK only, it runs fine. Any suggestions anyone?

推荐答案

已解决;所以,在基础项目中,连续出现了三个错误,顺序如下:

Solved; So, with the basic project, there were three consecutive errors in the following order:

System.MissingMethodException: Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector

  • 可以通过--linkskip=Cirrious.Core(丑陋)或通过在LinkerPleaseInclude.cs中包含以下内容来解决

    • can be resolved either by --linkskip=Cirrious.Core (ugly), or by including the following in LinkerPleaseInclude.cs

      public void Include(MvxPropertyInjector injector){
          injector = new MvxPropertyInjector ();
      } 
      

    • 下一个错误是:

          Cirrious.CrossCore.Exceptions.MvxException: Failed to construct and initialize ViewModel for type {0} from locator MvxDefaultViewModelLocator - check MvxTrace for more information
      

      这个很难;简单的修复当然是做一个 --linkskip=portableLibrary,或者在某处创建一个 ViewModel 的实例(可能在 LinkerPleaseInclude.cs 中);至少在我的情况下,第二种方法的问题是,我的大多数 VM 没有无参数构造函数,显然在这种情况下使用 IOC 无济于事.

      This one is difficult; Simple fix is to ofcourse to do a --linkskip=portableLibrary, or to crate an instance of the ViewModel somewhere (perhaps in LinkerPleaseInclude.cs); problem with the second approach at-least in my case is, most of my VM doesn't have a parameter less constructor, and obviously using IOC in this case wouldn't help.

      最终错误:

      System.ArgumentNullException: missing source event info in MvxWeakEventSubscription
      Parameter name: sourceEventInfo
      

      要么使用--linkskip=System(丑陋),要么将以下内容添加到LinkerPleaseInclude.cs

      Either use --linkskip=System (ugly), or add the following to LinkerPleaseInclude.cs

          public void Include(INotifyPropertyChanged changed)
          {
              changed.PropertyChanged += (sender, e) =>  {
                  var test = e.PropertyName;
              };
          }
      

      这足以让我的基本项目使用 LinkAllAssemblies、使用 LLVM 优化器和使用 SGen 收集器运行.

      This was enough for my basic project to run with LinkAllAssemblies, Using LLVM optimizer, and Use SGen collector.

      希望这能帮助任何寻求解决方案的人.

      Hope this will help anyone looking for a solution.

      这篇关于Xamarin 链接器:未找到 Crillous.CrossCore.IoC.MvxPropertyInjector 类型的默认构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆