简体   繁体   English

Mvvmcross:文件插件错误

[英]Mvvmcross: File Plugin error

When using the mvvmCross File Plugin I am getting the below error. 使用mvvmCross文件插件时,我收到以下错误。 I tried using the N-14 code sample which uses "File Plugin 3.1.1-beta" and I get the error and I also use a fresh new project, downloading the lastest plugin version from nuGet and I also get the same error. 我尝试使用N-14代码示例,它使用“File Plugin 3.1.1-beta”,我得到错误,我也使用了一个全新的项目,从nuGet下载最新的插件版本,我也得到了同样的错误。

This seems to be the same problem as this guy had: 这似乎与这个家伙有同样的问题:

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

This seems to be the main line in the error message: 这似乎是错误消息中的主线:

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 

I have tried re-starting xamarin studio and my MacPro etc. I have used the location and messenger plugins without any issues 我已经尝试重新启动xamarin工作室和我的MacPro等。我使用了位置和信使插件没有任何问题

Please advise 请指教

Trace: 跟踪:

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]. 2014-03-17 20:37:44.836 MCOTaxiIOS [2730:60b] TouchNavigation:Diagnostic:0.56 Navigate requested [0:] TouchNavigation:Diagnostic:0.56在'/Developer/Projects/MCO/MCO.IOS/导航请求已解决的待处理断点Views / FirstView.cs:58,1'到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.875 MCOIOS [2730:60b] mvx:诊断:0.59请求为空 - 假设这是一个TabBar类型的情况,其中在构造期间调用ViewDidLoad ...现在修补请求 - 但请注意构造期间虚拟调用的问题[0:] mvx:诊断:0.59请求为空 - 假设这是一个TabBar类型的情况,其中在构造期间调用ViewDidLoad ...现在修补请求 - 但要注意问题构造期间的虚拟调用在'/Developer/Projects/MCO/MCO.Common/Services/LocationService.cs:110,1'中解决了挂起的断点,以使MCO.Common.LocationService.OnError无效(Cirrious.MvvmCross.Plugins.Location.MvxLocationError错误) )[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.ViewMode [0:] 2014-03-17 20:37:44.917 MCOIOS [2730:60b] mvx:警告:0.64创建类型为FirstViewModel的viewModel时遇到问题 - 问题MvxIoCResolveException:创建MCO.Common时,无法解析IMvxFileStore类型的参数fileStore的参数.ViewModels.FirstViewModel在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]在:0在Cirrious.CrossCore.Mvx.IocConstruct(System.Type的吨)[0x00000]中:0在Cirrious.MvvmCross.ViewModels.MvxDefaultViewModelLocator.TryLoad(System.Type的viewModelType,IMvxBundle的parameterValues,IMvxBundle savedState,IMvxViewModel&视图模型) [0x00000] in:0 [0:] mvx:警告:0.64创建类型为FirstViewModel的viewModel时出现问题 - 问题MvxIoCResolveException:创建MCO.Common.ViewMode时,无法解析类型为IMvxFileStore的参数fileStore的参数 ls.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 ls.FirstViewModel在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在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

Stack trace: 堆栈跟踪:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.TargetInvocationException:调用目标抛出了异常。 ---> 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.O ---> System.Exception:无法从定位器MvxDefaultViewModelLocator为类型CollectABull.Core.ViewModels.FirstViewModel构造和初始化ViewModel - 有关更多信息,请查看MvxTrace在Cirrious.MvvmCross.ViewModels.MvxViewModelLoader.LoadViewModel(Cirrious.MvvmCross.ViewModels.MvxViewModelRequest)请求,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]中:0在Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods + <> C_ DisplayClass1.b _0()[0x00000]中:0在Cirrious.MvvmCross.Views.MvxViewExtensionMethods.OnViewCreate (IMvxView视图,System.Func`1 viewModelLoader)[0x00000] in:0 at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.O nViewCreate (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/M nViewCreate(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_ __object_EventArgs(对象,System.EventArgs)在Cirrious.CrossCore.Core.MvxDelegateExtensionMethods.Raise(System.EventHandler事件处理程序,System.Object的发送者)[0x00000]中:0在Cirrious.CrossCore.Touch.Views.MvxEventSourceTabBarController.ViewDidLoad() [0x00000] in:0处的MCO.IOS.Views.FirstView.ViewDidLoad()[0x00002]位于/Developer/Projects/MCO/MCO.IOS/Views/FirstView.cs:26,位于MCO.IOS.Views.FirstView .. ctor()[0x0000f]位于/Developer/Projects/MCO/MCO.IOS/Views/FirstView.cs:18 at(包装器托管到本机)System.Reflection.MonoCMethod:InternalInvoke(System.Reflection.MonoCMethod,object / Developer / M中的System.Reflection.MonoCMethod.InternalInvoke(System.Object obj,System.Object [] parameters)[0x00002]中的,object [],System.Exception&) onoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:537 onoTouch /源/单声道/ MCS /类/ corlib /的System.Reflection / MonoMethod.cs:537

MvvmCross plugins typically come in 2 parts. MvvmCross插件通常分为两部分。 There is the interface that goes in the core PCL project. 核心PCL项目中有接口。 Then there are the platform specific implementations: Android, iOS, etc. 然后是平台特定的实现:Android,iOS等。

If you look in the NuGet package, you will see various platform targets. 如果您查看NuGet包,您将看到各种平台目标。 NuGet will reference the correct assembly based on your project type. NuGet将根据您的项目类型引用正确的程序集。

MvvmCross uses IoC to inject dependencies at run-time. MvvmCross使用IoC在运行时注入依赖项。 Your ViewModel will take a reference to IFileStore and MvvmCross will try to resolve that dependency when constructing the ViewModel. 您的ViewModel将引用IFileStore ,MvvmCross将在构造ViewModel时尝试解析该依赖关系。

However, MvvmCross can only resolve it if a specific implementation of the interface has been registered. 但是,如果已注册接口的特定实现,MvvmCross只能解析它。 Normally you would have code in App.Initialize to register all types ending with "Service". 通常,您可以在App.Initialize使用代码来注册以“Service”结尾的所有类型。 You can also explicitly register types. 您还可以显式注册类型。

Since plugins have a common pattern, MvvmCross has support to automatically register plugins at startup. 由于插件具有通用模式,因此MvvmCross支持在启动时自动注册插件。 The way it does this is via a Bootstrap file that is added to the platform specific project by NuGet. 它的方式是通过NuGet添加到平台特定项目的Bootstrap文件。 This typically looks like: 这通常看起来像:

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

At startup, MvvmCross looks for all types that implement IMvxBootstrapAction . 在启动时,MvvmCross会查找实现IMvxBootstrapAction所有类型。 Each plugin also has a PluginLoader class that registers the type in MvvmCross. 每个插件还有一个PluginLoader类,用于在MvvmCross中注册该类型。 Something like this: 像这样的东西:

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

So as you can see, by installing the plugin package in both the Core PCL project as well as your platform specific project, MvvmCross has all the parts in place to automatically register the implementation in the IoC container. 正如您所看到的,通过在Core PCL项目以及特定于平台的项目中安装插件包,MvvmCross具有所有部件,可以自动在IoC容器中注册实现。

TL;DR: Make sure you install your plugins in both Core PCL and platform specific projects. TL; DR:确保在Core PCL和平台特定项目中安装插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM