SonarLint can't bind to project

I’m using
Microsoft Visual Studio Enterprise 2019 Version 16.7.5
SonarLint for Visual Studio 4.26.0.22454
SonarQube Version 6.7.7 (build 38951)

I’m able to connect to SonarQube from Visual Studio but when I try to bind to a project I got these error:

Failed to bind the solution to SonarQube project, try again.
See more information in the output window (SonarLint).

And the output shows that:

Binding solution to SonarQube project: Download quality profile(s):
Successfully downloaded quality profile. Name: ‘Sonar way (outdated copy)’, Key: ‘cs-sonar-way-35493’, Language: ‘C#’
INFO: SonarLint connected mode no longer installs the analyzers NuGet packages. The analyzers embedded in the VSIX are used instead.
Binding solution to SonarQube project: Generating project rule sets
Ruleset binding: all projects need to be updated reference the generated ruleset.
Failed to write credentials, Win32ErrorCode: 1312. See https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes for more information.
Unexpected error during workflow execution: Failed to write credentials.

Hi @bsalmeida, welcome to the community.

Are you running VS with impersonation?
During the binding process, we save the credentials into Windows’ credentials store.
Error code 1312 (ERROR_NO_SUCH_LOGON_SESSION) can happen when the code runs under impersonation context (see a similar stackoverflow thread).
If you’re running with impersonation, then please run VS without and then the binding should work.

EDIT: according to MS’ documentation, you will also get this error if you’re in a network session, e.g. logged in via Remote Desktop, Remote Assistance, etc.

Hi Rita!

In my company everyone runs VS with impersonation (as ADMIN), but some people can bind projects. Probably the answer is the Remote Desktop that I’m using.

Hi Bruno,

It’s probably indeed due to Remote Desktop. I’m sorry, I don’t have a way to fix that as it’s a Windows limitation. You will need to run VS outside of Remote Desktop for SonarLint to be able to store the credentials.

Happening this week on my MSVS 2022 [ADMIN] projects.

“”
Failed to write credentials, Win32ErrorCode: 1312. See Tutorial - Debug system error codes - Win32 apps | Microsoft Learn for more information.
Unexpected error during workflow execution: Failed to write credentials.
“”

On…
Microsoft Visual Studio Professional 2022 Version 17.6.3
VisualStudio.17.Release/17.6.3+33801.468
Microsoft .NET Framework Version 4.8.04084
Installed Version: Professional
SonarLint for Visual Studio 6.16.0.69538

Not remote - on my laptop, with corporate MSVS install.
Hadn’t ran Sonar in a while, so don’t think it’s this weeks .Net updates.
Any bright ideas?