无法运行MVVMcros Xamarin.Forms项目

时间:2017-06-11 18:48:51

标签: xamarin xamarin.forms mvvmcross

我正在尝试配置MVVMCrosswith Xamarin.Forms。所以我正在创建XF项目,为视图模型添加了另一个PCL项目。接下来我正在安装所需的MVVMCross nugets,包括Mvvmcross.StarterPack,MVVMCross.Forms和MVVMCross.Presentation。然后我在自动创建的垃圾箱中清理项目。一切都在建设。但是当我在构建时将XF MainPage.xaml ContentPage更改为MvxContentPage时,会出现以下错误:

    The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'StormFinder, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'StormFinder.dll'
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() StormFinder.Android     

StormFinder是我的XF UI项目。我已经尝试了一切,包括清洁,重新安装XF,MVVMCross甚至开始新项目。

我该怎么办? 编辑: 项目可以在那里找到:https://github.com/straiser/StormFinder

EDIT2: 在xaml中它是错误的命名空间。项目正在建设中,但现在我又遇到了另一个错误:

 System.TypeLoadException: Parent class vtable failed to initialize, due to: Type MvvmCross.Forms.Presenter.Core.MvxFormsPagePresenter has invalid vtable method slot 7 with method MvvmCross.Core.Views.MvxViewPresenter:Close (MvvmCross.Core.ViewModels.IMvxViewModel) assembly:/storage/emulated/0/Android/data/StormFinder.Android/files/.__override__/MvvmCross.Forms.Presenter.Core.dll type:MvxFormsPagePresenter member:<none>
06-12 18:52:19.744 E/mono-rt ( 1784): [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Parent class vtable failed to initialize, due to: Type MvvmCross.Forms.Presenter.Core.MvxFormsPagePresenter has invalid vtable method slot 7 with method MvvmCross.Core.Views.MvxViewPresenter:Close (MvvmCross.Core.ViewModels.IMvxViewModel) assembly:/storage/emulated/0/Android/data/StormFinder.Android/files/.__override__/MvvmCross.Forms.Presenter.Core.dll type:MvxFormsPagePresenter member:<none>

1 个答案:

答案 0 :(得分:1)

您需要在MvxContentPage中包含MainPage的命名空间。

它需要看起来像这样:

<?xml version="1.0" encoding="utf-8" ?>
<core1:MvxContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:StormFinder"
              xmlns:core="clr-namespace:MvvmCross.Forms.Presenter.Core;assembly=MvvmCross.Forms.Presenter.Core"
              xmlns:core1="clr-namespace:MvvmCross.Forms.Core;assembly=MvvmCross.Forms"
              x:Class="StormFinder.MainPage">

    <Label Text="{Binding Text}" 
           VerticalOptions="Center" 
           HorizontalOptions="Center" />
    <!-- core:MvxContentPage -->
</core1:MvxContentPage>