System.Runtime.InteropServices.COMException when calling AddFromTemplate
I have written a VS extension (for 2019). It shows a menu point. When it is clicked, I execute this code:
private void Execute(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();
dte.SelectedItems.Item(1).Project.ProjectItems.AddFromTemplate("path to vstemplate for a dialog", "TestDialog");
}
Now... this works. It does show the wizard for this template. It does create and add the dialog (or whatever this template should do) ... it does also work for other templates. Everything fine... except, that I get an unhandled System.Runtime.InteropServices.COMException after the call. And... I don't understand why. Is this normal? Do I have to catch it? Is it because of something I'm not doing? ... what is it?