Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinForm Sample - unable to run due to error ('Object reference not set to an instance of an object.') #42

Open
anilgenius opened this issue Jun 21, 2020 · 16 comments

Comments

@anilgenius
Copy link

in the winform sample system.nullreferenceexception came on
line
this.Controls.Add(this.webView2Control);

@MinChanSike
Copy link

same error, System.NullReferenceException: 'Object reference not set to an instance of an object.'
Building on Visual Studio 2019

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 WebView2WindowsFormsBrowser.BrowserForm.InitializeComponent() in ...\WebView2Samples\WebView2WindowsFormsBrowser\BrowserForm.Designer.cs:line 215

@champnic
Copy link
Member

Thanks for trying out the sample apps! Can you expand a bit on what you were trying to do when you experienced this error? Is there a specific action within the app that led to this, or was it on launch?

@MinChanSike
Copy link

Application could not launch, it throw System.NullReferenceException on Form InitializeComponent .
After installation Microsoft Edge BETA Version 84.0.522.26 on computer, fixed and working now.
Thanks.

@LukeOwlclaw
Copy link

Using "Version 84.0.522.40 (Official build)" the problem is still present.

@champnic
Copy link
Member

@LukeOwlclaw Can you tell me what channel that Edge build is? What version of the SDK are you using? Could you add some repro steps that led to that error for you?

@MinChanSike Glad the issue resolved for you!

@LukeOwlclaw
Copy link

@champnic I just installed Edge and did not change the channel. Then I created a WinForms C# project (.NET Framework 4.7.2), installed WebView2 NuGet version 0.9.515-prerelease (because that is the latest version which supports my Edge version), dropped a WebView2 component on the form, and hit run ==>
image

@champnic
Copy link
Member

@LukeOwlclaw Are you using the stable channel of Edge? If so you need to use a Canary or Dev build of Edge. Or you can use the WebView2 Runtime.

I just tried your steps locally (Using 0.9.515-prerelease, VS 2019 16.6.2, WV2RT 85.0.564.8) and created a WinForms app, dropped the control, and it worked fine.

@LukeOwlclaw
Copy link

Yes, I am using the stable channel. It is currently at 84.0.522.
The release notes for the WebView2 version I am using (0.9.515-prerelease), states:

minimum Microsoft Edge version 84.0.515.0.

So it should work, shouldn't it?

@champnic
Copy link
Member

Unfortunately we don't support the stable channel, only the Canary/Dev/Beta and the Runtime. @liminzhu has more details here: MicrosoftEdge/WebView2Feedback#341 (comment)

@LukeOwlclaw
Copy link

@champnic Thanks for the link. Though I do not understand why the distribution channel matters if the release version is exactly the same. But I guess it'll come all together once it is released...

@erpcto
Copy link

erpcto commented Oct 14, 2020

I have the same problem
version 0.9.628
Dev channel

@erpcto
Copy link

erpcto commented Oct 14, 2020

QQ图片20201014162434

@champnic
Copy link
Member

champnic commented Oct 14, 2020

@erpcto Is your issue with the sample app or your own app?

@erpcto
Copy link

erpcto commented Oct 15, 2020

@erpcto Is your issue with the sample app or your own app?

This exception is prompted when my new program references the control and runs.

@champnic
Copy link
Member

What version of Edge/Runtime are you using? It's possible you're hitting MicrosoftEdge/WebView2Feedback#535.

@erpcto
Copy link

erpcto commented Oct 15, 2020

I use the Dev channel

What version of Edge/Runtime are you using? It's possible you're hitting MicrosoftEdge/WebView2Feedback#535.
I use the Dev channel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants