WebView2 Deployment

Hal Roenick 20 Reputation points
2026-07-04T13:23:05.03+00:00

Hello,

I recently converted a VB.net (VS 2022) Desktop Application from a WebBrowser control to a WebView2 Control. I have everything working just as I would like. When I create an installer and include all of the dependencies then install my application, the application will not display the form that has the WebView2 control on it and I get this error...

Microsoft.Web.WebView2.WinForms, Version=1.0.4071.0, Culture=neutral, PublicKeyToken=2a8ab48044d2601e' or one of its dependencies. The system cannot find the file specified.

When I look up this error, it tells me I am missing a dependency, but I have created a setup and included all of the dependencies. I have also tried to install the Evergreen version of the WebView2 files and that installer tells me all the WebView2 dependencies are already installed on my PC. Does anyone have a suggestion?

Thank you.

Developer technologies | VB

Answer accepted by question author
Nancy Vo (WICLOUD CORPORATION) 8,155 Reputation points Microsoft External Staff Moderator
2026-07-07T07:07:41.8566667+00:00

Hello @Hal Roenick ,

Thank you so much for sharing your findings.

Since you cannot accept your own answer, I’m posting this issue and its solution to help anyone else who may encounter the same problem.

In addition to the solutions you found, I recommend an additional workaround to help keep your application aligned with standard Windows security practices:

  1. Managing the installation folder and permissions.

Moving the application to the root of the system drive bypasses Windows security, but it is much safer to keep 32-bit apps in the standard Program Files (x86) folder. You can refer to these code example:

Dim userDataFolder As String = System.IO.Path.Combine(Application.LocalUserAppDataPath, "EBWebView")

Dim environment As Microsoft.Web.WebView2.Core.CoreWebView2Environment = Await Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateAsync(Nothing, userDataFolder, Nothing)

Await WebView21.EnsureCoreWebView2Async(environment)
  1. If you ever want to move your DataGridView back to a separate dialog, you absolutely can. When WebView2 turns into Nothing in VB.NET, it is usually because the code accidentally called a "ghost" copy of the form instead of the real one you are looking at. Passing a direct reference of your open form to the new dialog will prevent the control from losing its instance.

Again, thank you so much for sharing your time and experience.

If any part of my explanation helped address your question, I would greatly appreciate it if you could follow the instructions here. This can also help other community members facing similar scenarios.

Was this answer helpful?

2 people found this answer helpful.

4 additional answers

