Link to home
Start Free TrialLog in
Avatar of Sanmarie
Sanmarie

asked on

How Execute one project while editing another project in same VS .NET Solution

I have a solution with 3 projects: a console project, a windows forms project and a class library project. Actually, I'm learning WCF and the book I'm reading says to run the console application. After which I should add some code to the windows forms application and add a reference to the class library.

The thing is visual studio 2008 doesn't allow me to edit the windows project while the console application is running. The book doesn't give instructions on how to do this. Does anyone know?

Thanks
San
Avatar of HalfAsleep
HalfAsleep

You can "run" an application from visual studio and keep editing anything in visual studio.  You can also start a debug session of one of the projects and still keep editing in the visual studio.  You cannot start 2 debug sessions though.  What is the exact wording from the book?
Avatar of Sanmarie

ASKER

The wording in the book is: "Test the solution by compiling and running the host (the console application) first and then the Client (the windows application)."

I can't run an application in visual studio and keep editing in it. Is there some setting that I need to set? I even went to the properties of the solution and set the host to "Single Startup Project" and "Multiple startup projects" where I set it to "Start without debugging"

Thanks
San
Why do you need to edit it?  I think what the book wants you to do, is to run both the server and the client.  You can achieve this in visual studio by selecting "start without debugging" from the "debug" menu.

It does not sound to me like the book wants you to edit while you are running, merely running the two together to test them.  And you _can_ run an application and edit it at the same time in visual studio.  If you are deugging however, you will not be able to edit the code at the same time.

You have to compile both projects, and then run them both, the host first, and then the client.
And of course, like you have already discovered, you can also tell visual studio to start more than one project, through the solution properties.  You should be able to keep editing in visual studio, even though you have started your two applications, as long as you don't start them in debug mode.
Yes, I know about the option where you can tell visual studio to start more than one project through the solution properties. I cannot edit in Visual Studio when any of the projects is running. Here is another instruction from the book:

1. Start by running the Host project so that you can generate proxies for each service.
2. Go to the client project in solution explorer and right click the project to add a Service reference (This is greyed out for me).
3. Next add code to the client project to invoke each operation as shown below ...
4. Compile and test the client application.

So the instructions are telling me that I should first run the host project. Next, I should  edit the client project which I cannot do. Then finally I should compile and run the client project.

Thanks
San
SOLUTION
Avatar of Aleksei_Malkov
Aleksei_Malkov
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Btw, I would like to add that it is not necessary (though handy) to open another Visual Studio instance to run two or more programs. Just rightclick your project and select Debug > Start New Instance. This also works if you want to test how your program reacts when more than one instance of the program is around.

By default, breaking (hitting Pause or a breakpoint) would break all processes. The option "Break all processes when one process breaks" as mentioned above can be set to prevent that from happening and to keep other processes responsive when you hit a breakpoint.

If you click the Pause button or Debug > Pause, this will break all running processes, regardless of the setting under Options. To break only a certain process, select from the main menu Debug > Windows > Processes and in the Processes window, select the process that you want to pause, step through, or detach (detaching leaves process running, but won't hit the debugger anymore) and click the appropriate button in the Processes window's buttonbar.

-- Abel --
Thanks Abel. Very informative. Here's what I tried but I don't think I get everything you suggested as it's still not working for me or I'm not following your instructions properly.:

"allow edit and continue" is set to On and Break all processes when one process breaks is checked. I even unchecked this to see if it would work.
In the properties of the solution, I select "Multiple startup projects." I set the Host to "Start without debugging" and the client to just "Start" so that its assembly gets loaded.
Next, I run the solution so both the host and client gets started. I hit the break/pause button but I still get the following message:

Changes are not allowed while code is running or if the option break all processes when one process breaks is disabled. the option can be enabled in tools, options, debugging.

Edit a file not in the running project while not in break mode
(I did your instructions under this heading but still doesn't work)

Add a reference to a project while running
(I think that the book intends for me to add a reference to the client while the host project is running because the url of the host doesn't exist or won't be found unless the host is running and listening for requests)

Enabling Edit and Continue in ASP.NET
I couldn't find the "Web" option to "Enable edit and continue. Maybe I'm looking in the wrong place.

Thanks. Please help me out some more and show me where I'm going wrong.

San



this:

> In the properties of the solution, I select "Multiple startup projects."
> I set the Host to "Start without debugging" and the client to just "Start" so that its assembly gets loaded.


will not work. The Host must be starting with debugging, otherwise, Edit and Continue will not work (that only works when Debugging is enabled). I didn't mean to use the option "Multiple startup projects". Just use one startup project. Using your instructions, I didn't manage to get it working either.

So: one startup project, configuration Debug (for all), really load the assembly (in your startup handler or something) but you do not need to do anything with it and hit Pause or a breakpoint. Then you can edit as much as you like.

------

> because the url of the host doesn't exist or won't be found unless the host is running and listening for requests
ok, so that is solved then, that's about something else then a library reference in VS.

> I couldn't find the "Web" option to "Enable edit and continue. Maybe I'm looking in the wrong place.

that's only inside ASP.NET. I don't believe you are using ASP.NET. It looks like you are using a WinForms project and a DLL, right?
Hi Abel,
I'll try your suggestions when I get home. Forgot to bring the source code with me to work.

I was just wondering why the host (the console application) needs to be started in debug mode because it is the client (the winforms application) that I want to modify. The host is just there to listen for incoming requests. I'll try it though.

>>>ok, so that is solved then, that's about something else then a library reference in VS.
I'm learing Windows Communication Foundation (WCF) so yes, this is not just adding a reference to a dll but adding a service reference (generating the proxy at the client). Visual studio gives the two options: Add a Reference (a dll) or Add a Service Reference.

>>that's only inside ASP.NET. I don't believe you are using ASP.NET. It looks like you are using a >>WinForms project and a DLL, right?
Well, I started out with a blank solution then I added a console application project (the host), a windows forms project (the client) and a class library project (the service type) so it didn't include an ASP.NET project in this case. However, there was another example in the book where I added an ASP.NET website as a service host with a windows forms project as the client. In this case I used the svcUtil command tool to generate the proxy for the client. Adding a Service Reference in Visual Studio does the same thing as the svcUtil tool.  VS studio just greys out this option for me because I'm not doing something wrong but I'll try your suggestions and get back to you.

Thanks

San



> Visual studio gives the two options: Add a Reference (a dll) or Add a Service Reference.
well, you cannot do that while running an application, never, ever. Sorry for that. Or you have to add it dynamically, through code, which is quite a bit more work and a project on its own.

> I was just wondering why the host (the console application) needs to be started in debug mode
if you use multiple visual studios, this is not necessary. If you open the host outside visual studio, this is not necessary either (and you can still debug the client from within visual studio). Come to think of it, maybe it is not necessary, full stop. But while I tested, I needed the debug to true....
>>well, you cannot do that while running an application, never, ever. Sorry for that. Or you have to add >>it dynamically, through code, which is quite a bit more work and a project on its own.
Ok

>>>Come to think of it, maybe it is not necessary, full stop. But while I tested, I needed the debug to true.
Will try and let you know



Thanks Abel. It worked. I set breakpoints and that did it.
I set the host as the startup project then I started the client (Debug ->Start New Instance) with breakpoints in it. I was able to add code and save it while the host was running. I was hitting the pause key on the keyboard but VS kept telling me that changes are not allowed while code is running. I guess I don't know how to use the pause/break key.

I guess I need to reread the instructions in the book that says I should start the host then add a service reference to the client while the host is running. As you have explained, I cannot do this. I will email the author to clarify how to do this.

Thanks Abel, HalfAsleep, and Aleksei for all your help!

San
> I was hitting the pause key on the keyboard but VS kept telling me that changes are
> not allowed while code is running. I guess I don't know how to use the pause/break key.

Interesting, never thought of that, but that's not what I meant and sorry for the confusion.

That Pause key on your keyboard is not meant for breaking your application. Incidentally, when you click the Pause button, you break the application where it's currently at, hence the Babylonian confusion. See screenshot for the correct location of that button.

ScreenShot246.png
Ok Abel. Thanks for the clarification. I thought the pause/break key was supposed to do the same thing as putting a breakpoint at a line. Well, that's how we learn. Thanks again for following up.

San