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

[Bug] [S] WebView2Loader.dll is missing in net472 app #2482

Closed
pmaytak opened this issue Mar 18, 2021 · 11 comments
Closed

[Bug] [S] WebView2Loader.dll is missing in net472 app #2482

pmaytak opened this issue Mar 18, 2021 · 11 comments

Comments

@pmaytak
Copy link
Contributor

pmaytak commented Mar 18, 2021

Which Version of MSAL are you using ?
4.33

Platform
net472

What authentication flow has the issue?
Interactive WebView2

Repro 1
WebView2LoaderRepro.zip

  • WebView2Library references WebView2 SDK NuGet.
  • WebView2Library does specify AnyCPU PlatformTarget explicitly.
  • WebView2Library is packed as a NuGet.
  • WebView2App references WebView2Library as a NuGet.
  • Run WebView2App for net472 target.

Repro 2

  1. Use NetDesktopWinFormsWAM project.
  2. Update to reference MSAL NuGet instead of source code project.
  3. Build, run, do interactive request.
  4. WebView2Loader error occurs.

Expected behavior
WebView2 should show up.

Actual behavior
If App targets net472, I see different behavior depending on the PlatformTarget element in the App csproj.

  • None specified - BadImageFormatException
  • AnyCPU - DllNotFoundException
  • x86 or x64 - everything works

Additional context / logs / screenshots
Current workaround is to set PlatformTarget to either x86 or x64 in the app's project file.

Related issue in WebView2 repo:
Using WebView2 in a WPF Assembly

@pmaytak pmaytak added the bug label Mar 18, 2021
@bgavrilMS
Copy link
Member

I was not able to reproduce this issue. @pmaytak - could you try to create a simple repro and open a bug on WebView2 team ? Should be sufficient to just try

string s = CoreWebView2Environment.GetAvailableBrowserVersionString();
Console.WriteLine(s);

@pmaytak
Copy link
Contributor Author

pmaytak commented Mar 18, 2021

@bgavrilMS Added zip repro above.
Bug: MicrosoftEdge/WebView2Feedback#1091

@pmaytak
Copy link
Contributor Author

pmaytak commented Mar 31, 2021

@bgavrilMS It's an issue with WebView2 SDK. Possible bug and workaround is described here. Workaround is to add <PlatformTarget>AnyCPU</PlatformTarget> to the project file. Small change, just need to test.

The explanation is pretty long but worth a read. Basically WebView2 SDK fails to build different WebView2Loader.dll version for different targets (since it's a native DLL) when the PlatformTarget element is missing. So although AnyCPU is default, we still need to add it as a workaround.

@bgavrilMS
Copy link
Member

Nice, thanks for following this up @pmaytak !

@bgavrilMS bgavrilMS added this to the 4.30 milestone Mar 31, 2021
@bgavrilMS bgavrilMS changed the title [Bug] WebView2Loader.dll is missing in net472 app [Bug] [S] WebView2Loader.dll is missing in net472 app Apr 6, 2021
@pmaytak
Copy link
Contributor Author

pmaytak commented Apr 9, 2021

@bgavrilMS Adding PlatformTarget element workaround doesn't work for us.

Should we exclude WebView2 here for NetFx targets?

if (_isWebView2AvailableFunc())
{
requestContext.Logger.Info("Using WebView2 embedded browser.");
return new WebView2WebUi(coreUIParent, requestContext);
}

NetDesktopWinFormsWAM still doesn't include the WebView2Loader.dll.
image

NetCoreWinFormsWAM does include the different WebView2Loader.dll runtimes.
image

Also for reference: Release notes for WebView2 SDK.

@bgavrilMS
Copy link
Member

We should think about catching the exception and re-thrwoing a meaningful error with the workaround,

@pmaytak
Copy link
Contributor Author

pmaytak commented Jul 1, 2021

Update: Seems like the workaround doesn't work when the library is consumed as a NuGet. Left comment in the WebView2 feedback issue.

@pmaytak
Copy link
Contributor Author

pmaytak commented Jul 12, 2021

cc @bgavrilMS @mjcheetham
I may have found another workaround for this. In the client app project add <PlatformTarget>AnyCPU</PlatformTarget> and directly reference WebView2 NuGet.

@jmprieur
Copy link
Contributor

@pmaytak do we want to document this in the wiki?

@pmaytak
Copy link
Contributor Author

pmaytak commented Jul 13, 2021

@jmprieur We do have it in a wiki: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/WebView2#troubleshooting. But thanks, for the reminder, I'll update it.

@bgavrilMS bgavrilMS moved this to Blocked/Waiting for reply in MSAL Customer Trust / QM Jul 22, 2022
@bgavrilMS
Copy link
Member

Closing as no fix. For AAD authorities, please use WAM.

@bgavrilMS bgavrilMS closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2022
Repository owner moved this from Blocked/Waiting for reply to Fixed in MSAL Customer Trust / QM Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants