You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dotnet/api/overview/index.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,8 @@ Check out the [scenario overview](/entra/msal/dotnet/getting-started/scenarios)
29
29
30
30
[](https://www.nuget.org/packages/Microsoft.Identity.Client.Desktop/)
31
31
32
+
[](https://www.nuget.org/packages/Microsoft.Identity.Client.Desktop.WinUI3/)
33
+
32
34
[](https://www.nuget.org/packages/Microsoft.Identity.Client.Extensions.Msal/)
Copy file name to clipboardExpand all lines: msal-dotnet-articles/advanced/webview2.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,13 @@ To use WebView2 in your application, the following requirements must be met:
25
25
- MSAL.NET version 4.28.0 and higher.
26
26
-[WebView2 runtime](/microsoft-edge/webview2/) must be installed on the machine.
27
27
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
+
28
35
## Call pattern
29
36
30
37
When attempting to use the new WebView2 runtime, keep in mind the following required changes:
@@ -50,13 +57,32 @@ var pca = PublicClientApplicationBuilder
50
57
| .NET Core | WebView2 with fallback to Legacy<sup>2</sup> | System |
51
58
| .NET 6<sup>3</sup> | WebView2 with fallback to Legacy<sup>2</sup> | System |
52
59
| .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 |
53
61
54
62
<sup>1</sup> Legacy web view is the default in .NET Framework apps. WebView2 can be used via Microsoft.Identiy.Client.Desktop package.
55
63
<sup>2</sup> .NET Core and .NET 6+ apps can only use web view via Microsoft.Identity.Client package.
56
64
<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.
57
76
58
77
## Troubleshooting
59
78
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
+
60
86
### WebView2 on .NET Framework
61
87
62
88
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