Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebView2Loader.dll is left out when publishing #1061

Closed
Perka1000 opened this issue Mar 10, 2021 · 8 comments
Closed

WebView2Loader.dll is left out when publishing #1061

Perka1000 opened this issue Mar 10, 2021 · 8 comments
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@Perka1000
Copy link

Perka1000 commented Mar 10, 2021

WebView2Loader.dll is left out when publishing an application that have reference to a class library with package reference to Microsoft.Web.WebView2.

Native dll is WebView2Loader.dll.deploy is missing.

Everything works fine when publishing an application with package reference to Microsoft.Web.WebView2.
Step to reproduce issue:

  1. Start VS 2019 and select create a new project.
  2. Select WPF App (.NET Framework) C#, you get a WpfApp1 project.
  3. To solution add New Project, select Class Library (.NET Framework) C#, you get a ClassLibrary1.
  4. To WpfApp1 add reference to ClassLibrary1.
  5. To ClassLibrary1 install NuGet Microsoft.Web.WebView2 (1.0.705.50).
  6. For WpfApp1 select property and select tab Publish and specify a publishing folder on hard drive.
  7. Press Publish Now button and look in publishing folder. The WebView2 assemblies and WebView2Loader.dll.deploy is left out, there is no runtimes folder.
    Thanks
    Perka

AB#32169077

@Perka1000 Perka1000 added the bug Something isn't working label Mar 10, 2021
@Rauce
Copy link

Rauce commented Mar 11, 2021

I've just tried a Nuget package update and am having the same issue with my WPF app.

This seems to be an issue with the latest 1.0.774.44 Nuget package.

See attached screenshot, the build subfolders are missing in 1.0.774.44, whereas they were there in 1.0.705.50

image

@champnic champnic changed the title WebView2Loader.dll is left out when publishing WebView2Loader.dll is left out when publishing - 1.0.774.44 Mar 18, 2021
@champnic champnic changed the title WebView2Loader.dll is left out when publishing - 1.0.774.44 WebView2Loader.dll is left out when publishing Mar 18, 2021
@champnic
Copy link
Member

@Rauce This doesn't seem to be limited to 1.0.705.50 vs 1.0.774.44, as the original issue was reported for 1.0.705.50. For 1.0.774.44 I think we consolidated the loader dlls to be in the "runtimes" folder for both .NET Framework and Core (previously they were duplicated). Regardless it seems the issue is still persisting.

@Perka1000 I've opened a bug on our backlog to take a look at this. It looks related to #730.

@champnic champnic added the tracked We are tracking this work internally. label Mar 18, 2021
@champnic
Copy link
Member

This should be fixed in SDK package 1.0.1056-prerelease. Thanks!

@Perka1000
Copy link
Author

Hi @champnic .

According to me the bug is still there.
I have tried to be more clearly about how to reproduce error "Unable to load DLL 'WebView2Loader.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)".

  1. Start VS 2019 and select create a new project.
  2. Select WPF App (.NET Framework) C#, you get a WpfApp1 project.
  3. To solution add New Project, select Class Library (.NET Framework) C#, you get a ClassLibrary1.
  4. To WpfApp1 add reference to ClassLibrary1.
  5. To ClassLibrary1 install NuGet Microsoft.Web.WebView2 (version 1.0.1020.30).
  6. In project ClassLibrary1 in class Class1 add GetBrowserVersionString method:
    public class Class1
    {
        static public string GetBrowserVersionString()
        {
            return CoreWebView2Environment.GetAvailableBrowserVersionString();
        }
    }
  1. In project WpfApp1 add project refrence to ClassLibrary1.
  2. In project WpfApp1 class MainWindow update constructor to subscribe to Application.DispatcherUnhandledException and to call Class1.GetBrowserVersionString method:
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
            var version = Class1.GetBrowserVersionString();
            MessageBox.Show($"Browser Version String {version}");
        }

        private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {            
            MessageBox.Show(e.Exception.ToString());
        }
    }
  1. In Visual Studio 2019 press start button to debug WpfApp1. Everything works fine, browser version is displayed.
  2. For WpfApp1 select property and select tab Publish and specify a publishing folder on hard drive.
  3. Press Publish Now button and look in publishing folder. The WebView2 assemblies and WebView2Loader.dll.deploy is left out, there is no runtimes folder.
  4. From publish folder execute setup.exe to install WpfApp1.
  5. Run installed WpfApp1. It will display error message "Unable to load DLL 'WebView2Loader.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)".

I have also added the source code for example I described above.

Thanks
Perka
WpfApp1.zip

@Reshma9006
Copy link

Hi @champnic ,
The Bug still Exists in 1.0.1056-prerelease.
I have a WPF application which uses WebView2 Control, and i am using Microsoft.Web.WebView2 1.0.1056 latest pre-release package.
The application works fine when i Publish as 'Self Contained' x86 application. (WebView2Loader.dll is copied in the specific location)
But when i Create a setUp project and build as single .msi installer and when Installed, WebView2Loader.dll is missing from directory.
If copied Explicitly the application works fine.

Thanks,
Reshma

@champnic
Copy link
Member

champnic commented Nov 3, 2021

If you are creating a separate MSI installer it's possible you have to manually include the necessary files. We have a description of what you'll need to include here:
https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#files-to-ship-with-the-app

@dodgecox-dansal
Copy link

I see the best fix is to manually load the WebView2Loader.dll into the executable directory/deployment package. I know this is an odd use case, but I happen to be trying to add WebView2 to a ClickOnce deployed VSTO add in for Office 2016. If you're not aware, the ClickOnce build, deploy, install, update, and execution within Office is not that straightforward as having an "executable directory" as the assemblies load from the ClickOnce cache, a series of random directories in the local user profile. Any pointers for forcing WebView2Loader.dll into a ClickOnce? I cannot add it as a reference as it doesn't appear to be a valid assembly or COM component according to VS2019. Thanks!

@champnic
Copy link
Member

Hey @dodgecox-dansal - If the UI is not letting you do this, you should be able to manually edit the csproj file to include the dll:
https://stackoverflow.com/a/70513633/13778848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

5 participants