Skip to content

[Bug] #5090

@akulyakhtin

Description

@akulyakhtin

Library version used

4.5.0

.NET version

net45

Scenario

PublicClient - desktop app

Is this a new or an existing app?

None

Issue description and reproduction steps

I have the following code:

IPublicClientApplication application = PublicClientApplicationBuilder.Create("myclientid")
                    .WithAuthority("https://login.microsoftonline.com/mytenantid")
                    .WithDefaultRedirectUri()
                    .WithLogging((level, message, containsPii) =>
                        {
                            Console.WriteLine($"MSAL Log: {level} - {message}");
                        }, LogLevel.Verbose, enablePiiLogging: false)
                    .Build();


await application.AcquireTokenInteractive(scopes)

It works fine with .net46 and above, bringing in the popup login screen.

However with .net45 I'm getting the following error:

MSAL Log: Info - (False) MSAL 4.5.0.0 MSAL.Desktop Microsoft Windows NT 6.2.9200.0 [01/20/2025 13:51:32 - 64be2ddb-148a-4083-8367-621dad14a1b4] (UnknownClient: 0.0.0.0) === Token Acquisition (InteractiveRequest) started:

Authority Host: login.microsoftonline.com
MSAL Log: Verbose - (False) MSAL 4.5.0.0 MSAL.Desktop Microsoft Windows NT 6.2.9200.0 [01/20/2025 13:51:32 - xxx] (UnknownClient: 0.0.0.0) [Instance Discovery] Tried to use network cache provider for login.microsoftonline.com. Success? False
MSAL Log: Info - (False) MSAL 4.5.0.0 MSAL.Desktop Microsoft Windows NT 6.2.9200.0 [01/20/2025 13:51:32 - xxx] (UnknownClient: 0.0.0.0) Fetching instance discovery from the network from host login.microsoftonline.com
MSAL Log: Error - (False) MSAL 4.5.0.0 MSAL.Desktop Microsoft Windows NT 6.2.9200.0 [01/20/2025 13:51:33 - xxx] (UnknownClient: 0.0.0.0) Exception type: System.Net.Http.HttpRequestException
---> Inner Exception Details
Exception type: System.Net.WebException

I'm running it on WIndows 11 Home x64.

My questions are:

  1. Can I use MSAL with .NET 4.5?
  2. If yes, how do I modify the code, since the same code works with .NET 4.6?

Thank you very much for you help.

Best regards,
Alexander

Relevant code snippets

Expected behavior

No response

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions