Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

System.NullReferenceException in INotifyPropertyChanged on Android after rotating the smartphone

$
0
0

Hello,

my application will throw an exception in Android, if I try to rotate my smartphone. Everything is working...till I rotate it. It only happens at this part of the code: Entry.PropertyChanged.

This works:
artikelButton.Clicked += OnArtikelChanged;

This not:
lagerOrt.PropertyChanged += OnLagerChanged;

My BaseViewModel:

public class BaseViewModel : INotifyPropertyChanged {
        private bool _isBusy;
        public bool IsBusy {
            get { return _isBusy; }
            set {
                _isBusy = value;
                OnPropertyChanged();
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;
        public virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) {
            var handler = PropertyChanged;
            if (handler != null) {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

Exception triggers in this Line:

handler(this, new PropertyChangedEventArgs(propertyName));

Part of the exception (whole exception is in an extra txt file):

System.NullReferenceException: Object reference not set to an instance of an object
03-16 14:37:33.332 D/Mono    (24302): DllImport attempting to load: '/system/lib/liblog.so'.
03-16 14:37:33.332 D/Mono    (24302): DllImport loaded library '/system/lib/liblog.so'.
03-16 14:37:33.337 D/Mono    (24302): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
03-16 14:37:33.337 D/Mono    (24302): Searching for '__android_log_print'.
03-16 14:37:33.337 D/Mono    (24302): Probing '__android_log_print'.
03-16 14:37:33.337 D/Mono    (24302): Found as '__android_log_print'.
03-16 14:37:33.357 I/MonoDroid(24302): UNHANDLED EXCEPTION:
03-16 14:37:33.367 I/MonoDroid(24302): System.NullReferenceException: Object reference not set to an instance of an object
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.Platform.Android.Platform.GetNativeSize (Xamarin.Forms.VisualElement,double,double) <IL 0x00092, 0x00494>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.VisualElement.OnSizeRequest (double,double) <IL 0x0003b, 0x0027f>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.VisualElement.GetSizeRequest (double,double) <IL 0x0003b, 0x002db>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout/LayoutInformation,Xamarin.Forms.StackOrientation,double,double,double,double) <IL 0x000a1, 0x006fb>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout/LayoutInformation,double,double,double,double,bool) <IL 0x00061, 0x0032f>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.StackLayout.LayoutChildren (double,double,double,double) <IL 0x00068, 0x002b7>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.Layout.UpdateChildrenLayout () <IL 0x000c8, 0x0066f>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.Layout.OnSizeAllocated (double,double) <IL 0x00010, 0x000ab>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.VisualElement.SizeAllocated (double,double) <IL 0x00003, 0x00083>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.Layout.OnChildMeasureInvalidated () <IL 0x00075, 0x00357>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.Layout.OnChildMeasureInvalidated (object,System.EventArgs) <IL 0x00001, 0x00057>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.VisualElement.InvalidateMeasure () <IL 0x00014, 0x00083>
03-16 14:37:33.367 I/MonoDroid(24302): at Xamarin.Forms.VisualElement.<.cctor>b__3 (Xamarin.Forms.BindableObject,object,object) <IL 0x00006, 0x0007f>

Best regards


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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