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

Identity Client package incompatibility? #5143

Closed
jmiddour opened this issue Jun 3, 2021 · 19 comments
Closed

Identity Client package incompatibility? #5143

jmiddour opened this issue Jun 3, 2021 · 19 comments
Labels
product-winui3 WinUI 3 issues question team-Markup Issue for the Markup team v0.8 Issues introduced in the Project Reunion 0.8 prerelease

Comments

@jmiddour
Copy link

jmiddour commented Jun 3, 2021

I am working on a WinUI 3 app as part of reunion 0.5.7 (I was able to reproduce using the 0.8 preview as well.)

A blank packaged application will run, however once I build out my app, I start getting errors.

This is the error VS reports:
WMC9999 Cannot find type System.Windows.DependencyObject in module WindowsBase.dll.
A scan of the output says that this is happening in the MarkupCompilePass2 target
Repeated cleans, including closing vs and manually deleting vs/obj/bin folders does not help.

When I try to build from the command line, I get a different error:

Task "CompileXaml"
        Xaml Compiler Marker: 3:22:23 PM: 674 perfXC_StartPass1, ExampleWinUIApplication
        Xaml Compiler Marker: 3:22:23 PM: 693 perfXC_FingerprintCheck, New2: c:\repos\Example.winnativeapp\src\working\templates\ExampleWinUIapplication\Example.httpclient.public\bin\x64\debug\net5.0\Example.httpclient.public.dll
        Xaml Compiler Marker: 3:22:23 PM: 694 perfXC_FingerprintCheck, List of Assemblies Changed
        Xaml Compiler Marker: 3:22:23 PM: 694 perfXC_FingerprintCheck, Reference Assemblies Fingerprint Changed
        Xaml Compiler Marker: 3:22:23 PM: 695 perfXC_CreatingTypeUniverse
        Xaml Compiler Marker: 3:22:23 PM: 699 perfXC_CreatedTypeUniverse
        Xaml Compiler Marker: 3:22:23 PM: 700 perfXC_CreatingSchemaContext
  1:7>C:\Users\me\.nuget\packages\microsoft.projectreunion.winui\0.8.0-preview\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(465,9): Xaml Internal Error error WMC9999: **Operation is not supported on this platform. [C:\Repos\Example.WinNativeApp\src\working\templates\ExampleWinUIApplication\ExampleWinUIApplication\ExampleWinUIApplication.csproj]
           at System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid clsid, Guid riid)**
           at System.Reflection.Adds.MetadataDispenser.GetDispenserShim()
           at System.Reflection.Adds.MetadataDispenser.OpenFileAsFileMapping(String fileName)
           at Microsoft.UI.Xaml.Markup.Compiler.Lmr.Loader.OpenMetadataFile(String filename)
           at Microsoft.UI.Xaml.Markup.Compiler.Lmr.Loader.ReadAssemblyFromFile(String file)
           at Microsoft.UI.Xaml.Markup.Compiler.Lmr.XamlTypeUniverse.LoadAssemblyFromFile(String path)
           at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.TryLoadAssembly(String reference)
           at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.LoadAssembly(String reference)
           at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.LoadAssemblyItem(String item, Boolean isSystemAssembly)
           at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.LoadAssemblyItems(List`1 referenceAssemblies, Boolean isSystemAssembly)
           at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.LoadSchemaContext()
           at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.DoExecute()
        Xaml Compiler Marker: 3:22:23 PM: 727 perfXC_EndPass1, ExampleWinUIApplication

I'm assuming there's something I'm referencing that the compiler doesn't like, but isn't bad enough for VS to pick it up earlier. I just don't know where to go from here to find it. Any help would be appreciated.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jun 3, 2021
@ranjeshj ranjeshj added v0.8 Issues introduced in the Project Reunion 0.8 prerelease team-Markup Issue for the Markup team labels Jun 10, 2021
@andrewleader
Copy link

@Scottj1s @ranjeshj this also repro's on 0.8 RC for the customer

@jmiddour any chance you can share a repro project?

@jmiddour
Copy link
Author

@andrewleader @ranjeshj

Sorry for the delay, I finally had a chance to continue debugging the application. In the process of prepping a repro project, I finally found the culprit.... the Windows.Identity.Client nuget package (at least v4.31)

Apologies for the red herring. I just couldn't quite figure out what was failing and I needed the MSAL library so it wasn't something that was easy to just remove and see what happens.

I'm going to mark the issue closed. I think the only follow up would be if we could improve the error handling, so that if it comes down to "can't find a type" also provide the assembly that was asking for the type. The error only ever reported as part of the main project, which contributed to the difficulty debugging.

@ghost ghost removed the needs-triage Issue needs to be triaged by the area owners label Jun 17, 2021
@abhi-msft
Copy link

Had the same issue when I upgraded my app to 0.8 along with other package updates.
@jmiddour : Your comment helped me fix my issue as well however in my case it is Microsoft.Identity.Client. Had to downgrade the package from 4.33.0 to the last used version (4.16.1). Not sure what is going on.

@jmiddour
Copy link
Author

jmiddour commented Jul 5, 2021

Had the same issue when I upgraded my app to 0.8 along with other package updates.
@jmiddour : Your comment helped me fix my issue as well however in my case it is Microsoft.Identity.Client. Had to downgrade the package from 4.33.0 to the last used version (4.16.1). Not sure what is going on.

Ok, if someone is still having issues with this, I'm thinking it should be reopened. @andrewleader

What I could track down appeared to be an issue of the MSAL packages including windowing that was not part of what was included in the project reunion packages.

I think that might be ok, but it should be made clear what we need to do to work around the issue in the meantime.

@jmiddour jmiddour reopened this Jul 5, 2021
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jul 5, 2021
@jmiddour jmiddour changed the title Is there any way to get more information on xaml compiler crash? Identity Client package incompatibility? Jul 5, 2021
@krschau krschau added the product-winui3 WinUI 3 issues label Jul 14, 2021
@jeromelaban
Copy link

I'm getting this exception as well, but I'm not using Identity client. Build works from VS2022 IDE, but not on the CLI, even using Reunion 0.8.1.

Here's the stack trace, from the binlog:

C:\Users\jerome.laban\.nuget\packages\microsoft.projectreunion.winui\0.8.1\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(465,9): error WMC9999: Operation is not supported on this platform. [C:\Temp\test-net6-validation\UnoAppWinUI\UnoAppWinUI.Windows.Desktop\UnoAppWinUI.Windows.Desktop.csproj]

   at System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid clsid, Guid riid) in System.Runtime.InteropServices.dll:token 0x6000048+0x5
   at System.Reflection.Adds.MetadataDispenser.GetDispenserShim() in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x60012e9+0x1f
   at System.Reflection.Adds.MetadataDispenser.OpenFileAsFileMapping(String fileName) in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x60012eb+0x8
   at Microsoft.UI.Xaml.Markup.Compiler.Lmr.Loader.OpenMetadataFile(String filename) in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x6001c73+0x1
   at Microsoft.UI.Xaml.Markup.Compiler.Lmr.Loader.ReadAssemblyFromFile(String file) in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x6001c75+0x1
   at Microsoft.UI.Xaml.Markup.Compiler.Lmr.XamlTypeUniverse.LoadAssemblyFromFile(String path) in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x6001ffd+0xe
   at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.TryLoadAssembly(String reference) in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x60013df+0x1b
   at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.LoadAssembly(String reference) in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x60013de+0x1
   at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.LoadAssemblyItem(String item, Boolean isSystemAssembly) in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x60013dd+0x9
   at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.LoadAssemblyItems(List`1 referenceAssemblies, Boolean isSystemAssembly) in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x60013dc+0x1a
   at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.LoadSchemaContext() in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x60013e7+0x17
   at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.DoExecute() in Microsoft.UI.Xaml.Markup.Compiler.dll:token 0x60013d9+0x243

