I am planning to add functionality to a small application developed in VB6 which will check the pre-requisites for a WPF application that uses WebView2 control. This small application will run first and determine if the "Microsoft Edge WebView2 Runtime" or "Microsoft Edge Insider Channels" is installed? If it founds one of these options then allows to run the WPF application otherwise it will show an error to install the pre-requisite.
My requirement is to keep the VB6 app because this app is already checking the different versions of the .NET framework.
Please help me, how to achieve this?
Thanks.
Apologies I don't know what it looks like in VB, but you should be able to use the static methods CoreWebView2Environment.GetAvailableBrowserVersionString
and CoreWebView2Environment.CompareBrowserVersions
. GetAvailableBrowserVersionString will tell you which WebView2 Runtime version would be used if a WebView2 were created and you can use CompareBrowserVersions to check if the version you get from GetAvailableBrowserVersionString is higher than your minimum required version.
string availableVersion = null;
try
{
availableVersion = CoreWebView2Environment.GetAvailableBrowserVersionString();
}
catch (WebView2RuntimeNotFoundException)
{
}
if (availableVersion != null &&
CoreWebView2Environment.CompareBrowserVersions(availableVersion, "100.0.0.0") >= 0)
{
System.Console.WriteLine("Minimum version found");
}
else
{
System.Console.WriteLine("Minimum version not found.");
}