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

  • Question

  • User86176 posted

    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.AnonymousMethod40(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.AnonymousMethod0() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod0() 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.TrySetResult(System.Canon result) Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetExistingTaskResult(Xamarin.Forms.Page result) Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.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.AnonymousMethod40(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.AnonymousMethod0() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod0() 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.TrySetResult(System.Threading.Tasks.VoidTaskResult result) Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetExistingTaskResult(System.Threading.Tasks.VoidTaskResult result) Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult(System.Threading.Tasks.Task 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.AnonymousMethod40(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.AnonymousMethod0() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod0() 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.TrySetResult(System.Threading.Tasks.VoidTaskResult result) Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetExistingTaskResult(System.Threading.Tasks.VoidTaskResult result) Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult(System.Threading.Tasks.Task 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.AnonymousMethod40(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.AnonymousMethod0() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod0() 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.TrySetResult(System.Threading.Tasks.VoidTaskResult result) Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetExistingTaskResult(System.Threading.Tasks.VoidTaskResult result) Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult(System.Threading.Tasks.Task 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.AnonymousMethod40(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.AnonymousMethod0() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod0() Unknown System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke() Unknown System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.GetActionLogDelegate.AnonymousMethod0() Unknown System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation..cctor.AnonymousMethod80(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`

    Wednesday, March 25, 2020 4:58 PM

Answers

  • User369979 posted

    It's hard to detect what happened on your side without your code. But if you are trying to adapt to Xamarin Forms 3.6 why not try the latest version? I suggest opening a support ticket here https://support.microsoft.com/en-us/supportforbusiness/productselection?sapId=211dd84f-3474-c3c5-79bf-66db630c92a6 since you can't share your code here on this public forum.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, March 26, 2020 9:44 AM

All replies

  • User369979 posted

    It's hard to detect what happened on your side without your code. But if you are trying to adapt to Xamarin Forms 3.6 why not try the latest version? I suggest opening a support ticket here https://support.microsoft.com/en-us/supportforbusiness/productselection?sapId=211dd84f-3474-c3c5-79bf-66db630c92a6 since you can't share your code here on this public forum.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, March 26, 2020 9:44 AM
  • User86176 posted

    @LandLu said: It's hard to detect what happened on your side without your code. But if you are trying to adapt to Xamarin Forms 3.6 why not try the latest version? I suggest opening a support ticket here https://support.microsoft.com/en-us/supportforbusiness/productselection?sapId=211dd84f-3474-c3c5-79bf-66db630c92a6 since you can't share your code here on this public forum.

    Thank you for your reply. After trying with Xamarin.Forms 4.5, I find that we don't have this issue with UWP. We have some other issues we need to sort out with XF 4.5, but they seem like they'll be easier to resolve than this null delegate issue, so we will change course and move forward with the latest version of Xamarin.Forms 4.5 after all.

    Thursday, March 26, 2020 7:26 PM