MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
452 stars 55 forks source link

Cannot load WebView2Loader.dll in Excel VSTO Add-In #2324

Open FROGGS opened 2 years ago

FROGGS commented 2 years ago

Description I'm building a VSTO Add-In using Visual Studio 2019 on Windows 10. After adding the ribbon, windows form and the WebView2 user control I get an error message saying that said DLL cannot be found.

Version SDK: 1.0.1189-prerelease Runtime: Evergreen 99.0.1150.55 Framework: WinForms OS: Win10 21H2 Build 19044.1586

Repro Steps

Screenshots

Additional context Repository containing exactly what is mentioned in repro steps: https://github.com/FROGGS/excel-vsto-webview

FROGGS commented 2 years ago

A workaround is to copy the WebView2Loader.dll to the Office16 program folder, but is there a better way?

LK-Global commented 2 years ago

We ran into a similar issue with an Office Add-in. We used procmon to see the progression of locations where the WebView2 dotNet assemblies is trying to load this WebView2Loader.dll. Eventually we moved the location where Office loads the WebView2 dotNet assemblies and made sure WebView2Loader.dll was located there as well.

champnic commented 2 years ago

I can't speak to cgeier's initialization code. As mentioned by @LK-Global some files may need to be included with your app if they aren't automatically being deployed. The list and expected locations are described here: https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#files-to-ship-with-the-app

cgeier commented 2 years ago

@FROGGS: If using the initialization code that I posted in 187 double-check that the order of execution is as expected in your application. As of Webview2 version 1.0.664-prerelease/1.0.674.37, one can use CoreWebView2CreationProperties to specify properties such as UserDataFolder. For WPF, see 552 for how this can be used.