Skip to content

Commit f931e6d

Browse files
authored
Merge pull request #705 from MicrosoftDocs/dharshanb/winui3_doc
Documentation for Microsoft.Identity.Client.Desktop.WinUI3 package
2 parents 185db2f + 3dafaae commit f931e6d

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

dotnet/api/overview/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Check out the [scenario overview](/entra/msal/dotnet/getting-started/scenarios)
2929

3030
[![NuGet badget for Microsoft.Identity.Client.Desktop](https://img.shields.io/nuget/v/Microsoft.Identity.Client.Desktop.svg?style=flat-square&label=Microsoft.Identity.Client.Desktop&colorB=00b200)](https://www.nuget.org/packages/Microsoft.Identity.Client.Desktop/)
3131

32+
[![NuGet badge for Microsoft.Identity.Client.Desktop.WinUI3](https://img.shields.io/nuget/v/Microsoft.Identity.Client.Desktop.WinUI3.svg?style=flat-square&label=Microsoft.Identity.Client.Desktop.WinUI3&colorB=00b200)](https://www.nuget.org/packages/Microsoft.Identity.Client.Desktop.WinUI3/)
33+
3234
[![NuGet badge for Microsoft.Identity.Client.Extensions.Msal](https://img.shields.io/nuget/v/Microsoft.Identity.Client.Extensions.Msal.svg?style=flat-square&label=Microsoft.Identity.Client.Extensions.Msal&colorB=00b200)](https://www.nuget.org/packages/Microsoft.Identity.Client.Extensions.Msal/)
3335

3436
### Higher-Level Libraries

msal-dotnet-articles/advanced/webview2.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ To use WebView2 in your application, the following requirements must be met:
2525
- MSAL.NET version 4.28.0 and higher.
2626
- [WebView2 runtime](/microsoft-edge/webview2/) must be installed on the machine.
2727

28+
### Package Requirements
29+
30+
The package required depends on your target framework and application type:
31+
32+
- **.Net Framework** : Use [`Microsoft.Identity.Client.Desktop`](https://www.nuget.org/packages/Microsoft.Identity.Client.Desktop/)
33+
- **.NET MAUI 9+ and WinAppSDK packaged apps**: Use [`Microsoft.Identity.Client.Desktop.WinUI3`](https://www.nuget.org/packages/Microsoft.Identity.Client.Desktop.WinUI3/)
34+
2835
## Call pattern
2936

3037
When attempting to use the new WebView2 runtime, keep in mind the following required changes:
@@ -50,13 +57,32 @@ var pca = PublicClientApplicationBuilder
5057
| .NET Core | WebView2 with fallback to Legacy<sup>2</sup> | System |
5158
| .NET 6<sup>3</sup> | WebView2 with fallback to Legacy<sup>2</sup> | System |
5259
| .NET 6 Windows | WebView2, fallback to Legacy | WebView2, embedded |
60+
| MAUI 9+/WinAppSDK packaged apps | WebView2 with WinUI 3, no fallback to legacy<sup>4</sup> | WebView2, embedded |
5361

5462
<sup>1</sup> Legacy web view is the default in .NET Framework apps. WebView2 can be used via Microsoft.Identiy.Client.Desktop package.
5563
<sup>2</sup> .NET Core and .NET 6+ apps can only use web view via Microsoft.Identity.Client package.
5664
<sup>3</sup> MSAL.NET doesn't provide explicit `net5.0` binaries. .NET 5 apps will follow .NET Core behavior.
65+
<sup>4</sup> Use WinUI 3-based WebView2 implementation with B2C/ADFS support for MAUI 9+ and WinAppSDK packaged applications.
66+
67+
### When to Use
68+
69+
Use `Microsoft.Identity.Client.Desktop.WinUI3` when:
70+
- Building .NET MAUI 9+ applications
71+
- Developing WinAppSDK packaged applications
72+
- Requiring reliable B2C or ADFS authentication flows
73+
- Requiring WinRT framework compatibility
74+
75+
Use `Microsoft.Identity.Client.Desktop` in all other scenarios.
5776

5877
## Troubleshooting
5978

79+
### Package Selection Issues
80+
81+
If you encounter issues with WebView2 integration, ensure you're using the correct package for your target framework:
82+
83+
- **Error**: Could not load file or assembly 'Microsoft.Web.WebView2.Core' or WinRT-related exceptions in .NET MAUI 9+ or WinAppSDK packaged apps
84+
- **Solution**: Switch from `Microsoft.Identity.Client.Desktop` to `Microsoft.Identity.Client.Desktop.WinUI3` for MAUI 9+ and WinAppSDK packaged applications.
85+
6086
### WebView2 on .NET Framework
6187

6288
There's a scenario when an app that targets .NET Framework and references the [MSAL.NET NuGet package](https://www.nuget.org/packages/Microsoft.Identity.Client/) tries to acquire token interactively with WebView2 embedded browser, WebView2 will throw exceptions. These errors can be `System.BadImageFormatException: An attempt was made to load a program with an incorrect format.` or `System.DllNotFoundException: 'Unable to load DLL 'WebView2Loader.dll': The specified module could not be found.` As of MSAL.NET 4.32.0 these exceptions are wrapped into [`MsalClientException`](xref:Microsoft.Identity.Client.MsalClientException).

0 commit comments

Comments
 (0)