0

I need to execute a .NET 6 or 7 Background Service as a different account user. Note I need to do this in Visual Studio 2022. I have referenced "Start external program" functionality under the Debug section of a project's properties and reviewed How to debug a Visual Studio 2022 console application running as a service using a gMSA.

Has anyone figured out how to do this with 2022's new Debug settings?

I've tried different permutations on the following screen, with different arguments, with and without working directory, etc.:

enter image description here

When I debug the application, a console appears requesting the password (I do realize there is switch for caching this) which I provide. It attempts to start a different console, yet closes extremely quick. The original console then shows an exit code of 0:

enter image description here

VS's Output window shows the following:

08:12:35:002    The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
08:12:35:002    The program '[33484] runas.exe: Program Trace' has exited with code 0 (0x0).
08:12:35:002    The program '[33484] runas.exe' has exited with code 0 (0x0).

My TargetFramework is "net6.0" and I have a number of runtimes and sdks on this box.

Has anyone been successful with 2022 and have some recommendations?

  • I'm not sure if [RunAs](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc771525(v=ws.11)) works on your OS. Maybe you can try [this](https://stackoverflow.com/a/12923052) shift + right-click method – Jingmiao Xu-MSFT Dec 21 '22 at 09:11
  • This is Window 10 so yes it does. If I attempt to run VS as the service account then it struggles with licensing and source control. – Keith Nicholson Dec 21 '22 at 14:19

0 Answers0