0

Core Question

Given a solution that has multiple projects (A console app and two services, along with some shared libraries), how can I debug the solution (w/breakpoints in both web services + console) if each service needs to run under it's own service account?

Ideal

Set up the project to allow the F5 debugger to immediately attach to both services and the console, while running each service under its own account.

Project Set up

I have a single solution with multiple start entries. I already have it set up to launch each entry point when I click debug, but run into issues actually testing as the database requires the use of windows auth for each service account to connect, but the two services require different service accounts.

Solution:

  • Common Library (shared by all 3 projects)

  • Service 1 (WCF, needs to run as EXAMPLEDOMAIN/ServiceAccount1_DEV)

  • Service 2 (WebAPI, needs to run as EXAMPLEDOMAIN/ServiceAccount2_DEV)

  • Console application (needs both services, don't care what account this runs under)

  • Each service is talking to different physical databases, it is not possible to

Tried so far/things I cannot try

In previous versions of VS, I used VSCommands's DEBUG AS to solve this issue, but that project appears to be dead for VS 2015.

Tried to run visual studio itself as the various service accounts, but run into a "Trial period expired" message if not running it as myself.

Tried to use "C:\Windows\System32\cmd.exe /C runas /savecred /user:ServiceAccount#_DEV DebugTarget.Exe", which works for the console but I haven't figured out how to launch a service with this.

I cannot use a different version of VS, as I am in a locked down corporate environment and only have VS 2015 installed.

I can use plugins on manager approval but have no budget for them, so a plugin like VSCommands is an acceptable answer for my case, but only if it is free.

I cannot change the SQL permissions, as each service is talking to separate physical databases which do not share permissioning.

Edit: Missing ideal outcome block.

J. Patton
  • 27
  • 10
  • It seems that the real issue is not the debugging issue, it would be related to how start/launch a service in command line. Like this case here: https://stackoverflow.com/questions/133883/stop-and-start-a-service-via-batch-or-cmd-file, one idea is that whether you could start or stop the service through the bat file, or using other tool like PsExec or others. Hope it could provide you a path. – Jack Zhai Aug 30 '17 at 05:49
  • @JackZhai-MSFT, I appreciate the reponse, but I'm referring to debugging service projects inside the solution, not installed services on the machine, so neither SC nor PsExec have any actuall installed service to execute. – J. Patton Aug 30 '17 at 14:37
  • Please try to visit this suggestion here: https://stackoverflow.com/questions/5331206/how-to-run-iisexpress-app-pool-under-a-different-identity, another idea is that just turn to the project property to change the IIS Express to local IIS, and then run two projects with two account in IIS. – Jack Zhai Aug 31 '17 at 10:24
  • @JackZhai-MSFT, Local IIS, while not ideal, does get me around the issue at least. If you post it as an answer, I'll accept it. Much appreciated. – J. Patton Sep 01 '17 at 13:16
  • I post it as the answer, would you please mark it as the answer? So it could help other community members who get the same issue. – Jack Zhai Sep 05 '17 at 07:40

1 Answers1

1

Solution:

One idea is that just turn to the project property to change the IIS Express to local IIS, and then run two projects with two account in IIS.

Another thread also discussed the same issue here:

how to run iisexpress app pool under a different identity

Jack Zhai
  • 6,230
  • 1
  • 12
  • 20
  • Commenting in case anybody else comes along with the same question: Accepted answer as this provided a functioning workaround. While it's not quite what I was after, it appears that VS is incapable of meeting my ideal solution out-of-the-box and no free plugin meets the requirement now that VSCommand is no longer being maintained. It's a little more tedious than I hoped, but it does work. – J. Patton Sep 05 '17 at 13:22