While running this line of code I get an exception in my project. The error appears to be related to a version issue of WebView2.Core and Microsoft.Identity.Client.Desktop but I seem to have a high enough version of that dependency but it fails and gives the below exception.
authResult = await app.AcquireTokenInteractive(ApiScopes)
.WithParentActivityOrWindow(new WindowInteropHelper(this).Handle)
.ExecuteAsync();
More details on the error:
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Web.WebView2.Core, Version=1.0.864.35, Culture=neutral, PublicKeyToken=2a8ab48044d2601e
(Fully-specified)
LOG: Appbase = file:///C:/git/app/main/Release/
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.Identity.Client.Desktop, Version=4.64.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:WindowsMicrosoft.NETFrameworkv4.0.30319configmachine.config.
LOG: Post-policy reference: Microsoft.Web.WebView2.Core, Version=1.0.864.35, Culture=neutral, PublicKeyToken=2a8ab48044d2601e
LOG: Attempting download of new URL file:///C:/git/app/main/Release/Microsoft.Web.WebView2.Core.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
This error seems more like a bug.
- Calling assembly : Microsoft.Identity.Client.Desktop, Version=4.64.0.0 has a dependency on Microsoft.Web.WebView2.Core, Version=1.0.864.35.
In the NuGet documentation for Microsoft.Identity.Client.Desktop it has a dependency on WebView2.Core v1.0.864.35 or higher, and I have WebView2.Core Version=1.0.2739.15 installed and the exception still happens.
Reason why I am using WebView2.core: to do SSO implementation in our WPF App
private void InitializeSSOApp()
{
PublicClientApp = PublicClientApplicationBuilder.Create(ClientId)
.WithB2CAuthority(AuthoritySignUpSignIn)
.WithRedirectUri(RedirectUri)
.WithWindowsEmbeddedBrowserSupport()
.WithLogging(Log, LogLevel.Info, true)
.Build();
TokenCacheHelper.Bind(PublicClientApp.UserTokenCache);
}
Can anyone offer any help as to what I should try next?
I’ve tried:
- downgrading the WebView2.Core to v1.0.864.35 but other dependencies get in the way.
- I’ve tried removing all the dependencies related to WebView2 and re-adding them
- lots of cleaning and rebuilding my bin folder.