Microsoft-authentication-library-for-dotnet: AcquireTokenInteractive crashes on UWP app for ARM64

Created on 13 Nov 2020  路  41Comments  路  Source: AzureAD/microsoft-authentication-library-for-dotnet

Version of Nuget Microsoft.Identity.Client 4.19.0

Platform: UWP on ARM64

In a UWP Desktop App, running on ARM64, we want to authenticate for OneDrive, using the method IPublicClientApplication.AcquireTokenInteractive(...).ExecuteAsync();

Repro

private readonly string[] m_scopes = new[] { "Files.ReadWrite" };

IPublicClientApplication s_publicClientApp = PublicClientApplicationBuilder.Create("MyAppKeyForOneDrive")
                    .WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient")
                    .Build();
IEnumerable<IAccount> accounts = await s_publicClientApp.GetAccountsAsync();
IAccount firstAccount = accounts?.FirstOrDefault();
AuthenticationResult authResult;
if (firstAccount != null)
{
    authResult = await s_publicClientApp.AcquireTokenSilent(m_scopes, firstAccount).ExecuteAsync();
}
else
{
    authResult = await s_publicClientApp.AcquireTokenInteractive(m_scopes).ExecuteAsync();
}

Expected behavior
User is shown the login popup to enter credentials, and after successful login, the code receives a valid authResult.

Actual behavior
On ARM64, the app crashes with an unrecoverable exception in SharedLibrary.dll.

Additional context/ Logs / Screenshots
Please note that the very same code works perfectly in x64.

blocked bug external Mobile-UWP workaround exists

All 41 comments

Do you have an exception trace or some logs?

I wonder if WAM will fare better here. If you have the time, could you try to the WAM broker instead of the browser control ? This is described here https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/wam

It's a different experience that's more integrated with Windows and which we will probably enable by default at some point. From your point of view you just have to register another redirect URI and add .WithBroker(true). The link has more details.

Do you have an exception trace or some logs?

I don't, because when I step into that line s_publicClientApp.AcquireTokenXXX(), the app crashes miserably. The only thing we have is an event on the Windows Event Logs, stating there has been a crash of the app involving SharedLibrary.dll:

Faulting application name: MyApp.exe, version: 0.0.0.0, time stamp: 0x5fadfb37
Faulting module name: SharedLibrary.dll, version: 0.0.0.0, time stamp: 0x5d27c898
Exception code: 0x00001007
Fault offset: 0x00000000000ed608
Faulting process id: 0x34c4
Faulting application start time: 0x01d6b96f57b6f6d4
Faulting application path: C:\Program Files\WindowsApps\MyApp_1.4.2.0_arm64__xxx3536\MyApp.exe
Faulting module path: C:\Program Files\WindowsApps\Microsoft.NET.Native.Framework.2.2_2.2.27912.0_arm64__8wekyb3d8bbwe\SharedLibrary.dll
Report Id: 192f4c21-646f-441b-9913-0c45bdb4cb5b
Faulting package full name: MyAppxxx
Faulting package-relative application ID: App

I wonder if WAM will fare better here. If you have the time, could you try to the WAM broker instead of the browser control ? This is described here https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/wam

It's a different experience that's more integrated with Windows and which we will probably enable by default at some point. From your point of view you just have to register another redirect URI and add .WithBroker(true). The link has more details.

We will try this approach, but I also believe that it is worth fixing the methods s_publicClientApp.AcquireTokenXXX() for ARM64. By the way, are you able to reproduce the problem?

@bgavrilMS would it be due to the reference assemblies?

I don't know, did not have time to repro this.

@bgavrilMS Are you going to consider a fix for this issue? If yes, do you have a timeline (at least general, like 1 week, 1 month, 1 year...)?

@bgavrilMS it seems the "WithBroker()" method is not available in UWP.

So I cannot do:
var pca = PublicClientApplicationBuilder.Create("client_id").WithBroker(true);

Am I missing something?

@vfailla - are you using the latest MSAL ? We've only enabled this in MSAL 4.22 ... I can see the API:

image

@cghersi - how can I repro this? Is there an ARM emulator I can use? I don't have an ARM device.

@bgavrilMS unfortunately the only way I can see to reproduce the issue is by deploying the app on an actual ARM64 machine, e.g. a Microsoft Surface Pro X.

@henrik-me - can you help here? Is there any ARM Windows device that someone in our team can get to?

