MicrosoftEdge / MicrosoftEdge/WebView2Feedback

CapturePreviewAsync exception

Open
#2,087 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description
System.InvalidOperationException : 'CoreWebView2 members cannot be accessed after the WebView2 control is disposed
But WebView2 is not disposed

Version
SDK:
Microsoft.Web.WebView2 1.0.1133-prerelease
Microsoft.Web.WebView2.DevToolsProtocolExtension 1.0.824
Framework: WinForms
OS: Win10

Repro Steps

private async void CopieWebBitmap()
{
            MemoryStream ms = new MemoryStream();            
            await webBrowser1.CoreWebView2.CapturePreviewAsync(CoreWebView2CapturePreviewImageFormat.Jpeg, ms);            
            Global.xbrowserImage = new Bitmap(ms);
            ms.Close();
            ms.Dispose();
}

private void webBrowser1_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
        {
            CopieWebBitmap();         
        }

Screenshots

Additional context

AB#37874270

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CopieWebBitmap method and webBrowser1_CoreWebView2InitializationCompleted callback in the reported WinForms reproduction. Run the example with Microsoft.Web.WebView2 1.0.1133-prerelease and the listed DevToolsProtocolExtension version, then inspect when the WebView2 control is initialized or disposed relative to CapturePreviewAsync. Done means the lifecycle condition is reproduced and documented with a minimal explanation or confirmed product issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.