WebView2 WinForms c# “3.Getting Started“错误?

Jiale Xue - MSFT 41,271 信誉分 Microsoft 供应商
2024-04-03T06:04:55.7133333+00:00

你好;

我在“第 3 步 - 创建单个 WebView”

https://learn.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winforms

但是当我编译程序时,我收到以下错误;

System.NullReferenceException  
HResult=0x80004003  
Message=Object reference not set to an instance of an object.  
Source=Microsoft.Web.WebView2.WinForms  
StackTrace:  
at Microsoft.Web.WebView2.WinForms.WebView2.OnVisibleChanged(EventArgs e)  
at System.Windows.Forms.Control.AssignParent(Control value)  
at System.Windows.Forms.Control.ControlCollection.Add(Control value)  
at System.Windows.Forms.Form.ControlCollection.Add(Control value)  
at WinFormsGettngStarted.Form1.InitializeComponent() in C:\Users\vmars\source\repos\WinFormsGettngStarted\Form1.Designer.cs:line 50  
  
  
From this line:  this.Controls.Add(this.webView);   
  

我怎样才能克服这个错误?

Note:此问题总结整理于: WebView2 WinForms c# "3. Getting Started" Errors ?

Windows 窗体
Windows 窗体
一组用于开发图形用户界面的 .NET Framework 托管库。
142 个问题
0 个注释 无注释
{count} 票

接受的答案
  1. Hui Liu-MSFT 46,961 信誉分 Microsoft 供应商
    2024-04-03T07:25:05.49+00:00

    感谢您抽出宝贵时间在 Microsoft Q&A 论坛中发布此问题。

    此问题是由于没有选择合适的,请转到Winform项目的属性页面(右键单击>属性),然后单击>并选择,然后再次按下以测试。Platform targetBuildPlatform targetx64F5

    32190-1.png


    如果答案有帮助,请点击“接受答案”并点赞。 注意:如果您想接收此线程的相关电子邮件通知,请按照我们文档中的步骤启用电子邮件通知。

    1 个人认为此答案很有帮助。
    0 个注释 无注释

0 个其他答案

排序依据: 非常有帮助