Xamarin链接器:找不到类型为Cirrious.CrossCore.IoC.MvxPropertyInjector的默认构造函数 [英] Xamarin Linker : Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector
问题描述
对于带有HotTuna包中的FirstView的骨架项目,并且将Build链接器行为设置为链接所有程序集",我得到以下错误:
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:找不到类型为Cirrious.CrossCore.IoC.MvxPropertyInjector的默认构造函数
System.MissingMethodException: Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector
对所有MvvmCross使用nuGet软件包v3.1.1(4个软件包)
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)]
使用最新的稳定版本:
在PC上: Xamarin for VS 1.12.278 Xamarin.iOS 1.12.278
On PC: Xamarin for VS 1.12.278 Xamarin.iOS 1.12.278
Mac: Xamarin.iOS 7.2.2.2
Mac: Xamarin.iOS 7.2.2.2
当然,仅具有SDK的链接器行为,它运行良好.有任何建议吗?
Ofcourse with Linker behaviour 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链接器:找不到类型为Cirrious.CrossCore.IoC.MvxPropertyInjector的默认构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!