mrward/monodevelop-dnx-addin

Null reference exception when creating a new solution

mrward opened this issue · 1 comments

With latest monodevelop from master the roslyn branch of the DNX addin triggers a null reference exception in the main toolbar when a new solution is created.

ERROR [2016-02-02 21:51:36Z]: An unhandled exception has occured. Terminating MonoDevelop? False
System.NullReferenceException: Object reference not set to an instance of an object.
   at MonoDevelop.Components.MainToolbar.MainToolbarController.SelectActiveRuntime() in main\src\core\MonoDevelop.Ide\MonoDevelop.Components.MainToolbar\MainToolbarController.cs:line 407
   at MonoDevelop.Components.MainToolbar.MainToolbarController.SelectActiveConfiguration() in main\src\core\MonoDevelop.Ide\MonoDevelop.Components.MainToolbar\MainToolbarController.cs:line 339
   at MonoDevelop.Components.MainToolbar.MainToolbarController.UpdateCombos() in main\src\core\MonoDevelop.Ide\MonoDevelop.Components.MainToolbar\MainToolbarController.cs:line 162
   at MonoDevelop.Components.MainToolbar.MainToolbarController.<.ctor>b__19_6(Object sender, EventArgs e) in main\src\core\MonoDevelop.Ide\MonoDevelop.Components.MainToolbar\MainToolbarController.cs:line 102
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at MonoDevelop.Ide.RootWorkspace.OnActiveConfigurationChanged() in main\src\core\MonoDevelop.Ide\MonoDevelop.Ide\RootWorkspace.cs:line 108
   at MonoDevelop.Ide.RootWorkspace.set_ActiveConfigurationId(String value) in main\src\core\MonoDevelop.Ide\MonoDevelop.Ide\RootWorkspace.cs:line 100
   at MonoDevelop.Components.MainToolbar.MainToolbarController.SelectActiveConfiguration() in main\src\core\MonoDevelop.Ide\MonoDevelop.Components.MainToolbar\MainToolbarController.cs:line 332
   at MonoDevelop.Components.MainToolbar.MainToolbarController.UpdateCombos() in main\src\core\MonoDevelop.Ide\MonoDevelop.Components.MainToolbar\MainToolbarController.cs:line 162
   at MonoDevelop.Components.MainToolbar.MainToolbarController.<.ctor>b__19_7(Object sender, EventArgs e) in main\src\core\MonoDevelop.Ide\MonoDevelop.Components.MainToolbar\MainToolbarController.cs:line 103
   at MonoDevelop.Ide.RootWorkspace.NotifyConfigurationsChanged(Object s, EventArgs a) in main\src\core\MonoDevelop.Ide\MonoDevelop.Ide\RootWorkspace.cs:line 994
   at MonoDevelop.Projects.WorkspaceItem.OnConfigurationsChanged() in main\src\core\MonoDevelop.Core\MonoDevelop.Projects\WorkspaceItem.cs:line 224
   at MonoDevelop.Projects.Solution.NotifyConfigurationsChanged() in main\src\core\MonoDevelop.Core\MonoDevelop.Projects\Solution.cs:line 1015
   at MonoDevelop.Projects.SolutionConfigurationCollection.OnItemsAdded(IEnumerable`1 confs) in main\src\core\MonoDevelop.Core\MonoDevelop.Projects\SolutionConfigurationCollection.cs:line 55
   at MonoDevelop.Projects.ItemCollection`1.Add(T item) in main\src\core\MonoDevelop.Core\MonoDevelop.Projects\ItemCollection.cs:line 64
   at MonoDevelop.Projects.Solution.AddConfiguration(String id, Boolean createConfigForItems) in main\src\core\MonoDevelop.Core\MonoDevelop.Projects\Solution.cs:line 389
   at MonoDevelop.Dnx.SolutionExtensions.GenerateDefaultDnxProjectConfigurations(Solution solution, DnxProject project) in monodevelop-dnx-addin\src\MonoDevelop.Dnx\MonoDevelop.Dnx\SolutionExtensions.cs:line 76
   at MonoDevelop.Dnx.DnxProjectTemplateWizard.CreateProject(Solution solution, SolutionFolder srcFolder, Boolean newSolution) in monodevelop-dnx-addin\src\MonoDevelop.Dnx\MonoDevelop.Dnx\DnxProjectTemplateWizard.cs:line 137
   at MonoDevelop.Dnx.DnxProjectTemplateWizard.ItemsCreated(IEnumerable`1 items) in monodevelop-dnx-addin\src\MonoDevelop.Dnx\MonoDevelop.Dnx\DnxProjectTemplateWizard.cs:line 69
   at MonoDevelop.Ide.Projects.NewProjectDialogController.<Create>d__126.MoveNext() in main\src\core\MonoDevelop.Ide\MonoDevelop.Ide.Projects\NewProjectController.cs:line 592
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at MonoDevelop.Ide.Projects.GtkNewProjectDialogBackend.<MoveToNextPage>d__39.MoveNext() in main\src\core\MonoDevelop.Ide\MonoDevelop.Ide.Projects\GtkNewProjectDialogBackend.cs:line 412
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__4(Object state)
   at MonoDevelop.Ide.DispatchService.GtkSynchronizationContext.<>c__DisplayClass0_0.<Post>b__0() in main\src\core\MonoDevelop.Ide\MonoDevelop.Ide\DispatchService.cs:line 61
   at MonoDevelop.Ide.DispatchService.GuiDispatch(Action cb) in main\src\core\MonoDevelop.Ide\MonoDevelop.Ide\DispatchService.cs:line 107

This looks like a MonoDevelop bug since I can reproduce it by creating an empty solution and then adding a console project to the solution. bugzilla

Looks like I can workaround it by setting the solution's startup item before adding the project configurations.