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

VisualStudioActiveDocumentTracker.FrameListener.ctor null-refs when encountering the Windows Forms designer #43495

Closed
davkean opened this issue Apr 20, 2020 · 1 comment · Fixed by #46452
Labels
4 - In Review A fix for the issue is submitted for review. Area-IDE Bug
Milestone

Comments

@davkean
Copy link
Member

davkean commented Apr 20, 2020

Hit this while debugging, VisualStudioActiveDocumentTracker.FrameListener.ctor is null ref'ing when the project has a Windows Forms designer open.

Version Used:
Version 16.7.0 Preview 1.0 [30019.16.master]

Steps to Reproduce:

                if (ErrorHandler.Succeeded(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out var docData)))
                {
                    if (docData is IVsTextBuffer bufferAdapter)
                    {
                        _textBuffer = _documentTracker._editorAdaptersFactoryService.GetDocumentBuffer(bufferAdapter); // <-- Returns null

                        if (!_textBuffer.ContentType.IsOfType(ContentTypeNames.RoslynContentType)) // Null Ref
                        {
                            _textBuffer.Changed += NonRoslynTextBuffer_Changed;
                        }
                    }
                }
System.NullReferenceException: Object reference not set to an instance of an object.
> Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.VisualStudioActiveDocumentTracker.FrameListener.FrameListener(Microsoft.VisualStudio.LanguageServices.Implementation.VisualStudioActiveDocumentTracker service, Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame frame) Line 231	C#
 	Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.VisualStudioActiveDocumentTracker.TrackNewActiveWindowFrame(Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame frame) Line 160	C#
 	Microsoft.VisualStudio.LanguageServices.dll!Microsoft.VisualStudio.LanguageServices.Implementation.VisualStudioActiveDocumentTracker.Microsoft.VisualStudio.Shell.Interop.IVsSelectionEvents.OnElementValueChanged(uint elementid, object varValueOld, object varValueNew) Line 197	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConnectSelectionContext() Line 9173	C#
 	Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.Activate() Line 9100	C#
 	Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.TryActivate(Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame frame, Microsoft.VisualStudio.PlatformUI.Shell.ActivationType _) Line 2634	C#
 	Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.viewManager_ActiveViewChanged(object sender, Microsoft.VisualStudio.PlatformUI.Shell.ActiveViewChangedEventArgs e) Line 2618	C#
 	Microsoft.VisualStudio.Utilities.dll!Microsoft.VisualStudio.PlatformUI.ExtensionMethods.RaiseEvent<System.__Canon>(System.EventHandler<System.__Canon> eventHandler, object source, System.__Canon args) Line 714	C#
 	Microsoft.VisualStudio.Shell.ViewManager.dll!Microsoft.VisualStudio.PlatformUI.Shell.ViewManager.SetActiveView(Microsoft.VisualStudio.PlatformUI.Shell.View view, Microsoft.VisualStudio.PlatformUI.Shell.ActivationType type) Line 1406	C#
 	Microsoft.VisualStudio.Shell.ViewManager.dll!Microsoft.VisualStudio.PlatformUI.Shell.ViewManager.ActiveViewDeferrer.DisposeManagedResources() Line 2614	C#
 	Microsoft.VisualStudio.Utilities.dll!Microsoft.VisualStudio.PlatformUI.DisposableObject.Dispose(bool disposing) Line 102	C#
 	Microsoft.VisualStudio.Utilities.dll!Microsoft.VisualStudio.PlatformUI.DisposableObject.Dispose() Line 35	C#
 	Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.SolutionOptions.LoadBinaryDocumentStates.AnonymousMethod__0(Microsoft.VisualStudio.Utilities.VersionedBinaryReader VersionedBinaryReader) Line 1292	C#
 	Microsoft.VisualStudio.Utilities.dll!Microsoft.VisualStudio.Utilities.VersionedBinaryReader.ReadVersioned(int expectedVersion, Microsoft.VisualStudio.Utilities.VersionedBinaryReader.ReadCallback callback, bool throwOnUnexpectedVersion) Line 66	C#
 	Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.SolutionOptions.LoadBinaryDocumentStates(Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService windowManager, Microsoft.VisualStudio.OLE.Interop.IStream comStream) Line 830	C#
 	Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.SolutionOptions.LoadDocumentStates(Microsoft.VisualStudio.OLE.Interop.IStream comStream) Line 553	C#
 	Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.LoadDocumentStates.AnonymousMethod__0() Line 3126	C#
 	Microsoft.VisualStudio.Shell.Framework.dll!Microsoft.VisualStudio.ErrorHandler.CallWithCOMConvention(System.Action method, bool reportError) Line 205	C#
 	Microsoft.VisualStudio.Platform.WindowManagement.dll!Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.LoadDocumentStates(Microsoft.VisualStudio.OLE.Interop.IStream stream, int fExternal) Line 3123	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	Microsoft.VisualStudio.Shell.UI.Internal.dll!Microsoft.VisualStudio.PlatformUI.Packages.MRU.ExtensionMethods.TryOpenProject(Microsoft.VisualStudio.Shell.Interop.IVsSolution solution, string projectPath, System.Guid projectGuid) Line 108	C#
 	Microsoft.VisualStudio.Shell.UI.Internal.dll!Microsoft.VisualStudio.PlatformUI.CodeContainerAccessManager.OpenLocalCodeContainerAsync(Microsoft.VisualStudio.Shell.CodeContainerManagement.CodeContainer codeContainer) Line 101	C#
 	Microsoft.VisualStudio.Shell.UI.Internal.dll!Microsoft.VisualStudio.PlatformUI.CodeContainerAccessManager.OpenAsync(Microsoft.VisualStudio.Shell.CodeContainerManagement.CodeContainer codeContainer) Line 61	C#
 	Microsoft.VisualStudio.Shell.UI.Internal.dll!Microsoft.VisualStudio.PlatformUI.CodeContainerListViewModel.OnOpenCore.AnonymousMethod__0() Line 298	C#
 	Microsoft.VisualStudio.Threading.dll!Microsoft.VisualStudio.Threading.JoinableTaskFactory.ExecuteJob<Microsoft.VisualStudio.Threading.EmptyStruct>(System.Func<System.Threading.Tasks.Task> asyncMethod, Microsoft.VisualStudio.Threading.JoinableTask job) Line 699	C#
 	Microsoft.VisualStudio.Threading.dll!Microsoft.VisualStudio.Threading.JoinableTaskFactory.RunAsync(System.Func<System.Threading.Tasks.Task> asyncMethod, bool synchronouslyBlocking, Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions creationOptions, System.Delegate entrypointOverride) Line 571	C#
 	Microsoft.VisualStudio.Shell.UI.Internal.dll!Microsoft.VisualStudio.PlatformUI.CodeContainerListViewModel.OnOpenCore(Microsoft.VisualStudio.PlatformUI.CodeContainerViewModelBase codeContainerViewModel) Line 326	C#
 	Microsoft.VisualStudio.Shell.UI.Internal.dll!Microsoft.VisualStudio.PlatformUI.CodeContainerListViewModel.OnOpen.AnonymousMethod__0() Line 343	C#
 	Microsoft.VisualStudio.Shell.UI.Internal.dll!Microsoft.VisualStudio.PlatformUI.GetToCode.GetToCodeWorkflowViewModel.OnMruItemOpening.AnonymousMethod__0() Line 558	C#
 	WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Line 83	C#
 	WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Line 37	C#
 	WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() Line 583	C#
 	WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(object state) Line 528	C#
 	WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(object obj) Line 235	C#
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 917	C#
 	WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 185	C#
 	WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() Line 441	C#
 	WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() Line 2276	C#
 	WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 2529	C#
 	WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 345	C#
 	WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) Line 494	C#
 	WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Line 104	C#
 	WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Line 37	C#
 	WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Line 1445	C#
 	WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Line 398	C#

Expected Behavior:

Actual Behavior:

@Shyam-Gupta
Copy link
Member

I am also hitting this issue frequently with latest IntPreview build while debugging a WinForms designer project.

jmarolf added a commit to jmarolf/roslyn that referenced this issue Jul 30, 2020
@jinujoseph jinujoseph added the 4 - In Review A fix for the issue is submitted for review. label Jul 30, 2020
@jinujoseph jinujoseph modified the milestones: 16.7, 16.8.P2 Jul 30, 2020
@jmarolf jmarolf removed their assignment Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - In Review A fix for the issue is submitted for review. Area-IDE Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants