Error adding settings page in WinUI 3 MVVM app using Template Studio

TUAN THANH VO 0 Reputation points
2024-11-22T12:27:04.8366667+00:00

I'm trying to add a settings page to my existing WinUI 3 app using Template Studio (With Navigation Bar) with the MVVM pattern. However, I'm encountering the following error:

System.Exception: Error executing 'Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction'. Related template: ts.WinUI.MVVMToolkit.Feat.ThemeSelection. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at Microsoft.Templates.Core.PostActions.Catalog.Merge.MergeHandler.FindAndModifyContextLine(String mergeLine, Int32 diffTrivia)
   at Microsoft.Templates.Core.PostActions.Catalog.Merge.MergeHandler.Merge(IEnumerable`1 source, IEnumerable`1 merge)
   at Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction.ExecuteInternal()
   at Microsoft.Templates.Core.PostActions.PostAction.Execute()
   --- End of inner exception stack trace ---
   at Microsoft.Templates.Core.PostActions.PostAction.Execute()
   at Microsoft.Templates.Core.Gen.GenController.ExecutePostActions(GenInfo genInfo, ITemplateCreationResult generationResult)
   at Microsoft.Templates.Core.Gen.GenController.<GenerateItemsAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Templates.Core.Gen.NewItemGenController.<UnsafeGenerateNewItemAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Templates.UI.Services.GenerationService.<GenerateNewItemAsync>d__6.MoveNext()

This is the problem i faced
User's image

I've tried the following steps:

  • Ensured that I'm using the latest version of Template Studio.

Checked the App.xaml.cs and theme-related files for any discrepancies.

However, the issue persists. Could someone please help me resolve this error?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,952 questions
Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
801 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.