Distribution of WebView2 user native NetForms App: is WebView2 Runtime really needed? - winforms

Due to end if IE life, I am replacing the WebBrowser (IE based) control in our native .net forms app (c#) to Microsoft.Web.WebView2.WinForms.WebView2.
The distribution page says, the user needs to install the WebView2 Runtime, which is about 100 MB!
My question, is this really needed? Isn't it enough to have the MS Edge installed (which is on EVERY Windows 10 machine)?
This page says:
Prerequisites: Ensure you install the following list of pre-requisites before proceeding. WebView2 Runtime or any Microsoft Edge Insider (preview) Channel (Beta, Dev, or Canary) installed on a supported OS (currently Windows 10, Windows 8.1, and Windows 7).
However, I am not sure if Edge Insider is a normal user's Edge Browser?
So, do I really need to distribute 100MB WebView2 Runtime (some of our customers are offline users) together with my App Installer (which uses WinForms.WebView2 control to display HTML pages inside my native App), or it's enough if MS Edge is installed on those systems?

The answer is: Yes, you need to install the WebView2 Runtime! The version of Edge installed on user's machines is NOT insider channel - it's the Stable channel.
Although you can use the Edge Insider channel, this is is not recommended except for developing, since only developers has this version.
To quote the page you linked to: "Microsoft Edge Stable channel isn't supported for WebView2".

Yes, you really need to distribute WebView2 Runtime. From the doc you link, you can find the reasons:
Under this paragraph Runtime or browser support during development or production, you can find that:
A production release of a WebView2 app can only use the WebView2 Runtime as the backing web platform, not Microsoft Edge.
The pre-installed browser on Windows 10 is Edge Stable Channel, most people won't install Edge Insider (preview) Channel, and:
Microsoft Edge Stable channel isn't supported for WebView2

Yes, include the WebView2 runtime in your distribution kit.
If you include the WebView2 Evergreen Bootstrapper in your kit, it will fetch the latest evergreen embedded browser. It's intended to be future-proof even if you don't update your kit for a while.
My kit installs correctly on W10, W7SP1, W8.1, WS2016, and WS2019 when I include the <2MiB bootstrapper and run it.
And, your installer can detect whether WebView2 is already installed, and skip reinstalling it. I hope everybody writing an installer will do that. If we do, then our users will be spared a reinstallation for each new WebView2-using app.
This little Inno Setup code stanza detects it correctly for me. Returns True when it's necessary to run the WebView2 installer.
function WebView2IsNotInstalled: Boolean;
var Pv: String;
var key64: String;
var key32: String;
begin
key64 := 'SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}';
key32 := 'SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}';
Result := True;
if RegQueryStringValue(HKEY_LOCAL_MACHINE, key64, 'pv', Pv) then
begin
Result := 0 = Length(pV);
end
else begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, key32, 'pv', Pv) then
begin
Result := 0 = Length(pV);
end;
end;
end;
(Please doublecheck this code: I am not an installer whizz.)

Related

Windows WebView2 access local files exception raised

I am testing the WebView2 control and want to access local files instead of presenting a remote website. I am using the SetVirtualHostNameToFolderMapping method but get an exception specifying that the interface is not support maybe because an old version of the control or an old version of the runtime. I am using the most recent version of both (88.0.705.81 for the runtime and 1.0.790 for the WebView control) so not sure why I get the exception. Any help/ideas?
This is the line of code I get the exception on:
webView.CoreWebView2.SetVirtualHostNameToFolderMapping("web.example","web",CoreWebView2HostResourceAccessKind.Allow);
This is the exception I get:
An unhandled exception of type 'System.NotImplementedException' occurred in Microsoft.Web.WebView2.Core.dll
Unable to cast to Microsoft.Web.WebView2.Core.Raw.ICoreWebView2_3.
This may happen if you are using an interface not supported by the version of the WebView2 Runtime you are using.
For instance, if you are using an experimental interface from an older SDK that has been modified or removed in a newer runtime.
Or, if you are using a public interface from a newer SDK that wasn't implemented in an older runtime.
SetVirtualHostNameToFolderMapping requires WebView2 Runtime version build 721 or newer. The feature is still in the prerelease SDK package and requires a recent canary channel Edge browser as your WebView2 Runtime.
Finding the version
You can see in the SetVirtualHostNameToFolderMapping docs the bottom of the page says it applies to SDK versions 1.0.721 and 1.0.790. And as the version doc notes, the WebView2 Runtime version that corresponds to an SDK version has a matching build number. So this new feature requires at least WebView2 Runtime version 89.0.721.0 or greater.
Prerelease vs release package
You are using the latest version of WebView2 Runtime which matches the stable channel of the Edge browser and the code for SetVirtualHostNameToFolderMapping hasn't made it to the stable channel yet. That's why its still only in our prerelease SDK package not the release SDK package. To try it out for now, you'll need to use the Edge browser canary channel as your WebView2 Runtime.

Microsoft Edge 84 released but WebView2 is not working as promised

I was waiting for Microsoft Edge 84 to be released so that WebView2 is included as they promise.. but after updating MEdge WebView2 is not working...
For example CoreWebView2Ready never fired and WebView2 is showing nothing and it is throwing exception on resize!!
WebView2 is working fine only when installing Canary channel version on target machine.
Any help will be appreciated.
Regards,
I've used 0.9.515-prerelease and as stated in https://learn.microsoft.com/en-us/microsoft-edge/webview2/releasenotes#09515-prerelease it requires Microsoft Edge 84 or higher.
In real it requires Evergreen WebView2 Runtime Installer to be distributed to work on the target machine.
The other way to make it work without WebView2 Runtime Installer is to install Canary channel on target machine which is now on version 86.
Regards,

