Search code examples
c#wpfmicrosoft-edgewebview2microsoft-edge-chromium

How to distribute my WebView2 WPF app by Fixed Version distribution mode?


I want to distribute my wpf app with fixed version WebView2, here is my XAML code:

XAML:

<wv2:WebView2 x:Name="webView" vm:ReceiverViewModel.PreviewData="{Binding MyData}">
    <wv2:WebView2.CreationProperties>
        <wv2:CoreWebView2CreationProperties>
            <wv2:CoreWebView2CreationProperties.BrowserExecutableFolder>
                Microsoft.WebView2.FixedVersionRuntime.87.0.664.8.x86\\EBWebView\\x86
            </wv2:CoreWebView2CreationProperties.BrowserExecutableFolder>
        </wv2:CoreWebView2CreationProperties>
    </wv2:WebView2.CreationProperties>
</wv2:WebView2>

C#:

public Receiver()
{
    InitializeComponent();
    webView.Source = new Uri(System.IO.Directory.GetCurrentDirectory() + "/Receiver.html");
}

It doesn't work. Is BrowserExecutableFolder set correctly?


Solution

  • For Fixed Version deployment, when providing a browserExecutableFolder you must specify the path to the folder containing msedgewebview.exe. In the above you likely want to specify Microsoft.WebView2.FixedVersionRuntime.87.0.664.8.x86 not the EBWebView\x86 subfolder.