-1

In C# wpf I have three different projects:

  1. Designer
  2. Executor Client
  3. Executor Server

If I launch the designer (1) there are no problems for it is launched alone.

Instead if I launch the Executor Client (2) I always have to launch the Executor server (3). I am aware that I could use the multiple projects launch but I find it much more convenient both for debug and for release to follow this procedure:

  1. launch Executor client
  2. inside Executor client check for Executor server presence and if not found launch it from inside the Executor Client with Process.start(...).

Now my question is: since I launch it not with usual right click-debug launch with multiple project but with single project (on the first project) and from inside it I launch the second project Will there be any problems in debugging? I mean breakpoints, JIT and everything else? Is this safe and good practice?

Thanks for helping

Patrick

Patrick
  • 3,073
  • 2
  • 22
  • 60
  • 1
    If you want to be able to debug the project in Visual Studio, you should start it with the debugger attached. Alternatively, you could [attach the debugger](https://learn.microsoft.com/en-us/visualstudio/debugger/attach-to-running-processes-with-the-visual-studio-debugger?view=vs-2019) to the already running process once you have started it from somewhere else than Visual Studio. Does this answer your question? – mm8 Aug 14 '20 at 11:47
  • 1
    If you set your relevant projects all to start up then you can just debug everything. If you run them all separately you need multiple instances of visual studio at once and each instance will have a substantial overhead. Both can work but starting all your projects in one instance is usually far more convenient and advisable. The exception to this would be if starting up a server or something was extremely resource hungry as it creates very expensive resources or something. I'd usually use mocks to avoid that. – Andy Aug 14 '20 at 14:01
  • Thanks for both comments. They both might work. I am searching for the most convenient one. In any case I have to do some operations each time I launch the server. – Patrick Aug 17 '20 at 13:00
  • @mm8 is there any way to automatically attach the debugger from code behind so that I can automate the procedure? – Patrick Aug 17 '20 at 13:02
  • @Andy also the solution you propose migh be good. But the problem is that both projects are part of the same solution. So I would have to load the same solution twice... any workaround? – Patrick Aug 17 '20 at 13:03
  • @Patrick The workround is multiple startup projects in the one solution. That obviates loading the same solution multiple times because it starts up multiple projects when you run. From the one instance. – Andy Aug 17 '20 at 13:42

1 Answers1

1

The simplest approach when you have a services project and front end project in one solution is usually to set multiple startup projects.

When you hit f5 this then starts up not just your one front end project but any others you also choose. All from the one instance of visual studio.

The debugger is then attached to all the projects and you can seamlessly debug between front end and service code.

The way you do that is:

https://learn.microsoft.com/en-us/visualstudio/ide/how-to-set-multiple-startup-projects?view=vs-2019

To set multiple startup projects In Solution Explorer, select the solution (the top node).

Choose the solution node's context (right-click) menu and then choose Properties. The Solution Property Pages dialog box appears.

Expand the Common Properties node, and choose Startup Project.

Choose the Multiple Startup Projects option and set the appropriate actions.

When you do that you will see a list of your projects with comoboboxes. You use the combo boxes to set the ones you wish to run.

enter image description here Aside from the convenience, you then avoid the overhead inherent in running multiple instances of visual studio.

Andy
  • 11,864
  • 2
  • 17
  • 20
  • Yes thanks a lot that works. So in short, after having configured as above, when I launch the ExecutorClient+ExecutorServer I launch as multiple projects. When instead when I launch the Designer on its project and launch for debug. Still wondering if that can be automated with buttons that launch the project or projects I want with a single click.... – Patrick Aug 20 '20 at 09:12
  • 1
    You can have different settings for release and debug. I almost always want to start multiple projects when debugging. Until I come to testing a deploy. When I usually have a release version on a server anyhow. I suppose you could add another configuration but I'm not sure that really satisfies your "single click". – Andy Aug 20 '20 at 09:30