Issue resolved: It works when we set the application region in the App.xaml.cs or ExtendedSplash.xaml.cs files.
In a UWP application using WebView2, the CoreWebView2 method returns null after changing the region at runtime in C#
The CoreWebView2
method works fine the first time, but after changing the app region, the CoreWebView2
method returns null after initialization. Please help to fix this issue.
Code:
XAML
<muxc:WebView2 x:Name="PDFViewer" NavigationStarting="PDFViewer_NavigationStarting" Margin="0"
NavigationCompleted="PDFViewer_NavigationCompleted" Visibility="Visible"/>
CS file
PDFViewer.CoreWebView2
await PDFViewer.EnsureCoreWebView2Async();
PDFViewer.CoreWebView2.SetVirtualHostNameToFolderMapping("mi.Pdf", pdfFolder.Path, CoreWebView2HostResourceAccessKind.Allow);
I have change region in below function
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en-US";
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
CultureInfo.CurrentCulture = culture;
CultureInfo.CurrentUICulture = culture;
Exception:
3 answers
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
-