@cghersi - the reason why I'm recommending WAM is that on UWP we actually rely on a an old Windows component called WAB (Windows Auth Broker) to pop up the browser. We've had a lot of problems with it in the past. If the root cause of this bug in is WAB, I doubt we will be able to fix it. But I cannot say for sure as I don't have an ARM device. Trying WAM would be an alternative.

@bgavrilMS thanks for the explanation. While trying to integrate WAM, it seems there are some limitations, and you have to choose between personal / work account, AzureChina, etc. which is very inconvenient for us.
Moreover, the documentation refers to methods that are not available.
The ideal solution is to fix the bug in the library for ARM64.
If this is not possible, maybe you can point us out to an alternative implementation that keeps the same features and same results.

@cghersi - I'd like to understand more about the inconvenience. There is no distinction between personal / work account exposed to developers. Sovereign clouds (such as AzureChina) are supported both by WAM and by MSAL and the API is the same. WAM is the best alternative I can think of.

The only inconvenience I see is:

  • figuring out and registering a new redirect URI
  • making sure you are on the UI thread before calling AcquireTokenInteractive

We'll try to find an ARM device, repro the issue and fix MSAL, but currently we are all working from home and getting hold of hardware is not as easy as it used to be.

@bgavrilMS we are using this library to connect to OneDrive from our UWP app on behalf of the user, so that the user is able to:
1) browse her content on OneDrive (navigate thru folders, etc.)
2) download some files from her OneDrive account
3) upload some files into her OneDrive account.
For this to happen we need the AccessToken that we retrieve from the AuthenticationResult object, the result of the s_publicClientApp.AcquireTokenXXX() method.
We use this AccessToken to perform direct HTTP requests to endpoints like:

Let me know if you have a code snippet for WAM that allows us to perform the same operation (with all the possible OneDrive accounts that a user can have) and get a valid AccessToken that we can use in the subsequent HTTP calls.

Thank you very much!

We will update the UWP sample with WAM and get back to you. Probably in line with our next release, around end of next week
CC @jmprieur

@bgavrilMS : we have updated it for 4.22.0 : https://github.com/Azure-Samples/active-directory-xamarin-native-v2/tree/master/2-With-broker
The only missing thing is the new static property

I just tried this out on a Surface Pro X and the code above works for me. I have to say that the remote debugging experience was horrible, I spent about 2h getting everything to work, but that's besides the point.

I tried your code and I also tried WAM in debug mode and things seem to work fine.

I am using Windows 10 20H2 version.

@bgavrilMS we repro the issue on multiple ARM64 machines with winver 1909 (build 18363.1198).
Do you have the chance to try on that configuration?
Moreover, could you share the PoC project that you set up to try this behavior?

@cghersi - I will try with the version you mentioned, I think I have to reset my machine to rollback. I might not be able to do until January.

I tried with your code (but updated with my own client ID and scope). I also tried with our UWP sample https://github.com/Azure-Samples/active-directory-xamarin-native-v2/tree/master/2-With-broker which is preconfigured - could you try it please? I'm curious if at least the "Sign in with Broker" experience works for you.

I managed to get it all working both in debug mode and on the machine.

@cghersi - we have an internal thread on this as well. One of our engineers noticed that disabling the "optimize code flag" makes a difference.

image

There should also be possible to not optimize individual methods using an attribute

[MethodImpl(MethodImplOptions.NoOptimization)]

but I couldn't get this to work.

Hi @bgavrilMS , sorry for the latency.
I have a few problems:
1) we cannot ship an app without the Optimization flag off, and we need to understand which methods we should flag wit the attribute [MethodImpl(MethodImplOptions.NoOptimization)].
2) the sample you shared is for Xamarin, and it specifically mentions it is not working with UWP! Our app is in UWP, not Xamarin, so what should we do?
Please let me know your status and if you can provide us a new NuGet package with the fix.
Thank you very much

We are working on https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/2343 - maybe this will help with this scenario as well. Optimizers and linkers typically don't play well with reflection.

