question

VernonMarsden-2934 avatar image
0 Votes"
VernonMarsden-2934 asked IlijaDimitrov-8862 answered

WebView2 WinForms c# "3. Getting Started" Errors ?

Hello;

I am at 'Step 3 - Create a single WebView'

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

But when I compile program I get the following error;

 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); 

How can I get past this error ?

Thanks for yur Help...

windows-forms
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TianyuSun-MSFT avatar image
0 Votes"
TianyuSun-MSFT answered

Hello Vernon,

Thank you for taking time to post this issue in Microsoft Q&A forum.

This issue is caused by not choosing appropriate Platform target, please go to the properties page of your Winform project (right-click > Properties), then click Build > Platform target and choose x64 then press F5 to test again.

32190-1.png

Sincerely,
Tianyu


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



1.png (17.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

VernonMarsden-2934 avatar image
0 Votes"
VernonMarsden-2934 answered

Thank you TianyuSun !

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IlijaDimitrov-8862 avatar image
0 Votes"
IlijaDimitrov-8862 answered

On My app this doesn't work.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.