Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Exception while raising propertychanged event in Muitiple iew scenario

$
0
0
Hi,

I am working on windows store app and it has multiple view scenario where I publish one object from Main view to secondary view using Event Aggregator (PRISM). while assigning that object to a property of same type in subscriber class I receive below error.


A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.Practices.Prism.StoreApps.DLL

Additional information: Unable to cast COM object of type 'System.ComponentModel.PropertyChangedEventHandler' to class type 'System.ComponentModel.PropertyChangedEventHandler'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.

If there is a handler for this exception, the program may be safely continued.



This error occurs in below property on line which is bold.
string _playingSong;
        public string PlayingSong
        {
            get { return _playingSong; }
            set
            {
                if (value != null)
                    SetProperty(ref _playingSong, value);
            }
        }
if I remove SetProperty and set field value directly as below, code doesn't throw any error. it looks like error occurs while raising propertychangedevent.
        string _playingSong;
        public string PlayingSong
        {
            get { return _playingSong; }
            set
            {
                if (value != null)
                    _playingSong = value;
            }
        }
I use PRISM to bind view with ViewModels.


Appreciate any help.

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>