It should be very simple to change your app to use Windows Auth Manager controls instead of a simple browser. The Xamarin sample shows you the experience and works with UWP. Or just try directly yourself:

  • add .WithExperimentalFeatures(true).WithBroker(true) to the PublicClientApp builder
  • register a new redirect uri (https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/wam#uwp)
  • make sure to call AcquireTokenInteractive from UI thread

We are facing the same issue. I'm trying to run it on the sample provided here https://github.com/azure-samples/active-directory-dotnet-native-uwp-v2
Version of Nuget Microsoft.Identity.Client 4.27.0

Hi folks, we made some changes to the json serializer to not use reflection. Not sure if it will help, could you try with this package please (just remove the zip extension, GitHub does not allow nupkg uploads, although a nupkg is a zip )

Microsoft.Identity.Client.4.27.0-json.1.nupkg.zip

Instructions on how to consume local nuget packages: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/Installing-a-nuget-package-from-a-source-other-than-NuGet.org

@bgavrilMS Still the same issue is occurring, even with the this prerelease package
it is basically the same error mentioned here: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/2187#issuecomment-730628075

Thanks for confirming @true-hamid . CC @pmaytak

The other workaround would be to use WAM directly https://docs.microsoft.com/en-us/windows/uwp/security/web-account-manager

Hi @bgavrilMS
I don't think I can use WAM since I'm building a native module for a react native for windows app. And I have no experience in build a native UI component with this level of complexity. Hence I have to rely on MSAL for this one.
Were you able to reproduce this issue? if yes do we have timelines for a fix?

You can check what I'm trying to do here https://github.com/true-hamid/react-native-windows-msal

Your help is much appreciated.
Thanks

We're not doing any work on this, as it is not an MSAL problem. Keeping the issue open so that people can see the workarounds (i.e. don't check the optimization checkbox or possibly use WAM directly).

If you can raise a support issue with Microsoft related to UWP on ARM64, this would speed things up.

Hi I having same issue ....

I was be able to get some logs ...
When fails

````
Wallet.exe (Win32): Loaded 'C:\Windows\System32\dwmapi.dll'. Symbols loaded.
'Wallet.exe' (Win32): Loaded 'C:\Windows\System32\ninput.dll'. Symbols loaded.
'Wallet.exe' (Win32): Loaded 'C:\Windows\System32\avrt.dll'. Symbols loaded.
'Wallet.exe' (Win32): Loaded 'C:\Windows\System32\UIAnimation.dll'. Symbols loaded.
onecore\com\combase\dcomrem\preventrundownbias.cpp(1310)\combase.dll!00007FF9DFB81B78: (caller: 00007FF9DFB819B8) LogHr(2) tid(4418) 80070005 Access is denied.
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/08/2021 21:02:39] (wct/1.0.0: 1.0.0.0) Found 0 cache accounts and 0 broker accounts
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/08/2021 21:02:39] (wct/1.0.0: 1.0.0.0) Returning 0 accounts
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/08/2021 21:02:39] (wct/1.0.0: 1.0.0.0) Found 0 cache accounts and 0 broker accounts
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/08/2021 21:02:39] (wct/1.0.0: 1.0.0.0) Returning 0 accounts
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/08/2021 21:02:39 - ] (wct/1.0.0: 1.0.0.0) MSAL MSAL.UAP with assembly version '4.27.0.0'. CorrelationId(2e...-correlationId)
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/08/2021 21:02:39 - ] (wct/1.0.0: 1.0.0.0) === InteractiveParameters Data ===
LoginHint provided: False
User provided: True
UseEmbeddedWebView: NotSpecified
ExtraScopesToConsent:
Prompt: select_account
HasCustomWebUi: False

(True) MSAL 4.27.0.0 MSAL.UAP N/A [03/08/2021 21:02:39 - ] (wct/1.0.0: 1.0.0.0)
=== Request Data ===
Authority Provided? - True
Client Id - 76.....-clientID
Scopes - Directory.ReadWrite.All Files.ReadWrite.All User.Read
Redirect Uri - https://login.microsoftonline.com/common/oauth2/nativeclient
Extra Query Params Keys (space separated) -
ClaimsAndClientCapabilities -
Authority - https://login.microsoftonline.com/common/
ApiId - AcquireTokenInteractive
IsConfidentialClient - False
SendX5C - False
LoginHint -
IsBrokerConfigured - False
HomeAccountId -
CorrelationId - 2e...-correlationId

(True) MSAL 4.27.0.0 MSAL.UAP N/A [03/08/2021 21:02:39 - ] (wct/1.0.0: 1.0.0.0) === Token Acquisition (InteractiveRequest) started:
Authority: https://login.microsoftonline.com/common/
Scope: Directory.ReadWrite.All Files.ReadWrite.All User.Read
ClientId: 76.....-clientID

