MicrosoftEdge / MicrosoftEdge/WebView2Feedback

BadImageFormat Exception on launching WebView2

Open
#3,313 6 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description
We launch a standard WinForm containing an embedded WebView2 instance for different page URL's (logging in, information display, etc.). Our product/codebase is an Outlook Add-On written in .Net.

For most users, the installation and runtime work fine. But for some, with no identifiable pattern, we get the following exception upon trying to launch the form containing the WebView2 control:

System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateCoreWebView2EnvironmentWithOptions(String browserExecutableFolder, String userDataFolder, ICoreWebView2EnvironmentOptions options, ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler environment_created_handler)
at Microsoft.Web.WebView2.Core.CoreWebView2Environment.d__3.MoveNext()

Note in some instances uninstalling the existing WebView2 runtime and reinstalling solves the problem. But again for some it does nothing. One client found that rebuilding the user's desktop profile fixed the problem (but again, not for all). We have tried installing both the 32bit and 64bit WebView runtimes to no avail.

Version
SDK: Varies (older versions) but we just tried the latest 1.0.1587.40 with no success
Runtime: Evergreen instance as installed by the distributable MicrosoftEdgeWebview2Setup.exe. Also tried current fixed x86 and x64 versions.
Framework: WinForms, .Net running inside Outlook
OS: Windows 10 (also seen on Windows 7 before support was deprecated)

Repro Steps

Just for reference, this is the code used to initialize the WebView control instance:

var webView2Environment = CoreWebView2Environment.CreateAsync(null, userDataFolder).Result;
await webBrowserSFLogin.EnsureCoreWebView2Async(webView2Environment);

where webBrowserSFLogin is an instance of WinForms.WebView2 component

Screenshots

Additional context

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.