【发布时间】:2014-09-30 08:12:41
【问题描述】:
我有一个 MVVM Light 基础结构,它全部包含在一个针对 .Net 4、SL5、Win 8、WP 8.1、WPSL 8、Xamarin.Android 和 Xamarin.iOS 的可移植类库中。这与 WPF 客户端完美配合,但是,当我尝试在 Windows Store App/Win 8 环境中使用它时,我遇到了一些阻力。第一个问题在 App.xaml 中找到:
<Application
x:Class="Win8Client.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:INPS.Vision.Appointments.Shared.ViewModels"
xmlns:local="using:Win8Client">
<Application.Resources>
<vm:ViewModelLocator x:Key="Locator" />
</Application.Resources>
</Application>
在设计时,我得到“无法加载文件或程序集 'Microsoft.Threading.Tasks',版本 = 1.0.12.0 ...”,这是指我的 ViewModelLocator。这编译并似乎运行正常,但我没有得到任何设计时数据。设计时数据在 WPF 客户端中运行良好。
一旦运行,我会看到我的第一个视图,但是一旦调用了这条线:
Slots = await _appointmentsDataProvider.GetAppointments(SelectedDate);
我的 slot 属性设置器中出现以下异常,该设置利用了 ViewModelBase 的 MVVM Lights Set 方法。 Slots 属性尚未绑定到任何 UI。
例外:
“应用程序调用了一个为不同线程编组的接口。(来自 HRESULT 的异常:0x8001010E (RPC_E_WRONG_THREAD))”
插槽属性:
public List<Slot> Slots
{
get { return _slots; }
set
{
Set(SlotsPropertyName, ref _slots, value); // <-- Exception thrown here
}
}
意识到我实际上并没有问过问题。简单地说,我想知道,将 MVVM Light 与 Windows 应用商店应用程序一起使用的最佳方法是什么?
提前感谢您的任何帮助或建议!
【问题讨论】:
-
对于程序集加载错误,请尝试以下操作:卸载所有
Microsoft.BclNuGet 包,从app.config删除所有程序集重定向,然后安装这些包的最新版本。
标签: windows-store-apps mvvm-light portable-class-library