gpt4 book ai didi

c# - Mvvmcross:文件插件错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:58:19 25 4
gpt4 key购买 nike

使用 mvvmCross 文件插件时出现以下错误。我尝试使用使用“File Plugin 3.1.1-beta”的 N-14 代码示例,我得到了错误,我还使用了一个全新的项目,从 nuGet 下载了最新的插件版本,我也得到了同样的错误。

这似乎和这个人遇到的问题是一样的:

https://github.com/MvvmCross/MvvmCross/issues/510

这似乎是错误信息中的主线:

Failed to resolve parameter for parameter fileStore of type IMvxFileStor
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.GetIoCParameterValues (System.Type type, System.Reflection.ConstructorInfo firstConstructor) [0x00000] in <filename unknown>:0

我已经尝试重新启动 xamarin studio 和我的 MacPro 等。我已经使用了位置和信使插件,没有任何问题

请指教

跟踪:

2014-03-17 20:37:44.836 MCOTaxiIOS[2730:60b] TouchNavigation:Diagnostic: 0.56 Navigate requested [0:] TouchNavigation:Diagnostic: 0.56 Navigate requested Resolved pending breakpoint at '/Developer/Projects/MCO/MCO.IOS/Views/FirstView.cs:58,1' to MonoTouch.UIKit.UIViewController MCO.IOS.Views.FirstView.CreateTabFor (string title, string imageName, Cirrious.MvvmCross.ViewModels.IMvxViewModel viewModel) [0x0002f]. [0:] 2014-03-17 20:37:44.875 MCOIOS[2730:60b] mvx:Diagnostic: 0.59 Request is null - assuming this is a TabBar type situation where ViewDidLoad is called during construction... patching the request now - but watch out for problems with virtual calls during construction [0:] mvx:Diagnostic: 0.59 Request is null - assuming this is a TabBar type situation where ViewDidLoad is called during construction... patching the request now - but watch out for problems with virtual calls during construction Resolved pending breakpoint at '/Developer/Projects/MCO/MCO.Common/Services/LocationService.cs:110,1' to void MCO.Common.LocationService.OnError (Cirrious.MvvmCross.Plugins.Location.MvxLocationError error) [0x00001]. [0:] 2014-03-17 20:37:44.917 MCOIOS[2730:60b] mvx:Warning: 0.64 Problem creating viewModel of type FirstViewModel - problem MvxIoCResolveException: Failed to resolve parameter for parameter fileStore of type IMvxFileStore when creating MCO.Common.ViewModels.FirstViewModel at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.GetIoCParameterValues (System.Type type, System.Reflection.ConstructorInfo firstConstructor) [0x00000] in :0 at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type) [0x00000] in :0 at Cirrious.CrossCore.Mvx.IocConstruct (System.Type t) [0x00000] in :0 at Cirrious.MvvmCross.ViewModels.MvxDefaultViewModelLocator.TryLoad (System.Type viewModelType, IMvxBundle parameterValues, IMvxBundle savedState, IMvxViewModel& viewModel) [0x00000] in :0 [0:] mvx:Warning: 0.64 Problem creating viewModel of type FirstViewModel - problem MvxIoCResolveException: Failed to resolve parameter for parameter fileStore of type IMvxFileStore when creating MCO.Common.ViewModels.FirstViewModel at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.GetIoCParameterValues (System.Type type, System.Reflection.ConstructorInfo firstConstructor) [0x00000] in :0 at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type) [0x00000] in :0 at Cirrious.CrossCore.Mvx.IocConstruct (System.Type t) [0x00000] in :0 at Cirrious.MvvmCross.ViewModels.MvxDefaultViewModelLocator.TryLoad (System.Type viewModelType, IMvxBundle parameterValues, IMvxBundle savedState, IMvxViewModel& viewModel) [0x00000] in :0

堆栈跟踪:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Failed to construct and initialize ViewModel for type CollectABull.Core.ViewModels.FirstViewModel from locator MvxDefaultViewModelLocator - check MvxTrace for more information at Cirrious.MvvmCross.ViewModels.MvxViewModelLoader.LoadViewModel (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request, IMvxBundle savedState, IMvxViewModelLocator viewModelLocator) [0x00000] in :0 at Cirrious.MvvmCross.ViewModels.MvxViewModelLoader.LoadViewModel (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request, IMvxBundle savedState) [0x00000] in :0 at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.LoadViewModel (IMvxTouchView touchView) [0x00000] in :0 at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods+<>c_DisplayClass1.b_0 () [0x00000] in :0 at Cirrious.MvvmCross.Views.MvxViewExtensionMethods.OnViewCreate (IMvxView view, System.Func`1 viewModelLoader) [0x00000] in :0 at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.OnViewCreate (IMvxTouchView touchView) [0x00000] in :0 at Cirrious.MvvmCross.Touch.Views.MvxViewControllerAdapter.HandleViewDidLoadCalled (System.Object sender, System.EventArgs e) [0x00000] in :0 at at (wrapper delegate-invoke) :invoke_void_this__object_EventArgs (object,System.EventArgs) at Cirrious.CrossCore.Core.MvxDelegateExtensionMethods.Raise (System.EventHandler eventHandler, System.Object sender) [0x00000] in :0 at Cirrious.CrossCore.Touch.Views.MvxEventSourceTabBarController.ViewDidLoad () [0x00000] in :0 at MCO.IOS.Views.FirstView.ViewDidLoad () [0x00002] in /Developer/Projects/MCO/MCO.IOS/Views/FirstView.cs:26 at MCO.IOS.Views.FirstView..ctor () [0x0000f] in /Developer/Projects/MCO/MCO.IOS/Views/FirstView.cs:18 at at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:537

最佳答案

MvvmCross 插件通常分为两部分。核心 PCL 项目中有接口(interface)。然后是平台特定的实现:Android、iOS 等。

如果查看 NuGet 包,您会看到各种平台目标。 NuGet 将根据您的项目类型引用正确的程序集。

MvvmCross 使用 IoC 在运行时注入(inject)依赖项。您的 ViewModel 将引用 IFileStore,而 MvvmCross 将在构建 ViewModel 时尝试解决该依赖关系。

但是,MvvmCross 只能在接口(interface)的具体实现已经注册的情况下解析它。通常,您会在 App.Initialize 中使用代码来注册所有以“Service”结尾的类型。您还可以显式注册类型。

由于插件有共同的模式,MvvmCross 支持在启动时自动注册插件。它的方法是通过 NuGet 添加到平台特定项目的 Bootstrap 文件。这通常看起来像:

public class FilePluginBootstrap
: MvxPluginBootstrapAction<Cirrious.MvvmCross.Plugins.File.PluginLoader>
{
}

在启动时,MvvmCross 寻找所有实现IMvxBootstrapAction 的类型。每个插件还有一个 PluginLoader 类,用于在 MvvmCross 中注册类型。像这样:

public class Plugin
: IMvxPlugin
{
public void Load()
{
Mvx.RegisterType<IMvxFileStore, MvxTouchFileStore>();
}
}

如您所见,通过在 Core PCL 项目和您的平台特定项目中安装插件包,MvvmCross 拥有所有部件以自动在 IoC 容器中注册实现。

TL;DR:确保您在 Core PCL 和平台特定项目中都安装了您的插件。

关于c# - Mvvmcross:文件插件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22465070/

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