Forum Xamarin.Forms

System.ArgumentException: 'Delegate to an instance method cannot have null 'this'.' - UWP

Hello,

I'm struggling with an exception that I'm getting when trying to run my Xamarin.Forms UWP app. This is a legacy application that I'm working on that is currently on Xamarin.Forms 3.1.0.697729. I have to upgrade it to Xamarin.Forms 3.6.0.709228. to resolve an issue that is present in iPadOS 13 (because this is a legacy app, we don't want to upgrade Xamarin.Forms to the latest because we are in the process of deprecating this app within the next year, so we don't want to put a ton of effort into upgrading this to XF 4.5, when we're already doing that with our newer app).

Unfortunately, upgrading from XF 3.1 to 3.6 is causing an exception to occur in our UWP app when we're trying to set the MainPage of the application. The only thing that has changed is this XF NuGet package upgrade. Everything else is exactly the same. The app works perfectly fine with XF 3.1, but with XF 3.6, we get a System.ArgumentException with the message of: 'Delegate to an instance method cannot have null 'this'.' I tried doing some searches for how to resolve this issue, but I haven't come across anything useful for this specific case. Since this error started happening after an upgrade of Xamarin.Forms, I figured I would make a post here to see if anyone here has experienced an issue like this before and/or has ideas on a potential fix. Please let me know if there is anything else I can provide to help track this issue down. I appreciate any assistance I can get with this one.

Unfortunately, the stack trace & call stacks I get when the error occurs aren't super helpful, but here they are, just in case there is something useful that can be spotted inside of them:

