microsoft / TemplateStudio

Template Studio accelerates the creation of new WinUI 3, WPF, and UWP apps using a wizard-based experience.
Other
2.69k stars 459 forks source link

Template Studio fails with `System.MissingMethodException` while clicking on "Create" #4707

Closed akash07k closed 11 months ago

akash07k commented 1 year ago

Describe the bug

I'm using Visual Studio 17.8 Preview 1 and latest Template Studio (5.4). When I try to create any project by choosing Template Studio either for WPF or WinUI, it fails with System.MissingMethodException. Below is the complete stack trace:

System.MissingMethodException: Method not found: 'System.Collections.Generic.IReadOnlyList`1<Microsoft.TemplateEngine.Abstractions.ITemplate> Microsoft.TemplateEngine.Edge.Settings.ScanResult.get_Templates()'.
   at Microsoft.Templates.Core.TemplatesRepository.GetAll()
   at Microsoft.Templates.Core.TemplatesRepository.GetSupportedProjectTypes(UserSelectionContext context)
   at Microsoft.Templates.Core.TemplatesRepository.GetProjectTypes(UserSelectionContext context)
   at Microsoft.Templates.UI.Services.DataService.LoadProjectTypes(ObservableCollection`1 projectTypes, UserSelectionContext context)
   at Microsoft.Templates.UI.ViewModels.NewProject.ProjectTypeViewModel.<LoadDataAsync>d__1.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.ViewModels.NewProject.MainViewModel.<OnTemplatesAvailableAsync>d__38.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.Views.NewProject.NewProjectWizardShell.<OnLoaded>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   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.Window.ShowHelper(Object booleanBox)
   at System.Windows.Window.ShowDialog()
   at Microsoft.Internal.VisualStudio.PlatformUI.WindowHelper.ShowModal(Window window, IntPtr parent)
   at Microsoft.Templates.UI.VisualStudio.GenShell.VsGenShellUI.<ShowModalAsync>d__8.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.VisualStudio.GenShell.VsGenShellUI.<>c__DisplayClass7_0.<<ShowModal>b__0>d.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.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
   at Microsoft.Templates.UI.VisualStudio.GenShell.VsGenShellUI.ShowModal(IWindow shell)
   at Microsoft.Templates.UI.Launcher.WizardLauncher.LaunchWizardShell(IWizardShell wizardShell)
   at Microsoft.Templates.UI.Launcher.WizardLauncher.StartWizard(IWizardShell wizardShell, WizardTypeEnum wizardType)

I'm also attaching the logs. WTS_LocalEnv_20230815.log

To Reproduce

  1. Open Visual Studio Preview.
  2. Click on "New Project.
  3. Search for "Template Studio" and choose any template such as WPF/WinUI.
  4. Click "Next".
  5. Click on "Create" and observe

Additional context

image

Applies to the following platforms:

About your setup

LeftTwixWand commented 1 year ago

Same issue

jose8789 commented 1 year ago

Same issue here too

utech626 commented 1 year ago

Same Issue

ThaDaVos commented 1 year ago

Sadly same issue - was really looking forward to test Template Studio - perhaps it's not compatible with the latest Visual Studio Preview or DotNet 8?

MarcusKor commented 1 year ago

I think need to check the assembly "Microsoft.TemplateEngine.Edge.dll" under C:\Users\\AppData\Local\Microsoft\VisualStudio\17.0_9290dc47\Extensions\alz1ifqc.3ou path.

image

MarcusKor commented 1 year ago

I couldn't find out the get_Templates() in ScanResult method of the assembly. image

MarcusKor commented 1 year ago

Maybe the IReadOnlyList of its arguments is null. But the all related project template source files in there.

image

MarcusKor commented 1 year ago

image image image image image image image image image image image image

Template source test is working well. I think VS 2022 new release has fault to run template studio for wpf.

ReVanTis commented 11 months ago

Seems it's a similar issue of https://github.com/AvaloniaUI/TemplateStudio/issues/25

Petrarca181 commented 11 months ago

Seems like another abandoned project :)

LeftTwixWand commented 11 months ago

I've submitted a new bug on https://developercommunity.visualstudio.com And I'm going to attach the ticket link as soon as it gets reviewed

UPD: This is my bug report: https://developercommunity.visualstudio.com/t/TemplateEngine-can-not-find-Teplate-Stud/10489545

mikebattista commented 11 months ago

Related issue we encountered in the past: https://github.com/microsoft/TemplateStudio/issues/4589.

In that case, the problem was with VS, which seems likely again here given you're reporting similar issues with other projects like Avalonia.

pratikone commented 11 months ago

Thank for reporting. I am aware of it and actively working to find root cause of it. https://developercommunity.visualstudio.com/t/Template-Studio-for-WinUI-C-crashes-V/10379299#T-ND10469906 where it was first reported. It looks like some internal VS plugin development api changed with new preview which our templating nuget package depends. Updating templating nuget to newer one doesn't help either. I have fixed a few missing method exception by moving away from deprecated methods but it is now showing with newer apis too. 😔 While I continue to investigate it, I have filed this issue with templating team : https://github.com/dotnet/templating/issues/6991

They have had a new nuget release which I haven't upgraded TS to, maybe that could help.

Mysterious-Dev commented 11 months ago

@pratikone Have you tested with VS 17.8 Preview 4? Because when I test your branch (https://github.com/microsoft/TemplateStudio/tree/runson2022), it works fine ^^.

pratikone commented 11 months ago

@pratikone Have you tested with VS 17.8 Preview 4? Because when I test your branch (runson2022), it works fine ^^.

yes, it now works. The VS .net team fixed in preview 5. I guess 4 too.