0

Error Message

Unable to attach to the process. Visual Studio has insufficient privileges to debug this process. To debug this process, Visual Studio must be run as an administrator.

Explanation

I use Visual Studio 2019 on a Windows 10 maschine

and installed via PowerShell de Service and start the service.

PowerShell command was:

New-Service -Name "ServiceName" -BinaryPathName D:\Project\ServiceName.exe

I try also with credentials:

$credential = Get-Credential    --> Enter credentials
New-Service -Name "ServiceName" -BinaryPathName D:\Project\ServiceName.exe -Credential $credential

But if I try to attach the Service into Visual Studio 2019 (Run as an administrator) I get the message "Unable to attach..." (see ErrorMessage)

If I installed the service without credentials, I see the entry SYSTEM in the column username in Visual Studio. And with credentials DOMAINNAME\username [administrator]

Why is [administrator] appended at the end?

Do I not have enough rigths on my maschine?

I work on a virtual maschine Windows 10 environment.

Other Settings

Configuration: Local Security Policy --> Logal Policies/User Rights Assignment/Debug programs --> set my Domain

Local Security Policy --> Local Policies/Network access: Sharing and security model for local accounts --> Classic

Try on Debug|AnyCPU and Debug|x86

jps
  • 20,041
  • 15
  • 75
  • 79
  • It depands how you compile your code. Do not use "Any Debug" – Jules_96 Sep 12 '22 at 12:41
  • @Jules_96 Why can't I use AnyCPU? What is the reason? --> The Windows set it automaticly to x86 process. – Ramona Frick Sep 12 '22 at 12:48
  • 1
    Did you actually run Visual Studio AS administrator? In the title bar for visual studio it will actually say "Microsoft Visual Studio (Administrator)" when running as administrator. – LarryBud Sep 12 '22 at 14:32
  • If you want to debug a program on a remote server, just run the debugger on the server. The debugger can be found in the VS installation directory, and the Remote Debugger file is copied to the server. – Housheng-MSFT Sep 13 '22 at 07:53
  • @LarryBud I run the VS2019 with administrator rights – Ramona Frick Sep 13 '22 at 17:34
  • @housheng The Service run on my development environment. I don't have a server/client environment. – Ramona Frick Sep 13 '22 at 17:36

1 Answers1

1

Our IT department found the mistake, it was in the Debug rigths (Local Security Policy/UserRightAssignment/Debug programs)

Now he added me as a user and now it works in the debug mode :-)

https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/debug-programs