2
votes

I get this fun error when I try adding a local database to my Windows Phone 8 project.

The type 'System.ComponentModel.INotifyPropertyChanging' exists in both 'e:\users\keenan\Documents\Visual Studio 2012\Projects\MAL.WindowsPhone\packages\Portable.MvvmLightLibs.4.1.27.1\lib\wp8\GalaSoft.MvvmLight.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0\System.dll'

Why is System.ComponentModel.INotifyPropertyChanging in the WP8 libraries of the MVVM Portable NuGet package? Is this a bug, because I think it conflicts with what is already in the mscorlib of Windows Phone 8.

Please help.

2
Did you check the compatibility of the MVVM light package you're using? - DHN
The NuGet installer automatically determines which libraries to reference in my various projects. So I can see for my portable class library project it referenced assemblies out of the "portable-net45+sl4+wp71+win8" folder and for my WP8 project it referenced the assemblies in the "wp8" folder. This leads me to think that the build process is accidently compiling the System.ComponentModel.INotifyPropertyChanging for the WP8 and .NET 4.5 assemblies. With that, is there another way to check the compatibility? - Keenan Newton

2 Answers

3
votes

Please try the latest Portable.MvvmLightLibs (4.1.27.3). I had to remove INotifyPropertyChanging from the PCL version as there's really no way to get it to work properly across platforms.

We'd need Microsoft to provide a shim (similar to Microsoft.Bcl) for this so that it'd be picked up correctly on WP.

If you need property changing notifications (before the value changes - this is very uncommon and few things use this), one option could be to create your own interface and implement it in a derived type from ObservableObject (you can override the RaisePropertyChanging methods to know when to raise your own event).

If Microsoft adds support for INotifyPropertyChangning in PCL's, I'll certainly add it back to MVVMLight.

0
votes

One simple solution you can use is to download source code of MVVM Light and remove all references to INotifyPropertyChanging in ObservableObject. Compile the library by yourself and it should then work just fine.