LottieSharp icon indicating copy to clipboard operation
LottieSharp copied to clipboard

System.NullReferenceException: Object reference not set to an instance of an object.

Open mohanadasari opened this issue 3 years ago • 6 comments

Getting this exception while using spinner control. had downloaded the source code and fixed issue locally, how do we put the fix as part of upcoming release. Fix details, Filename: LottieSharp-master\LottieSharp\WpfSurface\D2dControl.cs on line number 135 inside method "OnIsFrontBufferAvailableChanged" added null check as follows if (d3DSurface != null && d3DSurface.IsFrontBufferAvailable)

Exception Details: Unhandled exception System.NullReferenceException: Object reference not set to an instance of an object. at LottieSharp.WpfSurface.D2dControl.OnIsFrontBufferAvailableChanged(Object sender, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyPropertyChangedEventHandler.Invoke(Object sender, DependencyPropertyChangedEventArgs e) at System.Windows.Interop.D3DImage.IsFrontBufferAvailablePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.Freezable.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at System.Windows.DependencyObject.SetValue(DependencyPropertyKey key, Object value) at System.Windows.Interop.D3DImage.SetIsFrontBufferAvailable(Object isAvailableVersionPair) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at Sncr.Cloud.UI.App.Main() An unhandled exception of type 'System.NullReferenceException' occurred in WindowsBase.dll Object reference not set to an instance of an object.

mohanadasari avatar Jun 01 '21 20:06 mohanadasari

@OmidID It will be great if we we come to know about expected release for the issue.

mohanadasari avatar Jun 23 '21 10:06 mohanadasari

I got same problem image

hristowwe avatar Sep 04 '21 10:09 hristowwe

I have the same problem, did you find a solution?

saklanmazozgur avatar Sep 30 '21 05:09 saklanmazozgur

I have the same problem, did you find a solution?

No you can use MediaElement or this lib https://github.com/XamlAnimatedGif/WpfAnimatedGif

hristowwe avatar Sep 30 '21 13:09 hristowwe

Hey !

Had the same issue.

1 - Put your json in solution image

2 - Check settings image

3 - Check your .csproj and find the new line image

4 - Update your xaml image

Thats how i fix mine :)

Hope it will help you too

jm-parent avatar Oct 22 '21 14:10 jm-parent

You're great, it worked for me, thank you.

saklanmazozgur avatar Oct 25 '21 05:10 saklanmazozgur