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

VSTO Excel Addin TaskPane VB.Net CoreWebView2 Will Not Populate #622

Closed
TF523 opened this issue Nov 11, 2020 · 33 comments
Closed

VSTO Excel Addin TaskPane VB.Net CoreWebView2 Will Not Populate #622

TF523 opened this issue Nov 11, 2020 · 33 comments
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@TF523
Copy link

TF523 commented Nov 11, 2020

This issue doesn't seem to be resolved from #187. I am using vb.net to attempt to place WebView2 control into an excel vsto addin task pane and I am having no luck. I have used the EnsureCoreWebView2Async to attempt to get the core object to populate and there is simply nothing that will work. Converting the following lines to vb:

C#
var env = await CoreWebView2Environment.CreateAsync (null, "C:\temp");
await webView21.EnsureCoreWebView2Async (env);
webView21.CoreWebView2.Navigate ("https://bing.com")

VB.NET
Dim env as object
env = Await CoreWebView2Environment.CreateAsync(Nothing, "C:\Test")
Await WebView21.EnsureCoreWebView2Async(env)
WebView21.CoreWebView2.navigate("https://www.bing.com")

Still the core object will not assign.
I have attempted every conceivable combination which included using the CoreWebView2CreationProperties to set the path prior to the core object assignment, and still nothing has worked.

I am working off the Microsoft.Web.WebView2.1.0.674-prerelease.

I thought that it may be the browserexcutablefolder causing it to fail, but that doesn't seem to work when I tried set that either. I am at a loss...

AB#30216412

@TF523 TF523 added the question label Nov 11, 2020
@champnic
Copy link
Member

@TF523 Is it causing any error/exception? Also I'm not sure if it was just a copy error in your post, but you need to pass ENV to EnsureCoreWebView2Async(ENV). Do you have a runtime installed (Edge Canary/Dev/Beta, or WebView2 Runtime)?

@TF523
Copy link
Author

TF523 commented Nov 11, 2020

yes it was just a copy error from my last iteration. I was trying different combinations and that was left over.

As far as the exception Initially when I tried to set the source it was giving me a write permission error just like they experienced on the other thread. When I moved to EnsureCoreWebView2Async that error went away and now the exception is object not assigned because it is nothing.

@TF523
Copy link
Author

TF523 commented Nov 11, 2020

Thanks for following up so quickly...

@TF523
Copy link
Author

TF523 commented Nov 11, 2020

Yes I have Dev version of runtime installed

@TF523
Copy link
Author

TF523 commented Nov 11, 2020

I set up a sample project to quickly test it in a vb.net form and everything works fine...

But in our TaskPane version, when I step through the code the the assignment never happens in EnsureCoreWebView2Async. It remains nothing...

@champnic
Copy link
Member

Do you have a repro app I could try out?

Another thing to try is to use the WebView2.CoreWebView2Ready event and see if that ever gets hit.

@TF523
Copy link
Author

TF523 commented Nov 11, 2020

Unfortunately I cannot provide access to the repo it is part of a much larger proprietary project.

I dont see how the event is going to get triggered the object is nothing.

I am sure our setup is good because it worked fine on the sample forms project. When it comes to the VSTO task pane I am not sure what else to try... It was hard to tell from the #187 thread, I couldn't really tell what finally got the WPF version to work for them.

@champnic
Copy link
Member

champnic commented Nov 11, 2020

Unfortunately I cannot provide access to the repo it is part of a much larger proprietary project.

Understandable.

Are you doing anything with threading, or is this all happening on your main UI thread? Or are you doing anything else besides just creating the WebView2?

I agree it looks like you are doing the right things here. I'll open a bug on our backlog and we'll try to repro and see what's going wrong.

@champnic champnic added bug Something isn't working tracked We are tracking this work internally. labels Nov 11, 2020
@TF523
Copy link
Author

TF523 commented Nov 11, 2020

No threading all on the Main UI. Called in an Async sub.

Not sure what you mean by "are we doing anything else besides just creating the webview"? The task pane houses many controls and the WebView is located on a tabbed page control container. As far as the exceptions our build is clean at this point this is the only problem. All I have done with the webview is placed it on the pane and now I am just trying to get it to work, no other navigation other than just a test call to bing...

@TF523
Copy link
Author

TF523 commented Nov 11, 2020 via email

@champnic
Copy link
Member

Thanks for the added context around how the control is being used.

The default when no exec folder is given is that the WebView2Loader.dll includes logic to see what versions of the runtime (Edge Canary/Dev/Beta or WebView2 Runtime) may be installed on the machine. It will find and use the most stable of those available. You have Dev installed, so it should be able to find and use that for any shipped version of our Nuget SDK package.

Some other things to double-check from #187:

  1. Are you setting the "Source" property on WebView2 anywhere? If you are during initialization, you need to remove that to ensure that EnsureCoreWebView2Async is the call doing the initialization to pickup the correct UserDataFolder.
  2. Is WebView2Loader.dll being deployed correctly when you run your project?