`Stack Trace:
System.ArgumentException
HResult=0x80070057
Message=Delegate to an instance method cannot have null 'this'.
Source=System.Private.CoreLib
StackTrace:
at System.MulticastDelegate.ThrowNullThisInDelegateToInstance()

Call Stack:
System.Private.CoreLib.dll!System.MulticastDelegate.ThrowNullThisInDelegateToInstance() Unknown
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.TitleViewManager.TitleViewManager(Xamarin.Forms.Platform.UWP.ITitleViewRendererController titleViewRendererController) Unknown
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.MasterDetailControl.OnApplyTemplate() Unknown
[Native to Managed Transition]
[Managed to Native Transition]
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.MasterDetailControl.Xamarin.Forms.Platform.UWP.IToolbarProvider.GetCommandBarAsync() Unknown
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.MasterDetailPageRenderer.Xamarin.Forms.Platform.UWP.IToolbarProvider.GetCommandBarAsync() Unknown
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.Platform.UpdateToolbarItems() Unknown
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.Platform.OnToolbarItemsChanged(object sender, System.EventArgs e) Unknown
Xamarin.Forms.Core.dll!Xamarin.Forms.Internals.ToolbarTracker.EmitCollectionChanged() Unknown
Xamarin.Forms.Core.dll!Xamarin.Forms.Internals.ToolbarTracker.Target.set(Xamarin.Forms.Page value) Unknown
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.Platform.UpdateToolbarTracker() Unknown
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.Platform.SetCurrent(Xamarin.Forms.Page newPage, bool popping, System.Action completedCallback) Unknown
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.Platform.SetPage(Xamarin.Forms.Page newRoot) Unknown
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.WindowsBasePage.OnApplicationPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) Unknown
Xamarin.Forms.Core.dll!Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName) Unknown
Xamarin.Forms.Core.dll!Xamarin.Forms.Element.OnPropertyChanged(string propertyName) Unknown
Xamarin.Forms.Core.dll!Xamarin.Forms.Application.MainPage.set(Xamarin.Forms.Page value) Unknown

Mobile2.Forms.dll!Mobile2.Forms.FormsApp.LoginUser(string username, string password, string company) Line 756 C#

[Resuming Async Method] 
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner..cctor.AnonymousMethod__4_0(object sm) Unknown
System.Private.CoreLib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)   Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.RunWithDefaultContext()    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0()   Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()  Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation.InvokeAction(object state)  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback callback, object state, ref System.Threading.Tasks.Task currentTask)   Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run(System.Threading.Tasks.Task task, bool canInlineContinuationTask) Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.RunContinuations(object continuationObject)  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.FinishContinuations()    Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task<System.__Canon>.TrySetResult(System.__Canon result)  Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Xamarin.Forms.Page>.SetExistingTaskResult(Xamarin.Forms.Page result)  Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Xamarin.Forms.Page>.SetResult(Xamarin.Forms.Page result)  Unknown
[Completed] Mobile2.Forms.dll!Mobile2.Forms.FormsApp.GetMainPage() Line 600 C#
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner..cctor.AnonymousMethod__4_0(object sm) Unknown
System.Private.CoreLib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)   Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.RunWithDefaultContext()    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0()   Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()  Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation.InvokeAction(object state)  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback callback, object state, ref System.Threading.Tasks.Task currentTask)   Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run(System.Threading.Tasks.Task task, bool canInlineContinuationTask) Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.RunContinuations(object continuationObject)  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.FinishContinuations()    Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task<System.Threading.Tasks.VoidTaskResult>.TrySetResult(System.Threading.Tasks.VoidTaskResult result)    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.SetExistingTaskResult(System.Threading.Tasks.VoidTaskResult result)    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.SetResult(System.Threading.Tasks.Task<System.Threading.Tasks.VoidTaskResult> completedTask)    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult()   Unknown
[Completed] Mobile2.Forms.dll!Mobile2.Forms.ViewModels.BaseAsyncViewModel.Initialize() Line 73  C#
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner..cctor.AnonymousMethod__4_0(object sm) Unknown
System.Private.CoreLib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)   Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.RunWithDefaultContext()    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0()   Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()  Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation.InvokeAction(object state)  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback callback, object state, ref System.Threading.Tasks.Task currentTask)   Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run(System.Threading.Tasks.Task task, bool canInlineContinuationTask) Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.RunContinuations(object continuationObject)  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.FinishContinuations()    Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task<System.Threading.Tasks.VoidTaskResult>.TrySetResult(System.Threading.Tasks.VoidTaskResult result)    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.SetExistingTaskResult(System.Threading.Tasks.VoidTaskResult result)    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.SetResult(System.Threading.Tasks.Task<System.Threading.Tasks.VoidTaskResult> completedTask)    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult()   Unknown
[Completed] Mobile2.Forms.dll!Mobile2.Forms.ViewModels.BaseAsyncViewModel.Reload(bool isPullToRefresh) Line 66  C#
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner..cctor.AnonymousMethod__4_0(object sm) Unknown
System.Private.CoreLib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)   Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.RunWithDefaultContext()    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0()   Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()  Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation.InvokeAction(object state)  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback callback, object state, ref System.Threading.Tasks.Task currentTask)   Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run(System.Threading.Tasks.Task task, bool canInlineContinuationTask) Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.RunContinuations(object continuationObject)  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.FinishContinuations()    Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task<System.Threading.Tasks.VoidTaskResult>.TrySetResult(System.Threading.Tasks.VoidTaskResult result)    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.SetExistingTaskResult(System.Threading.Tasks.VoidTaskResult result)    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.SetResult(System.Threading.Tasks.Task<System.Threading.Tasks.VoidTaskResult> completedTask)    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult()   Unknown
[Completed] Mobile2.Forms.dll!Mobile2.Forms.ViewModels.MenuListViewModel.LoadData() Line 198    C#
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner..cctor.AnonymousMethod__4_0(object sm) Unknown
System.Private.CoreLib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)   Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.RunWithDefaultContext()    Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__0()   Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()  Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__0() Unknown
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke()  Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.GetActionLogDelegate.AnonymousMethod__0() Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation..cctor.AnonymousMethod__8_0(object state) Unknown
System.Runtime.WindowsRuntime.dll!System.Threading.WinRTSynchronizationContextBase.Invoker.InvokeCore() Unknown
System.Runtime.WindowsRuntime.dll!System.Threading.WinRTSynchronizationContextBase.Invoker.InvokeInContext(object thisObj)  Unknown
System.Private.CoreLib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)   Unknown
System.Runtime.WindowsRuntime.dll!System.Threading.WinRTSynchronizationContextBase.Invoker.Invoke() Unknown`

Best Answer

Answers

Sign In or Register to comment.