移动模拟器上的 Prism-Mvvm 应用程序部署错误

Prism-Mvvm app deployment error on Mobile Emulator

我在 Mobile Emulator 10586 上部署一个简单的 Prism.Mvvm 应用程序时出现异常,而它在模拟器和我的本地计算机上都能正常工作。 我指的是 Prism.storeapps package.Here 是我的代码

App.xaml.cs

namespace MvvmSample
{
    sealed partial class App : MvvmAppBase
    {
        public App()
        {
            InitializeComponent();
        }
        public enum Expirences
        {
            Main
        }
        protected override Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args)
        {
            this.NavigationService.Navigate(Expirences.Main.ToString(), null);
            return Task.FromResult<object>(null);
        }

    }
}

MainPage.xaml

<controls:PageBase
    x:Class="MvvmSample.Views.MainPage"
    xmlns:controls="using:MvvmSample.Controls"
    xmlns:prism="using:Microsoft.Practices.Prism.Mvvm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MvvmSample"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    prism:ViewModelLocator.AutoWireViewModel="True"
    mc:Ignorable="d">
    <d:Page.DataContext>
        <local:MainPageViewModel/>
    </d:Page.DataContext>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <TextBlock Text="{Binding Title}" FontSize="29.333" />
    </Grid>
</controls:PageBase>

查看

namespace MvvmSample
{
    namespace Controls
    {
        public abstract partial class PageBase : Page, IView { }
    }
    namespace Views
    {
        public sealed partial class MainPage : Controls.PageBase
        {
            public MainPage()
            {
                this.InitializeComponent();
            }
        }
    }
    namespace ViewModels
    {
        public class MainPageViewModel : Microsoft.Practices.Prism.Mvvm.ViewModel
        {
            public string Title { get; set; }
            public MainPageViewModel()
            {
                this.Title = "Run Time";
            }
        }
    }
}

您正在使用 Prism.StoreApps, which is a package for Windows 8.1. For UWP you should be using Prism.Windows。它在您的机器上运行的原因是因为 Windows 10 可以 运行 Windows 8 个应用程序。而模拟器是特定的 SDK 版本。

有关 Windows 10(包括依赖项注入)的可用 NuGet 包的更多信息,请查看 official GitHub repo. There are some samples available as well in this repo