@bgavrilMS
Copy link
Member

Note that in the case of Microsoft.Identity.Client, the library targets net5.0-windows10.0.17763.0 because it needs to make WinRT calls (to Windows auth modules). This is a valid scenario for a library (i.e. to call WinRT).

@Konstantin-tr
Copy link

Had the same issue when I upgraded my app to 0.8 along with other package updates.
@jmiddour : Your comment helped me fix my issue as well however in my case it is Microsoft.Identity.Client. Had to downgrade the package from 4.33.0 to the last used version (4.16.1). Not sure what is going on.

This worked for me, too. However, I also tried to use the Microsoft.Graph.Auth package and I could not find a way to actually get that to work. It uses a newer version of the Microsoft.Identity.Client package and thus gets the same error. This seems really problematic imo.

@bgavrilMS
Copy link
Member

Using a lower version of Microsoft.Identity.Client should only be seen as a temporary workaround and should not be used in a production app. This is a security library, you always want to use the most recent version.

A better workaround would be to force msbuild / nuget to use MSAL's netcoreapp2.1 version instead of MSAL's net5-windows10.0.17663.0 version.

@jmiddour
Copy link
Author

jmiddour commented Aug 16, 2021

A better workaround would be to force msbuild / nuget to use MSAL's netcoreapp2.1 version instead of MSAL's net5-windows10.0.17663.0 version.

I don't believe I've ever seen a way to specify a nuget platform other than the target framework of the project. As far as I know, WinUI3 requires net5, so I don't believe I can change that to netcoreapp2.1. Can you point me to directions to use a specific target platform of nuget without changing the target of the project itself?

Also, I tried moving the identity logic to a separate project targeting 2.1, the net 5 project referencing that project still used the net 5 version of the package.

@Scottj1s
Copy link
Member

@RealTommyKlein any ideas on this?

@PaulSorauer-IPG
Copy link

Hi @Scottj1s

Just an FYI - I've put a comment here, in the hopes that it'll draw specific attention to the .NET 6.0 / ProjectReunion 0.8.1 context.

As mentioned in that thread, I tried different versions of the library but had no success.

@RealTommyKlein
Copy link
Contributor

At least for the Operation is not supported on this platform. error, the Xaml compiler build task (and many others like appx package related build tasks) don't support the .NET CLI. They are built against the .NET Framework to run as an MSBuild task there, but the .NET CLI invokes the build tasks on .NET Core which leads to incompatibilities like this error. Additionally, porting all of these MSBuild tasks to .NET Standard to allow them to run both in the VS IDE (which uses .NET Framework) and the .NET CLI (which uses .NET Core) would be quite expensive. @Scottj1s there's an old internal email thread about this titled ".NET CLI Support" if you're curious.

@KusiTec
Copy link

KusiTec commented Sep 12, 2021

If I install the nuget Microsoft.Identity.Client 4.36.1 on a WinUi3 Desktop project, the following errors occur:

Warning NU1701 Package 'Microsoft.ProjectReunion.InteractiveExperiences 0.8.1' was restored using 'net5.0-windows10.0.19041, .NETCoreApp,Version=v3.1, .NETCoreApp,Version=v3.0, .NETCoreApp,Version=v2.0, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, net6.0-windows10.0.19041, .NETFramework,Version=v4.6.1' instead of the project target framework 'UAP,Version=v10.0.19041'. This package may not be fully compatible with your project.

Error NETSDK1082 There was no runtime pack for Microsoft.WindowsDesktop.App.WindowsForms available for the specified RuntimeIdentifier 'win10-arm64'.

Environment:

  • target framework is net5.0-windows10.0.19041.0 - x86
  • projekt reunion 0.8.1,

Its not possible to down grade the target framework, because there are dependencies to Ms Toolkit packages...

Thanks a lot for working on a solution

@andrewleader
Copy link

Hey @KusiTec, WinUI 3 Desktop currently doesn't support MSAL, but in version 1.0 of the Windows App SDK we're fixing that bug and you'll be able to use MSAL. We should have a preview of 1.0 out shortly that includes this fix!

@KusiTec
Copy link

KusiTec commented Sep 20, 2021

Hi @andrewleader, thanks for answering. I am glad to see forward to the new Windows App SDK.
I need MSAL and MsGraph. Both are working now with the follow versions under WinUi 3 Desktop:

  • Microsoft.Identity.Client v4.27.1
  • Microsoft.Graph v.3.35

I hope, in future, when the release preview 1.0 from Windows App SDK is deployed, it is possible to implement the newest releases from MSAL and MsGaph..

@KusiTec
Copy link

KusiTec commented Sep 20, 2021

OOoh I see, its already deployed! Thanks a lot.

@andrewleader
Copy link

Correct, we just released the first preview of WinAppSDK 1.0 and MSAL now works in WinUI 3 Desktop apps! Please let us know if you run into any problems!

@ghost ghost removed the needs-triage Issue needs to be triaged by the area owners label Sep 20, 2021
@ADD-David-Antolin
Copy link

The errors:

Error NETSDK1082 There was no runtime pack for Microsoft.WindowsDesktop.App.WindowsForms available for the specified RuntimeIdentifier 'win10-arm'.
Error NETSDK1082 There was no runtime pack for Microsoft.WindowsDesktop.App.WindowsForms available for the specified RuntimeIdentifier 'win10-arm-aot'.

Is still happening if you add PackageReference Microsoft.Identity.Client with version between 4.25.0 and 4.50.0 (current last stable in nuget.org) with Microsoft.WindowsAppSDK from 1.0.0 to 1.2.230217.4 (current last stable in nuget.org).

@baskren
Copy link

baskren commented Mar 22, 2023

I concur with @ADD-David-Antolin - I've seen this since November 2022's .NET and VisualStudio updates. @andrewleader , if this is a known issue, can you point me to it? If this isn't a known issue, do we need to open one so this gets attention?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product-winui3 WinUI 3 issues question team-Markup Issue for the Markup team v0.8 Issues introduced in the Project Reunion 0.8 prerelease
Projects
None yet
Development

No branches or pull requests