(True) MSAL 4.27.0.0 MSAL.UAP N/A [03/08/2021 21:02:39 - ] (wct/1.0.0: 1.0.0.0) Fetching instance discovery from the network from host login.microsoftonline.com. Endpoint https://login.microsoftonline.com/common/discovery/instance.
Exception thrown at 0x0000000000000000 in Wallet.exe: 0xC0000005: Access violation executing location 0x0000000000000000.

The thread 0x3d7c has exited with code 0 (0x0).
onecore\com\combase\dcomrem\preventrundownbias.cpp(1310)\combase.dll!00007FF9DFB81B78: (caller: 00007FF9DFB819B8) LogHr(3) tid(4114) 80070005 Access is denied.
````

When works

`Wallet.exe (Win32): Loaded 'C:\Windows\System32\dwmapi.dll'. Symbols loaded.
'Wallet.exe' (Win32): Loaded 'C:\Windows\System32\ninput.dll'. Symbols loaded.
onecore\com\combase\dcomrem\preventrundownbias.cpp(1310)\combase.dll!00007FF9DFB81B78: (caller: 00007FF9DFB819B8) LogHr(1) tid(3fc4) 80070005 Access is denied.
'Wallet.exe' (Win32): Loaded 'C:\Windows\System32\avrt.dll'. Symbols loaded.
'Wallet.exe' (Win32): Loaded 'C:\Windows\System32\UIAnimation.dll'. Symbols loaded.
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27] (wct/1.0.0: 1.0.0.0) Found 0 cache accounts and 0 broker accounts
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27] (wct/1.0.0: 1.0.0.0) Returning 0 accounts
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27] (wct/1.0.0: 1.0.0.0) Found 0 cache accounts and 0 broker accounts
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27] (wct/1.0.0: 1.0.0.0) Returning 0 accounts
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27 - ] (wct/1.0.0: 1.0.0.0) MSAL MSAL.UAP with assembly version '4.27.0.0'. CorrelationId(df...-correlationId)
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27 - ] (wct/1.0.0: 1.0.0.0) === InteractiveParameters Data ===
LoginHint provided: False
User provided: True
UseEmbeddedWebView: NotSpecified
ExtraScopesToConsent: 
Prompt: select_account
HasCustomWebUi: False

(True) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27 - ] (wct/1.0.0: 1.0.0.0) 
=== Request Data ===
Authority Provided? - True
Client Id - 76.....-clientID
Scopes - Directory.ReadWrite.All Files.ReadWrite.All User.Read
Redirect Uri - https://login.microsoftonline.com/common/oauth2/nativeclient
Extra Query Params Keys (space separated) - 
ClaimsAndClientCapabilities - 
Authority - https://login.microsoftonline.com/common/
ApiId - AcquireTokenInteractive
IsConfidentialClient - False
SendX5C - False
LoginHint - 
IsBrokerConfigured - False
HomeAccountId - 
CorrelationId - df...-correlationId

(True) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27 - ] (wct/1.0.0: 1.0.0.0) === Token Acquisition (InteractiveRequest) started:
    Authority: https://login.microsoftonline.com/common/
    Scope: Directory.ReadWrite.All Files.ReadWrite.All User.Read
    ClientId: 76.....-clientID

(True) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27 - ] (wct/1.0.0: 1.0.0.0) Fetching instance discovery from the network from host login.microsoftonline.com. Endpoint https://login.microsoftonline.com/common/discovery/instance. 
(False) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27 - ] (wct/1.0.0: 1.0.0.0) Resolving authority endpoints... Already resolved? - FALSE
onecore\com\combase\dcomrem\marshal.cxx(1284)\combase.dll!00007FF9DFB2FC54: (caller: 00007FF9DFB2F03C) ReturnHr(1) tid(3eb0) 80004002 No such interface supported
    Msg:[Failed to marshal with IID={11D...someID}] 
onecore\com\combase\dcomrem\marshal.cxx(1179)\combase.dll!00007FF9DFB2F1B8: (caller: 00007FF9DFB32418) LogHr(2) tid(3eb0) 80004002 No such interface supported
onecore\com\combase\dcomrem\marshal.cxx(1119)\combase.dll!00007FF9DFB32470: (caller: 00007FF9D816DEE8) ReturnHr(2) tid(3eb0) 80004002 No such interface supported
'Wallet.exe' (Win32): Loaded 'C:\Windows\System32\AuthBroker.dll'. Symbols loaded.
'Wallet.exe' (Win32): Loaded 'C:\Windows\System32\wkscli.dll'. Symbols loaded.
'Wallet.exe' (Win32): Loaded 'C:\Windows\System32\netutils.dll'. Symbols loaded.
'Wallet.exe' (Win32): Loaded 'C:\Windows\System32\authz.dll'. Symbols loaded.
onecore\com\combase\dcomrem\preventrundownbias.cpp(1310)\combase.dll!00007FF9DFB81B78: (caller: 00007FF9DFB819B8) LogHr(3) tid(2d7c) 80070005 Access is denied.`

