Xamarin链接器:找不到类型为Cirrious.CrossCore.IoC.MvxPropertyInjector的默认构造函数(Xamarin Linker : Default construc

编程入门 行业动态 更新时间:2024-10-27 22:28:51
Xamarin链接器:找不到类型为Cirrious.CrossCore.IoC.MvxPropertyInjector的默认构造函数(Xamarin Linker : Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector)

使用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.MvxPropertyInjector

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 (); }

Next error is:

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

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.

Final Error:

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

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

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.

更多推荐

本文发布于:2023-07-04 10:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   函数   类型   链接   CrossCore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!