我已将Visual Studio与虚拟MAC机配对,创建了所需的钥匙串,并将其添加到我的项目中。我不断收到此错误:
Prism.Navigation.NavigationException: An error occurred while resolving the page. This is most likely the result of invalid XAML or other type initialization exception --->
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. ---> Microsoft.Identity.Client.MsalClientException: The application cannot access the iOS keychain for the application publisher (the TeamId is null). This is needed to enable Single Sign-On between applications of the same publisher.
我也尝试禁用Entitlements.plist
中的钥匙串-不起作用。某种程度上,这似乎是Prism导航问题,因为当我消除该问题并仅导航到示例页面时,它就可以工作。
我也尝试在Physical Mac上运行我的项目,我得到了:
2020-06-01 01:45:29.879475-0700 NatWest.KeepSafe.MobileApp.iOS[6277:128192] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=6277
2020-06-01 01:45:29.880109-0700 NatWest.KeepSafe.MobileApp.iOS[6277:128192] SecTaskCopyDebugDescription: NatWest.KeepSafe[6277]/0#-1 LF=0
2020-06-01 01:45:29.897634-0700 NatWest.KeepSafe.MobileApp.iOS[6277:128192] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=6277
2020-06-01 01:45:29.897992-0700 NatWest.KeepSafe.MobileApp.iOS[6277:128192] SecTaskCopyDebugDescription: NatWest.KeepSafe[6277]/0#-1 LF=0
P.S:该代码可在物理iPhone上完美运行,但在模拟器上运行时会出现问题。
这与Prism完全无关。.MSAL实际上与Prism很好用,您可以看到AP.AzureADAuth模块样本。
您发布的错误实际上告诉您问题的确切原因。您的权利存在问题,导致其无法在iOS模拟器上运行。
有关更多信息,您需要在此处签出文档:
var builder = PublicClientApplicationBuilder
.Create(ClientId)
.WithIosKeychainSecurityGroup("com.microsoft.adalcache")
.Build();
并且在Entitlements.plist
中,您想更新为类似内容:
<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
</array>
</dict>