使用HotTuna软件包中的FirstView构建骨架项目,并将Build链接器行为设置为“链接所有程序集”时,出现以下错误:
System.MissingMethodException:找不到类型Cirrious.CrossCore.IoC.MvxPropertyInjector的默认构造函数
对所有MvvmCross使用nuGet软件包v3.1.1(4个软件包)
LinkerPleaseInclude文件确实有[MonoTouch.Foundation.Preserve(AllMembers = true)]行
使用最新的稳定版本:
在PC上:Xamarin for VS 1.12.278 Xamarin.iOS 1.12.278
Mac:Xamarin.iOS 7.2.2.2
只有SDK的链接器行为,它运行良好。 有人建议吗?
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: Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector
Using nuGet package v3.1.1 for all MvvmCross (4 packages)
LinkerPleaseInclude file does have the line [MonoTouch.Foundation.Preserve(AllMembers = true)]
Using latest stable build:
On PC: Xamarin for VS 1.12.278 Xamarin.iOS 1.12.278
Mac: Xamarin.iOS 7.2.2.2
Ofcourse with Linker behaviour of SDK only, it runs fine. Any suggestions anyone?
最满意答案
解决了; 因此,对于基本项目,按以下顺序连续出现三个错误:
System.MissingMethodException: Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector可以通过--linkskip = Cirrious.Core(丑陋)或在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,或者在某处(或许在LinkerPleaseInclude.cs中)创建一个ViewModel的实例; 至少在我的情况下,第二种方法的问题是,我的大多数VM没有参数较少的构造函数,显然在这种情况下使用IOC无济于事。
最终错误:
System.ArgumentNullException: missing source event info in MvxWeakEventSubscription Parameter name: sourceEventInfo使用--linkskip = System(丑陋),或将以下内容添加到LinkerPleaseInclude.cs中
public void Include(INotifyPropertyChanged changed) { changed.PropertyChanged += (sender, e) => { var test = e.PropertyName; }; }这足以让我的基本项目能够运行LinkAllAssemblies,使用LLVM优化器和使用SGen收集器。
希望这会帮助任何寻找解决方案的人。
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.MvxPropertyInjectorcan be resolved either by --linkskip=Cirrious.Core (ugly), or by including the following in LinkerPleaseInclude.cs
public void Include(MvxPropertyInjector injector){ injector = new MvxPropertyInjector (); }Next error is:
Cirrious.CrossCore.Exceptions.MvxException: Failed to construct and initialize ViewModel for type {0} from locator MvxDefaultViewModelLocator - check MvxTrace for more informationThis 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.
Final Error:
System.ArgumentNullException: missing source event info in MvxWeakEventSubscription Parameter name: sourceEventInfoEither use --linkskip=System (ugly), or add the following to LinkerPleaseInclude.cs
public void Include(INotifyPropertyChanged changed) { changed.PropertyChanged += (sender, e) => { var test = e.PropertyName; }; }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.
更多推荐
发布评论