'System.ComponentModel.INotifyPropertyChanging' in two places with MVVMLight Portable libraries

百般思念 提交于 2019-12-11 04:07:42

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/15478958/system-componentmodel-inotifypropertychanging-in-two-places-with-mvvmlight-por

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!