windows form です。
提示のWebview2の利用でソースコードですが以下のtry castchにて以下の例外が発生してしまうのですがこれはなぜでしょうか?
調べたこと
検索しましたがC# windows form に関する記事がヒットしません。
null参照がst変数に来ているかどうかを確認
表示自体はされます。
例外
いいいい 109357828712607029 Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{4D00C0D1-9434-4EB6-8078-8697A560334F}' failed due to the following error: インターフェイスがサポートされていません (0x80004002 (E_NOINTERFACE)). いいいい
ソースコード
cs
1 2 public void setStreamTimeLine() 3 { 4 Task.Run( async () => 5 { 6 string? id = null; 7 while(true) 8 { 9 Console.WriteLine("いいいい"); 10 11 List<JsonData.Post>? post = await client.getHomeTimeLine_Async(id, null, null, "10", null); 12 if(post != null) 13 { 14 Console.WriteLine(post[0].id); 15 Debug.WriteLine("あああああ"); 16 17 Program.timeLine_form.setViewTimeLine(post); 18 19 Debug.WriteLine("いいいいい"); 20 21 id = post[0].id; 22 } 23 24 25 } 26 27 28 29 }); 30 } 31
cs
1 2 string st = ""; 3 4 public void setViewTimeLine(List<JsonData.Post>? post) 5 { 6 if(post == null) 7 { 8 //onsole.WriteLine("qqq"); 9 } 10 foreach(JsonData.Post p in post) 11 { 12 13 st += getPost(p); 14 } 15 16 17 18 19 //Console.WriteLine("ああああ " +st); 20 21 Debug.WriteLine("qqqqq"); 22 try 23 { 24 //webView.Reload(); 25 webView.NavigateToString(st); 26 } 27 catch (System.Exception e) 28 { 29 Console.WriteLine(e.Message); 30 } 31 Debug.WriteLine("eeeeeee"); 32 33 } 34
こちらのサイトは確認されましたでしょうか。まだでしたら役に立つかもしれません。
https://github-com.translate.goog/MicrosoftEdge/WebView2Feedback/issues/213?_x_tr_sl=en&_x_tr_tl=ja&_x_tr_hl=ja&_x_tr_pto=sc
https://makky12.hatenablog.com/entry/2016/08/23/215348

回答1件
あなたの回答
tips
プレビュー