Sort by: Most helpful
  1. Hal Roenick 20 Reputation points
    2026-07-06T18:27:27.3633333+00:00

    Hello everyone and thank you for the replies and ideas on this topic. With the help of a friend, we seem to have figured out where the problem is/was...Please understand that I am a self taught programmer and not nearly as proficient as most who likely replied to my post, so please let me know if you see something wrong with my assessment, but this is what we found.

    My experience has led me to believe that Microsoft recommends that 64 bit executable programs be installed in the Program Files (x86) folder. I have run this application at 32 bit and 64 bit in that folder for almost 15 years with no issues. Shortly after I posted this issue to this list, I put the "Await WebView21.EnsureCoreWebView2Async(Nothing)" statement into its own Try/Catch statement that I found on the web and started capturing a different error that told me that the program could not "write to the folder where the program is installed". This even though I knew the program needed to be told not to write in the folder where the .exe resides, but to point it to the users AppDataPath as shown here...

    Dim userDataFolder As String = System.IO.Path.Combine(Application.LocalUserAppDataPath, "EBWebView")

    Dim environment As Microsoft.Web.WebView2.Core.CoreWebView2Environment =

    Await Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateAsync(Nothing, userDataFolder, Nothing)

    Once I changed my installation and installed my application in a folder in the root directory of the system drive, everything started working correctly. It seems the setting I tried to make above did not keep the program from writing data to the executables directory.

    One other thing that I found that was quite interesting...I have a routine in my application where a list of files that reside on-line are printed one by one automatically. The user has the ability to decide how many copies of each of those files gets printed in the "Auto Print" routine. In my earlier version of this App, the list was made in a Datagridview that resided in a different dialog than where the WebBrowser control existed, but was then each file was navigated to in the WebBrowser control for automatic printing. I found that the WebView2 control would lose it instance meaning the "WebView21.CoreWebView2" instance would become "Nothing" when the new dialog with the DGV was displayed. So, I ended up putting a new DGV onto the same dialog as the WebView2 control and simply set its "Visible" property to "False", then set it to "True" via a button in a toolbar above where the WebView2 and DGV are displayed to control the printing of those files.

    So basically what I found is, two Don'ts when using a WebView2 control...

    1. Deploy your project to a folder where Windows does not have a problem with your reading and writing to files.
    2. Do not try to use controls outside the dialog where the WebView2 resides to do any processing that needs to interact with the WebView2 control.

    Thank you again for your help and let me know if you know of a better way to resolve the issues I have described. Everyone's posts were correct in things that needed to be done, but were not what fixed my issues. I had all of the correct Prerequisites in my install program, changing the path where it was installed was the real answer, at least for me.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Hal Roenick 20 Reputation points
    2026-07-04T14:03:05.5+00:00

    From what I can tell, all of the references mentioned above are installed on my system after I have installed my application. For example, WebView2Loader.dll is installed in all 3 of the runtimes folders mentioned (win-X86, win- X64 and win-arm64) in my application. My application is set to Any PC. As I mentioned above, my application works fine in the Visual Studio environment, but as soon as I deploy it and install it on my system, the problem persists.

    The WebView2Loader.dll files are loaded in this path...

    C:\Program Files (x86)\VCAMM Software\Golf League Pro\runtimes\win-x64\native

    ...and the .exe of my application is in this folder...C:\Program Files (x86)\VCAMM Software\Golf League Pro

    Thank you

    Was this answer helpful?

    1 person found this answer helpful.

  3. AI answer

    2026-07-04T13:23:26.0933333+00:00

    The error indicates that the Microsoft.Web.WebView2.WinForms assembly (or one of its dependencies) is not being deployed with the application, even though the development machine has the Evergreen WebView2 Runtime installed.

    Two separate things must be present on the target machine:

    1. WebView2 Runtime (Evergreen or Fixed Version)
    2. WebView2 loader and .NET assemblies that your app directly references

    The Evergreen Runtime installer only installs the runtime, not the assemblies your app must ship.

    To fix deployment for a VB.NET WinForms app:

    1. Ensure WebView2 loader DLL is included
      For .NET managed apps, WebView2Loader.dll is a native, architecture-specific binary and must be shipped with the app:
         \<myApp>
             \runtimes
                 \win-arm64\native\WebView2Loader.dll (arm64)
                 \win-x64\native\WebView2Loader.dll (x64)
                 \win-x86\native\WebView2Loader.dll (x86)
      
      In Visual Studio Installer/Setup Project, explicitly add these files from the WebView2 SDK output (usually under runtimes\win-<arch>\native).
    2. Include the WebView2 .NET assemblies
      For a WinForms app, the following assemblies must be deployed alongside the EXE:
         Microsoft.Web.WebView2.Core.dll
         Microsoft.Web.WebView2.Winforms.dll
      
      Confirm that:
      • They appear in the app’s output folder on the build machine.
      • They are added as files in the installer project and installed to the same folder as your application EXE.
    3. Verify architecture alignment
      Make sure the architecture of:
      • Your app (x86/x64/AnyCPU),
      • WebView2Loader.dll variants,
      • And the installed WebView2 Runtime are consistent. For AnyCPU, include x86, x64, and arm64 loader DLLs under runtimes as shown above.
    4. If using Fixed Version runtime (optional)
      If choosing Fixed Version instead of Evergreen, the Fixed Version binaries must be packaged with the app and the environment configured before Source is set. For WinForms, this is done via CoreWebView2CreationProperties and BrowserExecutableFolder or via CoreWebView2Environment.CreateAsync in EnsureCoreWebView2Async.

    Once the installer is updated to deploy Microsoft.Web.WebView2.*.dll and the appropriate WebView2Loader.dll files with the application, the "system cannot find the file specified" error should be resolved.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

    1 person found this answer helpful.
  4. Nancy Vo (WICLOUD CORPORATION) 8,155 Reputation points Microsoft External Staff Moderator
    2026-07-06T06:57:44.2433333+00:00

    Hello @Hal Roenick ,

    Thanks for your question.

    When you use a setup tool to create an installer, it sometimes forgets to pack all the necessary files. Your installer successfully packed the helper file (WebView2Loader.dll), but it left behind the main control files: Microsoft.Web.WebView2.WinForms.dll and Microsoft.Web.WebView2.Core.dll.

    Because these two main files are not sitting next to your .exe inside your main folder (C:\Program Files (x86)\VCAMM Software\Golf League Pro), the app crashes when it tries to open the screen.

    You can refer to these following steps:

    1. Open your setup project in Visual Studio.
    2. Open your Application Folder view.
    3. Choose Add -> File...
    4. Go to your main application's bin\Release folder (or bin\Debug, wherever you last built the app).
    5. Select Microsoft.Web.WebView2.WinForms.dll and Microsoft.Web.WebView2.Core.dll and add them to the setup.
    6. Rebuild your installer and try again.

    Note: In your main VB.NET project, look at your References (or Dependencies list). Right-click Microsoft.Web.WebView2, select Properties, and make sure the setting called Copy Local is set to True.

    I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.