I am currently reorganizing my WP8 project in order to have a Portable Class Library, which could result in a W8 app.
I am using MVVMLight and have the following code:
In the Portable Class Library:
namespace MyApp.Shared.Messages
{
public class MyItemSelectedMessage : MessageBase
{
public MyItemSelectedMessage(MyItem item)
{
Item = item;
}
public MyItem Item { get; set; }
}
}
In my WP8 app, I still do have the ViewModels (because of Telerik and some other stuff which I cannot outsource to the PCL), where I use the following code to register for the message:
Messenger.Default.Register<MyItemSelectedMessage>(this, msg => SelectedItem = msg.Item);
The code worked fine before but now VS gives me the following error in the WP8 app at the given line:
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'
In my WP8 project, I have installed MvvmLight (v4.2.30.23483) and in my PCL there are the MvvmLight Libraries for PCL (v4.2.30.16997), both up-to-date from Nuget. Do I need to downgrade a package to get the same build number, add the libraries manually or what can I do in order to make it work?
Thanks in advance!
You should reference the Portable.MvvmLightLibs NuGet package from both projects, and not any of the non-portable MvvmLight packages. The Portable.MvvmLightLibs package includes support for both PCLs and platform-specific libraries.