Is Driver exe for New Microsoft Chromium Edge Available?

Does anyone know whether Driver exe for New Microsoft Chromium Edge Available ?
If Yes, please share link.
Thanks.
Yes, it can be found here:
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads
It's version 75 but I've been testing it out and it works fine with Edge 76. Make sure that you have the correct Edge executable on your path depending on whether you have Dev or Canary.
Dev:
C:\Program Files (x86)\Microsoft\Edge Dev\Application\
Canary:
C:\Users\boni\AppData\Local\Microsoft\Edge SxS\Application\
There's a bit more info on my other answer:
I wouldn't recommend testing Canary, as it's unstable and it changes so fast, maintaining results will not be fun. I'm testing Dev and I'll switch to Beta when that's released.
Just a point regarding Dmitri's answer about market shares:
While accurate, they are global figures, so may be entirely irrelevant to what you're testing. If for example you're developing web applications for businesses, it's not unusual to find that the vast majority of your users are on IE or Edge, because companies have policies about only using Microsoft browsers. Sometimes this is about perceived security, but more often than not, it's about supporting legacy systems and documents, which can only be viewed in IE or chromium Edge's IE mode.
I would not go for automation till official release of the EdgeChromium-based browser from Microsoft, moreover looking into current browser market share I don't think you should be investing any efforts into it.
Chrome 61.75%
Safari 15.12%
Firefox 4.92%
UC Browser 4.22%
Opera 3.15%
IE 2.8%
Edge 2.15%
Others 5.89%
Just in case if you still want to assess the EdgeChromium automation the driver is available since 24th of April 2019 at normal Edge Driver downloads page
For example direct link for MS Edge 75 driver:
https://msedgecdn.azurewebsites.net/webdriver/index.html

Unable to Deploy WP7 SDK Application on Windows Phone 8 Through VS2012

I have Registered my device for developer.
But after choosing device in VS2012 and start deploying , It Gives error .
Unable to install application. The maximum number of developer applications on this phone has been reached. Please uninstall a developer application and try again.
I am new to deployment on device . Please suggest .
Do you happen to have multiple Windows Phone 8 devices? It turns out that if you register two devices under the same name, this problem arises. I had registered two Windows Phone Devices for development, but I hadn't given them a unique name (they were both named the default, which is Windows Phone, I think). On the first device, I had multiple test apps installed and, obviously, on the second device, nothing was installed, hence my frustration regarding the error. I did the following to make it work:
Remove the phone(s) from the dev portal,
Unregister both devices using Windows Phone Developer Registration.
Rename the devices, making sure their names are not the same.
Re-register the phones again, now with new, unique names.
I hope it works for you as well.
Uninstall the unwanted applications from the device.
Restart the device
Try to deploy the solution. It will work now.
It means you have installed three(3) testing app. windows phone have limit of max 3 app installation for debug.
Uninstall one of your previously installed application.
Now deploy your new application again.
Hope will work now.

Differences between ScheduledTaskAgent for Windows Phone 8 and 7.1

I have a big problem.
I wrote an app for Windows Phone 7.1+, and it's also published on Windows Phone Store:
this app works well for Windows Phone 7.1 and also for Windows Phone 8, and there were no problems during app submission process (who also declares that my app is fully compatible with any OS since Windows Phone 7.5).
The problem is related only to my Scheduled Agent, which runs perfectly on Windows Phone Mango (7.1), but it is not firing at all on Windows Phone 8 (I've also tested my app on real devices, with both the OS').
When I upgraded to Visual Studio 2012 (Express for Windows Phone), I've noticed that it is possibile to add two different types of ScheduledTaskAgent project: one for Windows Phone 7.5 and one for Windows Phone 8 (obviously it wasn't so in Visual Studio 2010...and I used the only one available = the first) !
Dou you think this can be the reason while the scheduled agent is not working in WP8?
What's the difference between the two projects types?
How to manage (in code I mean) two projects of that type? Is it possible?
How can I choose which task I have to register (see code below)?
Will the submission process fail with two ScheduledTaskAgent projects (I think so)?
This is the critical part of the code, when I'm registering my task at startup:
PeriodicTask newTask = new PeriodicTask("MyTaskID");
newTask.Description = "my Description";
ScheduledActionService.Add(newTask);
#if DEBUG
Microsoft.Phone.Scheduler.ScheduledActionService.LaunchForTest("MyTaskID", TimeSpan.FromSeconds(5));
#endif
Thank you in advance.
The only difference between the two project types is (1) the Windows Phone 8 one targets Windows Phone 8 instead of 7.1 and (2) it references the Windows Phone 8 SDK instead of the Windows Phone 7 dlls.
I have an application where I have two projects (7.1 and 8.0). I also have two background agent projects (7.1 and 8.0) and I share code between them using linked files. I reference the 8.0 agent from the 8.0 project and the 7.1 agent from the 7.1 project. I used this example as a best practice for having the two versions of code.
You do not want to reference two agents since that will not work.
If you remove the #if DEBUG does your agent get called when you're debugging?
First make sure you got the proper reference in app manifest file.
<ExtendedTask Name="BackgroundTask">
<BackgroundServiceAgent Specifier="ScheduledTaskAgent" Name="MyApp.Agent" Source="MyApp.Agent" Type="MyApp.Agent.ScheduledAgent" />
</ExtendedTask>
Second the Agent library must be referenced in the main app project.
Third, make sure you are not exceeding the allowed running time or memory allocation. In WP8 the cap for background agent was raised to 11MB. Also there is a limit of app with registered background tasks, so it might be possible that there was no free slot for your task with bg agent.

Resources