【发布时间】:2014-02-24 16:56:26
【问题描述】:
我目前正在重新组织我的 WP8 项目,以便拥有一个可移植的类库,这可能会产生一个 W8 应用程序。
我正在使用 MVVMLight 并且有以下代码:
在可移植类库中:
namespace MyApp.Shared.Messages
{
public class MyItemSelectedMessage : MessageBase
{
public MyItemSelectedMessage(MyItem item)
{
Item = item;
}
public MyItem Item { get; set; }
}
}
在我的 WP8 应用程序中,我仍然有 ViewModels(因为 Telerik 和其他一些我无法外包给 PCL 的东西),我使用以下代码注册消息:
Messenger.Default.Register<MyItemSelectedMessage>(this, msg => SelectedItem = msg.Item);
代码之前运行良好,但现在 VS 在给定行的 WP8 应用程序中给我以下错误:
The type 'GalaSoft.MvvmLight.Messaging.MessageBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'GalaSoft.MvvmLight, Version=4.2.30.16997, Culture=neutral, PublicKeyToken=null'
在我的 WP8 项目中,我安装了 MvvmLight (v4.2.30.23483),在我的 PCL 中有用于 PCL (v4.2.30.16997) 的 MvvmLight 库,它们都是来自 Nuget 的最新版本。我是否需要降级软件包以获得相同的内部版本号、手动添加库或我可以做些什么才能使其正常工作?
提前致谢!
【问题讨论】:
标签: c# windows-phone-8 windows-phone mvvm-light portable-class-library