c# - Code causes WPF Designer to crash, why? -


I created a class to monitor the properties for the changes and triggered the INotifyPropertyChanged event

It has been added to a WPF control, the system to the designer. Crashes with an unrestricted exception of the runtime. Remoting.RemotingException [4484] The designer process ended unexpectedly!

Why do anyone know?

  Public Interface IObservableValue & lt; T>: INotifyPropertyChanged, INotifyPropertyChanging {T Value {get; }} Public square observableProperty & lt; T & gt; : IObservableValue & lt; T & gt; {Public stable underlying operator T (Observative Property & Lt; T & gt; OBJ) {obj.Value return; } Public supervision property (): this (default (t)) {} public supervision qualification (t-value) {val = value; Check interface (val, true); } T Val; Public t-value {receive {return valance; } Set {if (! Val.Equals (value)) {OnPropertyChanging (changingArgs); Check interface (val, false); Val = value; Check interface (val, true); OnPropertyChanged (changedArgs); }}} Public Hearts {Receive {return Val! = Null; }} Protected Zero Check Interface & lt; TVLUE & gt; (TV Price, Add Bull) {INotifyPropertyChanging inc = INOTifyPropertyChanging as Price; If (inc! = Null) {if (plus) inc. Propertyclose = New PropertyChangingEventHandler (val_PropertyChanging); Other Inc. Property Chengning - = Changing New Property EventLandler (Val-PropertyChanging); } INotifyPropertyChanged inpc = INotifyPropertyChanged as Price; If (inpc! = Null) {if (add) inpc.PropertyChanged + = New PropertyChangedEventHandler (val_PropertyChanged); Else inpc.PropertyChanged - = new asset changing event handler (val_PropertyChanged); } INotifyCollectionChanged incc = INotifyCollectionChanged as Price; If (incc! = Null) {if (addition) incc.CollectionChanged + = New NotifyCollectionChangedEventHandler (val_CollectionChanged); Else incc.CollectionChanged - = New NotifyCollectionChangedEventHandler (val_CollectionChanged); }} Zero valvelobbing (object sender, notification chained event events e) {ONPROTITA CHANGED (changed erg); } Zero valveprotecting changes (object sender, property changing and earnings e) {ONPROTTING CHANGING (changing ARGS); } Zero valvproactive change (object sender, property changer ARGS E) {ONProperty Charged (changed erg); } Zero OnPropertyChanged (changed PropertyChangedEventArgs) {var handler = property changed; If (handler! = Null) handler (this changed); } Zero OnPropertyChanging (Changing PropertyChangingEventArgs) {var handler = Ching property; If (handler! = Null) handler (this changed); } Private Static PropertyChangedEventArgs changedArgs = New PropertyChangedEventArgs ("Value"); Private StaticJetting EnvironmentsErgings changingArgs = New Property Changing EventAge ("Value"); Public Event Threaded ChangedEventHandler Property changed; Public event property-setting duel handler property charging;  

The only thing I see is that

  will be thrown  

a NullReferenceException if val is zero; ( Val.Equals (value) I'm sure the designer uses the default constructor for the class, which means that val is zero in the designer, thus the value setter throws an exception.


Comments