@TF523
Copy link
Author

TF523 commented Nov 11, 2020 via email

@TF523
Copy link
Author

TF523 commented Nov 11, 2020 via email

@champnic
Copy link
Member

No sorry I haven't had time to try this out myself. In general I don't have time to manually repro the issues people are running into, so I try to help as much as I can through debugging or asking for a reproducing app I can run on my machine. We have a bug on our backlog that would include one of our devs trying to reproduce this issue, but our backlog is large and I'm not sure when a dev will be able to try it out.

@TF523
Copy link
Author

TF523 commented Nov 11, 2020 via email

@TF523
Copy link
Author

TF523 commented Nov 11, 2020 via email

@TF523
Copy link
Author

TF523 commented Nov 11, 2020 via email

@TF523
Copy link
Author

TF523 commented Nov 12, 2020 via email

@TF523 TF523 changed the title VSTO Addin VB.Net CoreWebView2 Will Not Populate VSTO Excel Addin TaskPane VB.Net CoreWebView2 Will Not Populate Nov 12, 2020
@champnic
Copy link
Member

@TF523 Thanks for putting together a sample, much appreciated! I'm not seeing it though - is there a link or attachment missing? (I'm using github.com - looks like you may be using email which could have dropped an attachement?)

@TF523
Copy link
Author

TF523 commented Nov 12, 2020

https://github.com/tf523/Excel_AddIn_WebView2

@TF523
Copy link
Author

TF523 commented Nov 12, 2020

Here is the exception thrown in debugger in case email broke the link again...

https://user-images.githubusercontent.com/5530663/98882435-1349a600-2441-11eb-9263-237758d0e3fb.PNG

@champnic
Copy link
Member

Was able to repro and figured out the issue. Apparently we have a check for "DesignMode" that looks for whether or not we have a "Site", which is set on controls in the VisualStudio Designer. However, we assume that the presence of a "Site" means we are in designer, when in fact there are other circumstances that a Site is set - like the Task Pane. We are tracking a fix for this as part of #614, and will hopefully be available in the next release.

@TF523
Copy link
Author

TF523 commented Nov 12, 2020

@champnic do u know when is the next update supposed to be released?

@champnic
Copy link
Member

Probably around the end of this month.

@TF523
Copy link
Author

TF523 commented Nov 12, 2020

@champnic Is there any access to the control.site property in runtime to override it as a workaround for now, or are we dead in the water until the update???

@TF523
Copy link
Author

TF523 commented Nov 29, 2020

Nic-
Just downloaded the update and everything seems to be working great. Thank you.

@TF523
Copy link
Author

TF523 commented Nov 29, 2020

@champnic this may or may not be an issue, but I was setting up selenium to some automation testing on our embedded viewer (based on this article: https://docs.microsoft.com/en-us/microsoft-edge/webview2/howto/webdriver). Anyway I am having a tough time getting it to work as part of an add-in. Also this article is a little dated as the selenium EdgeOptions constuctor has been updated as of their a-07 update. I am probably just goobing the path executables for some reason as the add-in fires from a different location, but I was wondering if you know of anyone making this work in C# or vb.net as an add-in. Thank you...

@champnic
Copy link
Member

champnic commented Dec 1, 2020

Glad it's working now! I'm going to close this issue out, but if you see the same problem let me know.

Re: Selenium - We have an existing bug to update our docs - I just pinged the owner to see if we can update it sooner. Unfortunately I don't think I've seen or heard of anyone using selenium with add-ins yet.

@champnic champnic closed this as completed Dec 1, 2020
@ShaunLoganOracle
Copy link

ShaunLoganOracle commented Dec 1, 2020

@TF523 , re:

Just downloaded the update and everything seems to be working great. Thank you.

Which SDK and runtime bits are you using?
Thanks!

@TF523
Copy link
Author

TF523 commented Dec 2, 2020

@TF523 , re:

Just downloaded the update and everything seems to be working great. Thank you.

Which SDK and runtime bits are you using?
Thanks!

64 bit os visual studio .net 4.8

@ShaunLoganOracle
Copy link

Thanks.
More specifically, which WebView2 SDK and WebView2 Runtime (or non-stable Microsoft Edge (Chromium) Canary channel ) are you using?

@TF523
Copy link
Author

TF523 commented Dec 2, 2020 via email

@ShaunLoganOracle
Copy link

ShaunLoganOracle commented Dec 9, 2020

For others encountering this thread, in case it might help.
I ran into issues rendering content in a UserControl that contained a single WebView2 control, where the UserControl was added to the VSTO Task Pane in Excel. More specifically, there were issues trying to set the Source property or calling CoreWebView2.NavigateToString(). Those calls might be ignored or cause errors.
What I ended up doing is to defer those calls until my event handler for CoreWebView2InitializationCompleted got called.

Env:
C#, Winforms, .NET 4.8, Windows 10
SDK 1.721-prerelease
Canary/Edge 89.0.726.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

3 participants