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: WebAuthenticationCoreManagerInterop does not work if AOT is enabled #1926

Open
lhak opened this issue Feb 15, 2025 · 1 comment
Open

Comments

@lhak
Copy link

lhak commented Feb 15, 2025

Description

Calling WebAuthenticationCoreManagerInterop.RequestTokenForWindowAsync() results in the following error message if AOT is enabled:

Cannot retrieve a helper type for generic public type 'Windows.Foundation.IAsyncOperation`1[Windows.Security.Authentication.Web.Core.WebTokenRequestResult]'

Steps To Reproduce

  1. Call WebAuthenticationCoreManagerInterop.RequestTokenForWindowAsync()

Expected Behavior

Should work as with AOT disabled

Version Info

cswinrt 2.2
.net windows sdk 10.0.22621.56

Additional Context

No response

@lhak
Copy link
Author

lhak commented Feb 17, 2025

I found a (complicated) workaround:

  • Copy definition of IWebAuthenticationCoreManagerInterop from WinRT.Interop.idl into a separate file with a new namespace
  • Change return type from Object to the correct one (IAsyncOperation<WebTokenRequestResult>)
  • Generate a winmd file (e.g. by adding the idl file to a c++ project)
  • Run cswinrt on the winmd file to create the projection files
  • Copy the generated .cs files to the application project
  • Copy the related code from ComInteropHelpers.cs and update it to use the generated code for the interface

So I guess updating the return types in cswinrt will be enough to fix this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant