MicrosoftEdge / MicrosoftEdge/WebView2Feedback
ContextMenuRequested 0x80070718
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
When the context menu is called repeatedly, a fatal error is thrown. And the added menu items simply disappear.
Take the standard code from the page (which has errors, but that's different):
https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/context-menus?tabs=csharp
Example: Adding custom menu items to a default context menu
Let's modify the code a bit to speed up the error:
this.WebView.CoreWebView2.ContextMenuRequested += delegate (object sender,
CoreWebView2ContextMenuRequestedEventArgs args)
{
// add new item to end of collection
CoreWebView2ContextMenuItem newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri", null, CoreWebView2ContextMenuItemKind.Command);
IList menuList = args.MenuItems;
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
// add new item to end of collection
newItem =
this.WebView.CoreWebView2.Environment.CreateContextMenuItem(
"Display Page Uri2", null, CoreWebView2ContextMenuItemKind.Command);
newItem.CustomItemSelected += delegate (object send, Object ex)
{
string pageUri = args.ContextMenuTarget.PageUri;
System.Threading.SynchronizationContext.Current.Post((_) =>
{
MessageBox.Show(pageUri, "Page Uri", MessageBoxButton.OK);
}, null);
};
menuList.Insert(menuList.Count, newItem);
};
Start the project and right-click about 50 times. Some system buffer overflows and an error is thrown:
Exception thrown: "System.Runtime.InteropServices.COMException" in Microsoft.Web.WebView2.Core.dll
Exception like "System.Runtime.InteropServices.COMException" occurred in Microsoft.Web.Web.WebView2.Core.dll, but was not handled in user code
Not enough quotas to process the command. (0x80070718)
Version
SDK: 1.0.1418.22
Runtime: 1.0.1418.22
Framework: WPF
OS: Windows 10
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Microsoft Edge WebView2 context-menu documentation linked in the report and reproduce the provided ContextMenuRequested handler, especially after repeated menu invocations. Confirm the fatal error and disappearing custom items, then identify the relevant WebView2 behavior or regression; no repository file or test is named in the 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
- Mostly clear
- Newbie friendliness
- 30/100