WebView2 WinForms c# Getting Started Errors ?

New Contributor

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...

5 Replies

@vmars316 Thanks for reaching out, and welcome to our Insider community! I've reached out to our WebView feature owner, and will let you know if/when they have thoughts to share.

 

Fawkes (they/them)
Program Manager & Community Manager - Microsoft Edge

@Deleted 

Please note this question is also outstanding 

How to Navigate on 'go Button Click' in winView2 ? 

https://docs.microsoft.com/en-us/answers/questions/129125/how-to-navigate-on-gobutton-click-in-winview2.html 

Thanks

@vmars316 Thanks for your patience. Here are the team's thoughts on your first question:

 

  1. You may be using the release package and not the pre-release package of the .NET WebView2
  2. There is a known bug based on configurations with our previous package. If you upgrade to the pre-release version of the newest package we released last week, it should work. (Release Notes for Microsoft Edge WebView2 for Win32, WPF, and WinForms - Microsoft Edge Development ...)

If you are still running into issues, you can check out our WebView2-specific feedback repo here:

MicrosoftEdge/WebView2Feedback: Feedback repo for Microsoft Edge WebView2 (github.com)

 

And it looks like someone from the team already addressed your second question, but let us know if you still have additional questions!

 

Fawkes (they/them)
Program Manager & Community Manager - Microsoft Edge

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.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

Visual Studio 2019

Net Framework 4.8

Nuget: Microsoft.Web.WebView2 1.0.721-prerelease

 

 

Only When I click Exit button I have this error. From Microsoft Store Team said that any of the buttons don`t work and the rejected my app. 

You can install my first version on this link published 30.11.2020 and there was no problem to publish.

Download link: http://go.microsoft.com/fwlink/?LinkId=532540&mstoken=

Enter this code: PJDD9-GWPJ9-C4QM7-67R34-2CYYZ The Umbrella website: http://11323444.450552.renderforestsites.com

Only when I click Exit (X) Button I have this same Error.

 

Visual Studio 2019

NET Framework 4.8

Microsoft.Web.WebView2 1.0.721-prerelease

 

 

From Microsoft Store I get this argument for the rejection: Unfortunately, we can’t test your product, the product's primary functions are not usable. 

Steps to reproduce:

1. Launch the app.

2. Notice that selecting any of the options shows the error "Unhandled exception has occurred in your application".

If you want to see my first version of my app click on the link an insert this code:PJDD9-GWPJ9-C4QM7-67R34-2CYYZ. 

https://t.co/tso11BqC0H?amp=1