MoeIDE
MoeIDE copied to clipboard
NullReferenceException crashes Visual Studio
:link: Originally reported here: https://developercommunity.visualstudio.com/content/problem/702646/moeide.html
This is the stack trace from a crash:
Event Time (UTC): 2019/8/21 7:32:47
Event ID: 1026
Data: 应用程序: devenv.exe
Framework 版本: v4.0.30319
说明: 由于未经处理的异常,进程终止。
异常信息: System.NullReferenceException
在 Meowtrix.MoeIDE.Settings.OnActivate(System.ComponentModel.CancelEventArgs)
在 Microsoft.VisualStudio.Shell.DialogPage+DialogSubclass.WndProc(System.Windows.Forms.Message ByRef)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr)
在 Microsoft.VisualStudio.Shell.Interop.IVsUIDataSource.Invoke(System.String, System.Object, System.Object ByRef)
在 Microsoft.Internal.VisualStudio.PlatformUI.DataSource.Invoke(System.String, System.Object, System.Object ByRef)
在 Microsoft.VisualStudio.PlatformUI.VsCommand.Execute(System.Object)
在 MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource, Boolean)
在 System.Windows.Controls.MenuItem.InvokeClickAfterRender(System.Object)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
在 System.Windows.Threading.DispatcherOperation.InvokeImpl()
在 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
在 MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
在 MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
在 System.Windows.Threading.DispatcherOperation.Invoke()
在 System.Windows.Threading.Dispatcher.ProcessQueue()
在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
在 MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
Took a look at this.
This is actually really tough.
There's not a lot of room for error, unless somehow SettingsManager
is a NullReference. Not being caught by anything might break something. I cannot think of a way to replicate this
https://github.com/Meowtrix/MoeIDE/blob/master/MoeIDE/Settings.cs#L17
If Model were null, as the logic states, the settings window loads normally with No Data
New Bug though: Need to fix the UI tool colours
@Scrxtchy Previously, all the code assumes that MainWindow
is present when doing everything. This is not true for VS2019 because of new start window.
Settings code should be refactored. But I don't have so much time for this project since I haven't used it for 2 years.