Line (False) MSAL 4.27.0.0 MSAL.UAP N/A [03/09/2021 07:37:27 - ] (wct/1.0.0: 1.0.0.0) Resolving authority endpoints... Already resolved? - FALSE doesn't appears on failing log ...

Notice that both are executed on SurfaceProX (ARM64) first release version and second debug version

Let see if this help you to fix it

Hello. In MSAL 4.28.0 we made some changes to the JSON serializer to not use reflection and also included rd.xml that fixes similar issue in optimized UWP apps. Could you please try with this MSAL version?

Hello. I try again with new version (4.28.1) and still it's failing. Here you have current log ...
Just FYI when failing, debugger is asking for find some source code Dispensers.NativeFormats.cs , maybe it helps

GET TOKEN !!!!!!!!!!!
(False) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15] Found 0 cache accounts and 0 broker accounts
(False) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15] Returning 0 accounts
(False) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] MSAL MSAL.UAP with assembly version '4.28.1.0'. CorrelationId(CORRELATION_ID)
(False) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] === AcquireTokenSilent Parameters ===
(False) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] LoginHint provided: False
(True) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] Account provided: false
(False) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] ForceRefresh: False
(True) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] 
=== Request Data ===
Authority Provided? - True
Client Id - CLIENT_ID
Scopes - Directory.ReadWrite.All Files.ReadWrite.All User.Read
Redirect Uri - urn:ietf:wg:oauth:2.0:oob
Extra Query Params Keys (space separated) - 
ClaimsAndClientCapabilities - 
Authority - https://login.microsoftonline.com/common/
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint - 
IsBrokerConfigured - False
HomeAccountId - 
CorrelationId - CORRELATION_ID

(True) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] === Token Acquisition (SilentRequest) started:
    Authority: https://login.microsoftonline.com/common/
    Scope: Directory.ReadWrite.All Files.ReadWrite.All User.Read
    ClientId: CLIENT_ID

Exception thrown: 'Microsoft.Identity.Client.MsalUiRequiredException' in Microsoft.Identity.Client.dll
Exception thrown: 'Microsoft.Identity.Client.MsalUiRequiredException' in System.Private.CoreLib.dll
Exception thrown: 'Microsoft.Identity.Client.MsalUiRequiredException' in System.Private.CoreLib.dll
(True) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] MSAL.UAP.4.28.1.0.MsalUiRequiredException: 
    ErrorCode: user_null
Microsoft.Identity.Client.MsalUiRequiredException: No account or login hint was passed to the AcquireTokenSilent call. 
   at Microsoft.Identity.Client.Internal.Requests.Silent.SilentRequest.<ExecuteAsync>d__5.MoveNext() + 0x224
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x24
   at Microsoft.Identity.Client.Internal.Requests.Silent.SilentRequest.<ExecuteAsync>d__5.MoveNext() + 0x654
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x24
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xac
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x58
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x24
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.<RunAsync>d__13.MoveNext() + 0x194

    StatusCode: 0 
    ResponseBody:  
    Headers: 
Exception thrown: 'Microsoft.Identity.Client.MsalUiRequiredException' in Microsoft.Identity.Client.dll
Exception thrown: 'Microsoft.Identity.Client.MsalUiRequiredException' in System.Private.CoreLib.dll
Exception thrown: 'Microsoft.Identity.Client.MsalUiRequiredException' in System.Private.CoreLib.dll
>>>>>>>>>>>>>>> No account or login hint was passed to the AcquireTokenSilent call. 
GET NEW TOKEN !!!!!!!!!!!
(False) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] MSAL MSAL.UAP with assembly version '4.28.1.0'. CorrelationId(OTHER_CORRELATION_ID)
(False) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] === InteractiveParameters Data ===
LoginHint provided: False
User provided: False
UseEmbeddedWebView: NotSpecified
ExtraScopesToConsent: 
Prompt: not_specified
HasCustomWebUi: False

