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

Exception "Method not found: 'Void Microsoft.Web.WebView2.WinForms.WebView2.add_AcceleratorKeyPressed" when calling AcquireTokenInteractive #2685

Closed
6 tasks
twieczor opened this issue Jun 8, 2021 · 7 comments · Fixed by #2764

Comments

@twieczor
Copy link

twieczor commented Jun 8, 2021

Logs and network traces
Without logs or traces, it is unlikely that the team can investigate your issue. Capturing logs and network traces is described in Logging wiki.

Which version of MSAL.NET are you using?
MSAL.NET 4.32.0

Platform
.NET 4.6

What authentication flow has the issue?

  • Desktop / Mobile
    • [X ] Interactive
    • Integrated Windows Authentication
    • Username Password
    • Device code flow (browserless)
  • Web app
    • Authorization code
    • On-Behalf-Of
  • Daemon app
    • Service to Service calls

Other?
Microsoft Edge WebView2 Runtime ver. 91.0.864.41

Is this a new or existing app?
c. This is a new app or experiment.

Repro

IMsalHttpClientFactory factoryHttpClient = new MsalClientFactory("user agent");
IPublicClientApplication client = PublicClientApplicationBuilder
                         .Create("client Id")
                         .WithDesktopFeatures()
                         .WithHttpClientFactory(factoryHttpClient)
                         .WithAuthority("authority")
                         .Build();

var authResult = await client.AcquireTokenInteractive(scopes).WithUseEmbeddedWebView(true)
                        .WithLoginHint("loginHint").WithPrompt(Prompt.NoPrompt)
                       .ExecuteAsync(cancelToken).ConfigureAwait(true);

Expected behavior
authResult returns access token

Actual behavior
Exception:
Method not found: 'Void Microsoft.Web.WebView2.WinForms.WebView2.add_AcceleratorKeyPressed(System.EventHandler`1<Microsoft.Web.WebView2.Core.CoreWebView2AcceleratorKeyPressedEventArgs>)'.

Possible solution

Additional context / logs / screenshots
Add any other context about the problem here, such as logs and screenshots.

d__16.MoveNext, Line 270] : Error acquiring access token
System.MissingMethodException: Method not found: 'Void Microsoft.Web.WebView2.WinForms.WebView2.add_AcceleratorKeyPressed(System.EventHandler`1<Microsoft.Web.WebView2.Core.CoreWebView2AcceleratorKeyPressedEventArgs>)'.
at Microsoft.Identity.Client.Platforms.Features.WebView2WebUi.WebView2WebUi.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.d__2.MoveNext()

System.MissingMethodException: Method not found: 'Void Microsoft.Web.WebView2.WinForms.WebView2.add_AcceleratorKeyPressed(System.EventHandler`1<Microsoft.Web.WebView2.Core.CoreWebView2AcceleratorKeyPressedEventArgs>)'.
at Microsoft.Identity.Client.Platforms.Features.WebView2WebUi.WebView2WebUi.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.d__2.MoveNext()

@pmaytak
Copy link
Contributor

pmaytak commented Jun 11, 2021

@bgavrilMS I vaguely remember getting something like this when I upgraded WebView2 SDK in MSAL (while testing something else). In this case, feels like it might be a back compat issue with the WebView2 runtime? (Because I think it worked for me on runtime 91.x). Might also want to consider updating to the latest SDK (1.0.864.35) or do we need to stay on the lower version?

@twieczor
Copy link
Author

I believe WebView2.AcceleratorKeyPressed event has been depraciated since 1.0.774.44, that was 3 releases ago.

@bgavrilMS
Copy link
Member

I don't understand how this can happen, we took a dependency on a stable (non pre-release) version of the SDK
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.705.50" />

@pmaytak
Copy link
Contributor

pmaytak commented Jun 24, 2021

@twieczor You are right it was removed since 1.0.774.44.
I created a test app (net461/netcoreapp3.1) that uses just MSAL. WebView2 works correctly since 1.0.705.50 version is pulled from MSAL.
If I add a direct reference to a newer WebView2 NuGet in my app, the newer WebView2 reference is picked up and the error does happen. Do you directly import a newer version of WebView2 SDK in your app? The workaround would be to either remove any direct reference to newer WebView2 NuGet (and transitively get it from MSAL) or downgrade it to 1.0.705.50.

@pmaytak pmaytak added this to In Progress in MSAL.NET (legacy) Jun 24, 2021
@pmaytak pmaytak assigned pmaytak and unassigned pmaytak Jun 24, 2021
@pmaytak pmaytak removed this from In Progress in MSAL.NET (legacy) Jun 24, 2021
@pmaytak
Copy link
Contributor

pmaytak commented Jun 30, 2021

For reference: MicrosoftEdge/WebView2Feedback#1453

@pmaytak
Copy link
Contributor

pmaytak commented Jul 1, 2021

@bgavrilMS Based on the MicrosoftEdge/WebView2Feedback#1453 (comment), if we upgrade WebView2 SDK version, we'll have to use OnKeyDown instead of AcceleratorKeyPressed.

Another point is that these events block all shortcut keys like CTRL + V, arrow keys. I think we might need to update the event handler to allow copy, paste, and such. Another alternative is to maybe set WebView2.CoreWebView2.Settings.AreBrowserAcceleratorKeysEnabled which doesn't disable all the keys.

@twieczor
Copy link
Author

twieczor commented Jul 7, 2021

@pmaytak Unfortunately, we use WebView2 SDK directly, and can't downgrade it. Hopefully the new MSAL will solve this.

@pmaytak pmaytak modified the milestones: 4.34.0, 4.35.0 Jul 7, 2021
@pmaytak pmaytak added this to Estimated/Committed in MSAL.NET (legacy) Jul 7, 2021
@pmaytak pmaytak self-assigned this Jul 13, 2021
@pmaytak pmaytak moved this from Estimated/Committed to In Progress in MSAL.NET (legacy) Jul 13, 2021
@pmaytak pmaytak added the In PR label Jul 14, 2021
MSAL.NET (legacy) automation moved this from In Progress to Fixed Jul 15, 2021
@pmaytak pmaytak removed the In PR label Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
5 participants