MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem/Bug]: there have some error in EnsureCoreWebView2Async(ev) after query sqlite

Open
#5,289 0 comments 0 reactions 1 assignee View on GitHub

@ojasvi1450 is already working on this.

Since Jul 2, 2025.

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

Description

What happened?
string ordersn = tb_goods.Text;
if (ordersn.Contains("-") == false)
{
    MessageBox.Show("Please enter the correct order number!");
    return;
}
if (string.IsNullOrEmpty(tb_goods.Text))
{
    MessageBox.Show("Please enter the correct order number");
    return;
}
//var gf = await OrderDb.CheckOrderInfo(ordersn);
this.BeginInvoke(new Action(() =>
{
    this.ShowMsg("Querying order information, please wait...");
}));
//SQLite database query
var gf = await Task.Run(() => OrderDb.CheckOrderInfo(ordersn));
//var gf=await OrderDb.CheckOrderInfo(ordersn);
if (gf != null)
{
    //there had error when FormHome show!
    new FormHome(66, $"{baseUrl}{ordersn}").Show();
    return;
}
MessageBox.Show("Order not stored!");

In the above code, if I set

//var gf=await OrderDb. CheckOrderInfo (ordersn); 

Annotate it to open FormHome normally. FormHome has using webview2 control.
If I don't annotate it, the following error will occur
The state of the group or resource is not the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)

Image

The location of the error is

await this.EnsureCoreWebView2Async(ev);

var gf=await OrderDb. CheckOrderInfo (ordersn) It is a normal database query method, and it is correct without any issues
Note:OrderDb. CheckOrderInfo class have using interface

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

1.0.3344.0

SDK Version

1.0.3344.0

Framework

Winforms

Operating System

Windows 10, Windows 11

OS Version

No response

Repro steps
public class OrderDb
 {
     public static async Task<GoodsInfo> CheckGoodsInfo(string goodsIdOrSn)
     {
         if (Common.Pd_Soft==0)
         {
             if (Common.DbSrc.Count == 0)
             {
                 MessageBox.Show("the path is error!!");
                 return null;
             }
             var gf= await PT_CheckGoodsInfo(goodsIdOrSn, 0);
             if(gf==null && Common.DbSrc.Count==2)
             {
                 gf =await PT_CheckGoodsInfo(goodsIdOrSn, 1);
             }
             return gf;
         }
         else 
         {
             IDbFace db = GetDbContext();
             if (db == null) return null;
             GoodsInfo gf =await OtherCheckGoodsInfo(db,goodsIdOrSn);
             if(gf!=null)
             {
                 gf.PddMallId = FixMallID(gf.PddMallId);
             }
             return gf;
         }
     }

     private static IDbFace GetDbContext()
     {
         IDbFace db = null;
         if (Common.Pd_Soft == 1)
         {
             db = new MfsDb();
         }
         else if (Common.Pd_Soft == 2)
         {
             db = new DDDb();
         }
         else if (Common.Pd_Soft == 3)
         {
             db = new MryDb();
         }
         return db;
     }
     public static async Task<GoodsInfo> CheckOrderInfo(string OrderSn)
     {
         if (Common.Pd_Soft == 0)
         {

             if (Common.DbSrc.Count == 0)
             {
                 MessageBox.Show("the path is error!");
                 return null;
             }
             var gf = await PT_CheckOrderInfo(OrderSn, 0);
             if (gf == null && Common.DbSrc.Count == 2)
             {
                 gf =await PT_CheckOrderInfo(OrderSn, 1);
             }
             return gf;
         }
         else
         {
             IDbFace db = GetDbContext();
             GoodsInfo gf =await OtherCheckOrderInfo(db, OrderSn);
             if (gf != null)
             {
                 gf.PddMallId = FixMallID(gf.PddMallId);
             }
             return gf;
         }
     }
     public static string FixMallID(string mid)
     {
         if (string.IsNullOrEmpty(mid)) return mid;
         return mid.Replace("pdd", "").Substring(0, 9);
     }
     private static async Task<GoodsInfo> OtherCheckGoodsInfo(IDbFace db,string goodsIdOrSn)
     {
         if (db == null)
         {
             return null;
         }
         GoodsInfo gf =await db.GetGoodsAndMallInfo(goodsIdOrSn);
         return gf;
     }
     private static async Task<GoodsInfo> OtherCheckOrderInfo(IDbFace db, string goodsIdOrSn)
     {
         if (db == null)
         {
             return null;
         }
         GoodsInfo gf =await db.GetSaleAndMallInfo(goodsIdOrSn);
         return gf;
     }
     private static async Task<GoodsInfo> PT_CheckGoodsInfo(string goodsIdOrSn,int index)
     {
         PTV2 db = Db.PTV2.InitDB(Common.DbSrc[index].path, Common.DbSrc[index].type);
         if (db == null)
         {
             return null;
         }
         var gf =await db.GetGoodsAndMallInfo(goodsIdOrSn);
         return gf;
     }
     private static async Task<GoodsInfo> PT_CheckOrderInfo(string OrderSn, int index)
     {
         PTV2 db = Db.PTV2.InitDB(Common.DbSrc[index].path, Common.DbSrc[index].type);
         if (db == null)
         {
             return null;
         }
         GoodsInfo gf =await db.GetSaleAndMallInfo(OrderSn);
         return gf;
     }
 }
public interface IDbFace
 {
    // static T InitDB();
     Task<GoodsInfo> GetGoodsAndMallInfo(string gidOrSn);
     Task<GoodsInfo> GetSaleAndMallInfo(string gidOrSn);
 }
Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Don't know

Last working version (if regression)

No response

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.