(True) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] 
=== Request Data ===
Authority Provided? - True
Client Id - CLIENT_ID
Scopes - Directory.ReadWrite.All Files.ReadWrite.All User.Read
Redirect Uri - urn:ietf:wg:oauth:2.0:oob
Extra Query Params Keys (space separated) - 
ClaimsAndClientCapabilities - 
Authority - https://login.microsoftonline.com/common/
ApiId - AcquireTokenInteractive
IsConfidentialClient - False
SendX5C - False
LoginHint - 
IsBrokerConfigured - False
HomeAccountId - 
CorrelationId - OTHER_CORRELATION_ID

(True) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] === Token Acquisition (InteractiveRequest) started:
    Authority: https://login.microsoftonline.com/common/
    Scope: Directory.ReadWrite.All Files.ReadWrite.All User.Read
    ClientId: CLIENT_ID

(True) MSAL 4.28.1.0 MSAL.UAP N/A [03/28/2021 15:59:15 - ] Fetching instance discovery from the network from host login.microsoftonline.com. Endpoint https://login.microsoftonline.com/common/discovery/instance. 
onecore\com\combase\dcomrem\preventrundownbias.cpp(1310)\combase.dll!00007FFC167B2B78: (caller: 00007FFC167B29B8) LogHr(2) tid(2cd8) 80070005 Access is denied.
Unhandled exception at 0x00007FFBE7B878E8 (mrt100_app.dll) in Wallet.exe: 0xC0000602:  A fail fast exception occurred. Exception handlers will not be invoked and the process will be terminated immediately.

Possible workaround - add this to the csproj:

<UseDotNetNativeSharedAssemblyFrameworkPackage>false</UseDotNetNativeSharedAssemblyFrameworkPackage>

Possible workaround - add this to the csproj:

<UseDotNetNativeSharedAssemblyFrameworkPackage>false</UseDotNetNativeSharedAssemblyFrameworkPackage>

This solve my problem

@bgavrilMS

<UseDotNetNativeSharedAssemblyFrameworkPackage>false</UseDotNetNativeSharedAssemblyFrameworkPackage>

I'm trying this out to see if it also addresses the crashing I've seen on ARM64.

Getting these warnings, though:

Warning MCG : warning MCG0007: Unresolved P/Invoke method 'api-ms-win-core-com-l1-1-0.dll!MkParseDisplayName' for method 'System.Void System.Runtime.InteropServices.ExternalInterop.MkParseDisplayName(System.Runtime.InteropServices.ComTypes.IBindCtx, System.String, System.UInt32, System.Runtime.InteropServices.ComTypes.IMoniker)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.

Warning MCG : warning MCG0007: Unresolved P/Invoke method 'api-ms-win-core-com-l1-1-0.dll!CreateBindCtx' for method 'System.Void System.Runtime.InteropServices.ExternalInterop.CreateBindCtx(System.UInt32, System.Runtime.InteropServices.ComTypes.IBindCtx)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.

@myokeeh - no idea where they come from, they are not from MSAL SDK. It is possible that an app or a dependency declares smth like

        [DllImport("User32.dll", CallingConvention = CallingConvention.StdCall)]
        internal static extern IntPtr GetDC(IntPtr hWnd);

I think these can trigger warnings like above, but does not mean the app will crash, for example if the method is not actually called.

@bgavrilMS

no idea where they come from, they are not from MSAL SDK. It is possible that an app or a dependency declares smth like

I didn't think that through. That makes sense since <UseDotNetNativeSharedAssemblyFrameworkPackage>false</UseDotNetNativeSharedAssemblyFrameworkPackage> is project-wide and not specific to any NuGet package/reference.

Good news though. The above has now allowed my apps to run on ARM64 again. They've been broken for several months (6-10 months?).

Thanks for confirming @myokeeh
@bgavrilMS : I've documented the work around in https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/troubleshooting#acquiretokeninteractive-crashes-on-uwp-app-for-arm64

@cghersi @true-hamid @nowheremanmail can you please confirm this also solves it for you?

confirmed! it solve application crash

Thanks for confirming @nowheremanmail
Closing the issue as there is a documented workaround

Was this page helpful?
0 / 5 - 0 ratings