From c5222f3d51a579bb545c93c028894960e58747fc Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 26 May 2025 12:35:58 +0200 Subject: [PATCH] Fixing installer for webview2 by frizzeling around with the right installation path --- .gitignore | 2 +- src/BreCalClient/BreCalClient.csproj | 5 +- src/BreCalClient/ShipcallControl.xaml.cs | 26 ++++++-- src/BreCalClient/app.manifest | 79 ++++++++++++++++++++++++ src/Setup/Setup.vdproj | 8 +-- 5 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 src/BreCalClient/app.manifest diff --git a/.gitignore b/.gitignore index 5ce71e8..8fb8755 100644 --- a/.gitignore +++ b/.gitignore @@ -159,7 +159,7 @@ MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest +# *.manifest *.spec # Installer logs diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj index e9f16d7..76fb527 100644 --- a/src/BreCalClient/BreCalClient.csproj +++ b/src/BreCalClient/BreCalClient.csproj @@ -8,12 +8,13 @@ True BreCalClient.App ..\..\misc\brecal.snk - 1.6.4.0 - 1.6.4.0 + 1.6.7.0 + 1.6.7.0 Bremen calling client A Windows WPF client for the Bremen calling API. containership.ico BreCalClient + app.manifest diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs index 22c7582..a2a7433 100644 --- a/src/BreCalClient/ShipcallControl.xaml.cs +++ b/src/BreCalClient/ShipcallControl.xaml.cs @@ -4,9 +4,11 @@ using BreCalClient.misc.Model; using log4net; +using Microsoft.Web.WebView2.Core; using Microsoft.Web.WebView2.Wpf; using System; using System.Diagnostics; +using System.IO; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -561,18 +563,34 @@ namespace BreCalClient }; string trenzUri = $"https://aismap.trenz.de/Live/StaticDemo.aspx?site=bsmd&Zoom=13&api=usgPcOPJnvTWUPTVbfVs&apikey=demo-H6cE4SG0FG&imo={this.ShipcallControlModel?.Ship?.Imo}"; - await Dispatcher.InvokeAsync(() => { + + string userDataFolder = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "BreCalClient", "WebView2"); + + await Dispatcher.InvokeAsync(async () => { buttonPanel.Children.Add(popOutButton); placeHolderMap.Children.Add(_webView); + + _webView.CoreWebView2InitializationCompleted += (s, e) => + { + if (!e.IsSuccess) + { + MessageBox.Show($"WebView2 initialization failed: {e.InitializationException.Message}"); + return; + } + _webView.Source = new Uri(trenzUri); + }; + try { - _webView.EnsureCoreWebView2Async(null); - _webView.Source = new Uri(trenzUri); + var env = await CoreWebView2Environment.CreateAsync(null, userDataFolder); + await _webView.EnsureCoreWebView2Async(env); } catch(Exception ex) { - MessageBox.Show($"WebView2 initialization failed: {ex.Message}"); + MessageBox.Show($"EnsureCoreWebView2Async threw:: {ex.Message}"); } }); diff --git a/src/BreCalClient/app.manifest b/src/BreCalClient/app.manifest new file mode 100644 index 0000000..9ce67d2 --- /dev/null +++ b/src/BreCalClient/app.manifest @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Setup/Setup.vdproj b/src/Setup/Setup.vdproj index 35daf72..f4f0d7f 100644 --- a/src/Setup/Setup.vdproj +++ b/src/Setup/Setup.vdproj @@ -215,7 +215,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:BreCalClient.resources, Version=1.6.3.0, Culture=de, PublicKeyToken=9ce7b6b354e08ac9, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:BreCalClient.resources, Version=1.6.5.0, Culture=de, PublicKeyToken=9ce7b6b354e08ac9, processorArchitecture=MSIL" "ScatterAssemblies" { "_CD20A468610C42B89F66B4D3367A5A6A" @@ -329,15 +329,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:Bremen calling" - "ProductCode" = "8:{F6083A70-E7F6-4EB1-8448-2FF6D1245944}" - "PackageCode" = "8:{9A84EABA-1517-486A-B9BF-3854DD357267}" + "ProductCode" = "8:{89C43CE2-DE96-450E-92B3-834CD3A0C232}" + "PackageCode" = "8:{4D02DC1F-8E66-4F0B-B131-92462C33CC8A}" "UpgradeCode" = "8:{1C7FA3E4-BAB9-4911-9348-73094357FC7C}" "AspNetVersion" = "8:" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:1.6.4" + "ProductVersion" = "8:1.6.7" "Manufacturer" = "8:Informatikbüro Daniel Schick" "ARPHELPTELEPHONE" = "8:+49 (0) 421 - 38 48 27" "ARPHELPLINK" = "8:https://www.bsmd.de/"