Skip to content

CoreWebView2 uninitialized exception on startup with unsaved backup file #139

@piknockyou

Description

@piknockyou

Image

Steps to Reproduce

  1. Open Notepad++ with no documents except a new unsaved tab (e.g., "new 1")
  2. Type some text to trigger automatic backup creation (new@YYYY-MM-DD_HHMMSS)
  3. Go to Plugins → Markdown Panel → Settings:
    • Enable "Allow all file extensions"
  4. Go to Plugins → Markdown Panel:
    • Enable Synchronize with caret position
      OR
    • Enable Synchronize with first visible line in editor
  5. Close Notepad++
  6. Reopen Notepad++

Expected Behavior

Notepad++ should start normally with the Markdown Panel plugin functioning.

Actual Behavior

.NET Framework unhandled exception occurs:

System.InvalidOperationException: The instance of CoreWebView2 is uninitialized and unable to complete this operation. See EnsureCoreWebView2Async.
   at Microsoft.Web.WebView2.WinForms.WebView2.VerifyInitializedGuard()
   at Microsoft.Web.WebView2.WinForms.WebView2.<ExecuteScriptAsync>d__78.MoveNext()
   ...
   at Webview2Viewer.Webview2WebbrowserControl.<>c__DisplayClass25_0.<<ScrollToElementWithLineNo>b__0>d.MoveNext()

Environment

  • CSVLint: 0.4.7.0
  • NppMarkdownPanel: 0.9.0.0
  • Microsoft.Web.WebView2.WinForms: 1.0.3296.44
  • .NET Framework: 4.8.9323.0

Possible Root Cause

The plugin likely attempts to synchronize the caret position (via ExecuteScriptAsync) before CoreWebView2 completes initialization. This timing issue appears specific to startup when Notepad++ restores unsaved backup files—the restoration and synchronization may occur too quickly for the async WebView2 initialization (EnsureCoreWebView2Async) to complete. Regular saved files don't exhibit this issue, possibly because their normal loading sequence provides sufficient initialization time.

Suggested Recommendations

  • Ensure EnsureCoreWebView2Async completes before calling ExecuteScriptAsync or other CoreWebView2-dependent operations
  • Add initialization state checks before attempting caret synchronization during startup
  • Consider queuing synchronization requests that occur during initialization and processing them after WebView2 is ready
Full error details

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidOperationException: The instance of CoreWebView2 is uninitialized and unable to complete this operation. See EnsureCoreWebView2Async.
at Microsoft.Web.WebView2.WinForms.WebView2.VerifyInitializedGuard()
at Microsoft.Web.WebView2.WinForms.WebView2.d__78.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Webview2Viewer.Webview2WebbrowserControl.<>c__DisplayClass25_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9323.0 built by: NET481REL1LAST_25H2_C
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

CSVLint
Assembly Version: 0.4.7.0
Win32 Version: 0.4.7.0
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/CSVLint/CSVLint.dll

System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9221.0 built by: NET481REL1LAST_25H2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

System
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9321.0 built by: NET481REL1LAST_25H2_B
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9221.0 built by: NET481REL1LAST_25H2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9319.0 built by: NET481REL1LAST_25H2_B
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9221.0 built by: NET481REL1LAST_25H2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9221.0 built by: NET481REL1LAST_25H2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

NppMarkdownPanel
Assembly Version: 0.9.0.0
Win32 Version: 0.9.0.0
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/NppMarkdownPanel.dll

MarkdigWrapper
Assembly Version: 0.9.0.0
Win32 Version: 0.9.0.0
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/MarkdigWrapper.dll

PanelCommon
Assembly Version: 0.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/PanelCommon.DLL

Webview2Viewer
Assembly Version: 0.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/Webview2Viewer.dll

Microsoft.Web.WebView2.WinForms
Assembly Version: 1.0.3296.44
Win32 Version: 1.0.3296.44
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/Microsoft.Web.WebView2.WinForms.DLL

Microsoft.Web.WebView2.Core
Assembly Version: 1.0.3296.44
Win32 Version: 1.0.3296.44
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/Microsoft.Web.WebView2.Core.DLL

Accessibility
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9221.0 built by: NET481REL1LAST_25H2
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll

Markdig
Assembly Version: 0.41.0.0
Win32 Version: 0.41.1.0
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/Markdig.DLL

ColorCode
Assembly Version: 1.0.3.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/ColorCode.DLL

System.Memory
Assembly Version: 4.0.2.0
Win32 Version: 4.600.24.56208
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/System.Memory.DLL

System.Runtime.CompilerServices.Unsafe
Assembly Version: 6.0.1.0
Win32 Version: 6.100.24.56208
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/System.Runtime.CompilerServices.Unsafe.DLL

System.Buffers
Assembly Version: 4.0.4.0
Win32 Version: 4.600.24.56208
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/System.Buffers.DLL

System.Numerics.Vectors
Assembly Version: 4.1.5.0
Win32 Version: 4.600.24.56208
CodeBase: file:///C:/Program%20Files/Notepad++/plugins/NppMarkdownPanel/lib/System.Numerics.Vectors.DLL

System.Runtime
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9221.0
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions