03-07-2021 06:33 PM
I need to have a web browser (and its contents) within the LabView environment.
The existing IWebBrowser2 uses the Internet Explorer 11 compatibility which is getting old...
As far as I know, the WebView2 control can be used only in Visual Studio or similar environment.
Is it some way that I can use it inside Labview?
Solved! Go to Solution.
03-07-2021 07:27 PM - edited 03-07-2021 08:03 PM
I haven't tried it myself, but I took a look at the documentation (https://docs.microsoft.com/en-us/microsoft-edge/webview2/ ). Based on that information, it appears you could use the .NET Windows Forms version of the control, especially since it supports the ("old") .NET Framework 4.6.2 or higher. LabVIEW supports hosting assemblies in that version of the CLR so there's a good chance you could make it work if you meet the runtime and OS requirements.
In your shoes I would download the control (https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.705.50), install the WebView2 runtime and supported version of Edge and try it out. Looking inside the nuget package (its just a zip), I can see you're possibly after the Core and WinForms assemblies. But a trial would be needed to clarify any other dependencies (.NET or native).
03-08-2021 04:44 AM
Thank you @tyk007,
I have already done that.
Unfortunately, the WebView2 runtime does not "add" some controls in .net controls, so that I can handle them inside LabView...
Thanks again,
03-08-2021 12:06 PM
Maybe you could be more specific on:
- what you have done so far
- what you are trying to achieve
- your existing code that demonstrates your progress.
Otherwise general questions won't get you a lot of detailed answers.
03-16-2021 09:09 AM - edited 03-16-2021 09:11 AM
Thank you tyk0007,
I tried to read some webpage, for example (https://tv.yousee.dk/tv-guide.com) by using the "WebBrowser" form the "System.Windows.Forms (4.0.0.0)" .net control.
The answer was that "...it's no longer support this browser. We recommend that you use the latest version of Google Chrome."
I have already installed the WebView2 runtime, expecting that it will "add" some controls in .net controls, so that I can handle them inside LabView.
And the question is: Is there a way that I can use the "WebView2" .net controls (which support the modern browser environment) inside Labview?
Thanks again,
04-27-2021 09:53 PM - edited 04-27-2021 09:56 PM
I just got this working. I followed what Microsoft says here and installed the runtime. I then downloaded the webview2 package from the nuget repository. Once that was done i change the nupkg extension to .zip and then unzipped it. I then added a .net control on the LV front panel. I linked it to the webview2 control, and shown below is the block diagram with some comments.
edit: you can probably remove the while loop around the CoreWebView reference. That was added before I got the wait on the async call to work correctly and I didn't remove it.
Hope this helps:
04-28-2021 11:23 AM
As an update, i'm finding the method used in my previous post sometimes hangs up. I'm guessing it has to do with the synchronization context of the Wait() method but I can't be sure.
Either way, using the source property to initialize the browser and then polling for a valid reference seems to work more consistently:
04-28-2021 03:17 PM
Thank you!
It is working!
Although it has some side effects... The folders visibility is missing when you want to open (using "Ctrl+O") for example a file!
Some times also the LabView freezes...
But in any case it is a good start!!!
Thank you again!
04-28-2021 03:52 PM - edited 04-28-2021 04:02 PM
@yorphanos wrote:
Thank you!
It is working!
Although it has some side effects... The folders visibility is missing when you want to open (using "Ctrl+O") for example a file!Some times also the LabView freezes...
But in any case it is a good start!!!
Thank you again!
Please see me latest reply, not the one you marked as an answer. Does that freeze up as well? I had better results with that.
Very interesting about the open file dialog...Not sure what's going on there.
Edit: I removed the CLFN calls which are being used to set the DLL paths. I then copied the WebView2 DLLs and the Releases directory into C:\Program Files (x86)\National Instruments\LabVIEW 2019. This works. That means the problem is being caused by the calls that are adding paths to the DLL search path.
So you can either troubleshoot that, or just copy the DLLs into the LabVIEW directory to make it work in the development environment, then remove the CLFNs. This is a bit ugly having to copy into C:\Program Files but it's what we're stuck with unless the WebView2 project owners allow the path to be set programmatically.
04-28-2021 04:19 PM
I can't find the ".net Constructor" for the "Uri" Constructor Node...
In which Assembly / Object can that be found?