Home > front end >  Including WebView2 fixed version runtime distribution into project
Including WebView2 fixed version runtime distribution into project

Time:10-19

I'm about to distribute a fixed version of WebView2 with my project. According to the Microsoft guide "Details about the Fixed Version runtime distribution mode" after downloading [1] and decompressing [2] the package I have to include binaries into my project [3] and indicate path the fixed version binaries when creating WebView2 environment [4].

The decompressed folder contains 169 files. Which files should I include and how do I include them?

I'm using .Net Framework 4.8. Currently I get following error in Visual Studio: "The type or namespace name 'Web' does not exist in the namespace 'Microsoft'"

CodePudding user response:

Generally we recommend using the Evergreen distribution model. It will save disk space on the end user's machine since its shared with other apps using evergreen WebView2 and its automatically kept up to date for you, unlike Fixed Version. You can read more about the pros and cons of both approaches.

If Fixed Version makes the most sense for your application, you need to ensure that all of the files in the cab package are on the disk somewhere for your app to reference them. If you are using something to build an installer, it should let you reference the folder of the Fixed Version files to have placed in the install path of your application.

The error about Web does not exist in Microsoft sounds like a missing reference to the WebView2 nuget package. Make sure you are also installing the WebView2 assemblies and loader files as described on Files to Ship With the App. These are SDK files that must be included in addition to the Fixed Version WebView2 Runtime files described above.

\<myApp>
    \Microsoft.Web.WebView2.Core.dll
    \Microsoft.Web.WebView2.Winforms.dll
    \Microsoft.Web.WebView2.WPF.dll
    \runtimes
        \win-arm64\native\WebView2Loader.dll (arm64)
        \win-x64\native\WebView2Loader.dll (x64)
        \win-x86\native\WebView2Loader.dll (x86)
  • Related