gpt4 book ai didi

c# - MVVX无法从MvxDefaultViewModelLocator初始化ViewModel

转载 作者:太空宇宙 更新时间:2023-11-03 13:12:57 24 4
gpt4 key购买 nike

我正在尝试使用mvvx创建一个移动应用程序。
尝试运行Droid应用程序时出现以下错误。
mvvmcross.platform.exceptions.mvxexception:未能为totheday.viewmodels.loginviewmodel类型从定位器mvxdefaultviewmodelocator构造和初始化viewmodel-有关详细信息,请检查innerexception
下面是内部异常的详细信息。
mvvmcross.platform.exceptions.mvxexception:未能为totheday.viewmodels.loginviewmodel类型从定位器mvxdefaultviewmodelocator构造和初始化viewmodel-有关详细信息,请检查内部异常-->mvvmcross.platform.exceptions.mvxexception:创建viewmodel时出现问题类型为loginviewmodel的-->mvvmcross.platform.exceptions.mvxiocresolveexception:在创建thoughtoftheday.viewmodels.loginviewmodel时未能解析imvxmessenger类型的参数messenger的参数
在mvvmcross.platform.ioc.mvxsimpleioccontainer.getiocparametervalues(system.type type,system.reflection.constructorinfo firstconstructor)[0x00036]上,位于d:\ git\mvvmcross\mvvmcross\platform\platform\ioc\mvxsimpleioccontainer.cs:504
位于d:\ git\mvvmcross\mvvmcross\platform\platform\ioc\mvxsimpleioccontainer.cs:314中的mvvmcross.platform.ioc.mvxsimpleioccontainer.iocconstruct(system.type type)[0x0002a]
在mvvmcross.platform.mvx.iocconstruct(system.type t)[0x00005]上,位于d:\ git\mvvmcross\mvvmcross\platform\platform\mvx.cs:170
在mvvmcross.core.viewmodels.mvxdefaultviewmodellocator.load(system.type viewmodeltype,mvvmcross.core.viewmodels.imvxbundle parametervalues,mvvmcross.core.viewmodels.imvxbundle savedstate)[0x00000]上
---内部异常堆栈跟踪结束---
在mvvmcross.core.viewmodels.mvxdefaultviewmodellocator.load(system.type viewmodeltype,mvvmcross.core.viewmodels.imvxbundle parametervalues,mvvmcross.core.viewmodels.imvxbundle savedstate)[0x00027]上
在mvvmcross.core.viewmodelloader.loadviewmodel(mvvmcross.core.viewmodels.mvxviewmodelrequest请求,mvvmcross.core.viewmodels.imvxbundle savedstate,mvvmcross.core.viewmodels.imvxviewmodellocator viewmodellocator)[0x00015]中<69bce0378e8e413982d352d7e387a8>:0
---内部异常堆栈跟踪结束---
在mvvmcross.core.viewmodelloader.loadviewmodel(mvvmcross.core.viewmodels.mvxviewmodelrequest请求,mvvmcross.core.viewmodels.imvxbundle savedstate,mvvmcross.core.viewmodels.imvxviewmodellocator viewmodellocator)[0x00046]中<69bce0378e8e413982d352d7e387a8>:0
在mvvmcross.core.viewmodelloader.loadviewmodel(mvvmcross.core.viewmodels.mvxviewmodelrequest请求,mvvmcross.core.viewmodels.imvxbundle savedstate)[0x00020]中<69bce0378e8e413982d352d7e387a8>:0
在mvvmcross.droid.views.mvxandroidviewscontainer.viewmodelfromrequest处(mvvmcross.core.viewmodelrequest viewmodelrequest,mvvmcross.core.viewmodels.imvxbundle savedstate)[0x00005]输入:0
在0中的mvvmcross.droid.views.mvxandroidviewscontainer.createviewmodelfromintent(android.content.intent intent,mvvmcross.core.viewmodels.imvxbundle savedstate)[0x00027]处
在mvvmcross.droid.views.mvxandroidviewscontainer.load(android.content.intent intent,mvvmcross.core.viewmodels.imvxbundle savedstate,system.type viewmodeltypehint)[0x00089]输入:0
在mvvmcross.droid.views.mvxactivityviewextensions.loadviewmodel(mvvmcross.droid.views.imvxandroidview androidview,mvvmcross.core.viewmodels.imvxbundle savedstate)[0x0006a]位置:0
在mvvmcross.droid.views.mvxactivityviewextensions+<>c_u displayClass1_u 0.b_u 1()[0x0000a]中:0
在mvvmcross.core.views.mvxviewextensionmethods.onviewcreate(mvvmcross.core.views.imvxview view view,system.func1[TResult] viewModelLoader) [0x00012] in <69bce0378e8e413982d3b552d7e387a8>:0
at MvvmCross.Droid.Views.MvxActivityViewExtensions.OnViewCreate (MvvmCross.Droid.Views.IMvxAndroidView androidView, Android.OS.Bundle bundle) [0x00062] in <f6aebf863dc84be7b380cfec8d459508>:0
at MvvmCross.Droid.Views.MvxActivityAdapter.EventSourceOnCreateCalled (System.Object sender, MvvmCross.Platform.Core.MvxValueEventArgs
1[t]eventargs)[0x0000c]中:0
在(包装器委托调用)system.eventhandler1[MvvmCross.Platform.Core.MvxValueEventArgs1[android.os.bundle]]:调用void\u object\u teventargs(object,mvvmcross.platform.core.mvxvalueeventargs1<Android.OS.Bundle>)
at MvvmCross.Platform.Core.MvxDelegateExtensionMethods.Raise[T] (System.EventHandler
1[teventargs]eventhandler,system.object sender,t value)[0x00000],位于d:\ git\mvvmcross\mvvmcross\platform\platform\core\mvxdelegateextension方法:cs:21
在<4230cf00b647458f9b3e211590e6cc9d>中的mvvmcross.platform.droid.views.mvxeventsourceactivity.oncreate(android.os.bundle bundle)[0x00014]:0
在Thoughtotheday.droid.views.loginview.oncreate(android.os.bundle bundle)[0x00002]中,位于C:\Work\Mobiledev\Thoughtotheday\thoughttotheday.droid\views\loginview.cs:15
我正试图将imvxmessenger传递到视图模型。上面的内部异常消息显示解决IMVxMessenger时出现问题。我需要在app.cs\initialize()中包含一些内容吗?如果你需要更多的信息请告诉我。非常感谢你的时间和帮助。

public LoginViewModel(IMvxMessenger messenger,
IDialogService dialogService,
IUserService userService)
: base(messenger)
{
_userService = userService;
_dialogService = dialogService;
}

enter image description here
解决方案:在android项目中也为mvvmcross.plugin.messenger安装了nuget包。
之前我只在PCL项目中安装了它。

最佳答案

解决方案:在android项目中也为mvvmcross.plugin.messenger安装了nuget包。之前我只在PCL项目中安装了它。

关于c# - MVVX无法从MvxDefaultViewModelLocator初始化ViewModel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41419280/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com