Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException crashes Visual Studio #19

Open
sharwell opened this issue Aug 22, 2019 · 2 comments
Open

NullReferenceException crashes Visual Studio #19

sharwell opened this issue Aug 22, 2019 · 2 comments

Comments

@sharwell
Copy 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)
@Scrxtchy
Copy link
Contributor

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

image

New Bug though: Need to fix the UI tool colours

@huoyaoyuan
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants