1

Topic: InvalidOperationException for solution with file opened

Getting System.InvalidOperationException in ViEmu 3.7.6 and Visual Studio 2017 (15.9.3). Steps to reproduce:
- create new solution in Visual Studio, open any file in it and close Visual Studio without closing the editor.
- try to load this solution in Visual Studio. On solution load VS is trying to open the editor with file that was left opened and shows exception alert.

System.InvalidOperationException: "GetTextViewLineContainingBufferPosition called before view is fully initialized."

Call Stack (truncated):
   Microsoft.VisualStudio.Platform.VSEditor.dll!Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.Microsoft.VisualStudio.Text.Editor.IWpfTextView.GetTextViewLineContainingBufferPosition(Microsoft.VisualStudio.Text.SnapshotPoint bufferPosition)
Microsoft.VisualStudio.Platform.VSEditor.dll!Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.GetTextViewLineContainingBufferPosition(Microsoft.VisualStudio.Text.SnapshotPoint bufferPosition)
Microsoft.VisualStudio.Platform.VSEditor.dll!Microsoft.VisualStudio.Text.MultiSelection.Implementation.SelectionUIProperties.TryGetContainingTextViewLine(out Microsoft.VisualStudio.Text.Formatting.ITextViewLine line)
Microsoft.VisualStudio.Platform.VSEditor.dll!Microsoft.VisualStudio.Text.MultiSelection.Implementation.SelectionUIProperties.ContainingTextViewLine.get()
Microsoft.VisualStudio.Platform.VSEditor.dll!Microsoft.VisualStudio.Text.Editor.Implementation.CaretElement.ContainingTextViewLine.get()
VSHub.dll!VSHub.ViEmuCaret.CalcCaretSize()
VSHub.dll!VSHub.ViEmuCaret.SetCaretType(nglib.ViCaretShape caret)
VSHub.dll!VSHub.ViEmuCaret.Initialize(VSHub.ViEmuView _qView)
VSHub.dll!VSHub.ViEmuView.InitializeWpfInterfaces()
VSHub.dll!VSHub.ViEmuViewManager.TextViewCreated(Microsoft.VisualStudio.Text.Editor.IWpfTextView qTextView)

2

Re: InvalidOperationException for solution with file opened

I got this one too.  ViEmu VSIX version is 3.7.6, but the settings box shows v3.8.0 (not sure if that means anything or not).  Update to VS2017 15.9.4 also exhibits the problem.  I've tried disabling other editor extensions and just leaving ViEmu enabled, but it still throws the dialog.

Here's the pertinent entry from the ActivityLog.xml file:

System.InvalidOperationException: GetTextViewLineContainingBufferPosition called before view is fully initialized.&#x000D &#x000A
   at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.Microsoft.VisualStudio.Text.Editor.IWpfTextView.GetTextViewLineContainingBufferPosition(SnapshotPoint bufferPosition)&#x000D &#x000A
   at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.GetTextViewLineContainingBufferPosition(SnapshotPoint bufferPosition)&#x000D &#x000A
   at Microsoft.VisualStudio.Text.MultiSelection.Implementation.SelectionUIProperties.TryGetContainingTextViewLine(ITextViewLine&amp line)&#x000D &#x000A
--- End of stack trace from previous location where exception was thrown ---&#x000D &#x000A
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)