views:

337

answers:

5

I have 3 projects in my solution: 1) A silverlight Application Project 2) ASP.Net Web Application Project 3) A WCF Service Application. Projects 1&2 have a service reference to project 3. The binding type is basicHTTPbinding.

If I set project 2 as the start-up project, I am break points set in both project 1 & 2 are hit, but not break points in project 3.

If I set project 3 as the start-up project, I can still use my client application and break points in project 3 are hit but not the breakpoints in projects 1 & 2.

I would like to be able to set breakpoints in all projects of my solution and have them hit no matter what the select start-up project is. I have tried enabling tracing on the WCF project and including details in the exception; neither have worked. Any advice?

A: 

You haven't mentioned unit testing, but if each individual project contains a suite of unit tests, you can be more confident of the individual behavior of each project, and your integration testing would, as a consequence, would be much simpler.

The kind of breakpoint-fix testing you are describing is very difficult in an application with so many moving parts, and it is not repeatable.

Robert Harvey
Its an interesting point, how easy would it be to add a complete set of unit tests to existing code that hasn't be structured to support unit tests?
AnthonyWJones
The ASP.NET component is the least testable. If MVVM is being employed in Silverlight, it is testable all the way up to the UI veneer. The WCF component is completely testable.
Robert Harvey
If I am setting a breakpoint to isolate a problem, I seldom set more than one, and I certainly don't set them system-wide as described. That is just too much to look at all at once.
Robert Harvey
@Robert: Sounds great! How easy is all that to add to an existing pile of code that is ready for debugging as in the question?
AnthonyWJones
It doesn't have to be a complete unit test suite. Rather than trying to breakpoint several areas at the same time, some targeted unit tests could be employed.
Robert Harvey
Any recs on how to test to ensure that UI objects and event bindings are getting disposed if properly? My motivation for the question is that I was using hit count condotional breakpoints to identify where the code I am working with was having these problems.
Gus
No, I don't have any recommendations for this; I am surprised that you would be having problems getting objects to dispose, given the garbage collection nature of the .NET framework. I suggest you post this as a new question.
Robert Harvey
+1  A: 

Have you checked in the Debug|Attach Processes dialog to see which processes VS has attached to?

I suspect that its not attaching to the development web server running the WCF service. If so having started with the ASP.NET Application try adding an attachment to the other development web service.

AnthonyWJones
Is a way to set up the solution to do this automatically?
Gus
A: 

Based on your description (and I may be wrong), it sounds like you have at least two different application, i.e., processes. While it's apparently possible to debug multiple processes in a single instance of Visual Studio (see here), it's not something that I've ever done (or even comtemplated for that matter).

I typically run an instance of the debugger for each process I want to debug. An easy way to do this is to put the following line of code in the main startup function for each application:

System.Diagnostics.Debugger.Break();

When you run the application from Windows Explorer, you'll be prompted to select the debugger you want. Just create a new instance of the debugger for each application you want to debug and you can set your breakpoints from there.

Thanks to Peter Oehlert for correcting my original comment.

Matt Davis
-1 This is not correct, you can definitely attach to multiple processes with 1 VS debug session.
Peter Oehlert
That's apparently true; I've just never done it before. I'll update my answer.
Matt Davis
A: 

You can definitely attach to all 3 processes, I am however not certain that the transparent step-into of all 3 will happen.

Use your current setup and then choose Debug->Attach to Process to add your WCF project. At this point, you can try to step-into the WCF service host from either the ASP or Silverlight side and see if it will seamlessly transition. I think there might be a limit of 2 processes for this to work, so if it fails you can set a breakpoint at the interface of your WCF project and when you step-over in the ASP or SL projects your breakpoint will be hit.

Whenever a breakpoint is hit in any of the processes, the debugger will stop all of your processes concurrently. You can migrate through the locations of each process by using Debug-> Windows -> Processes and the Debug -> Windows -> Threads will let you switch threads in each process.

Peter Oehlert
A: 

There are a couple ways of doing this.

1) Two instances of Visual Studio open at the same time. There are several other advantages to having your web service and data access in a separate solution. If you do this you can even edit one while the other is running which can help in certain situations.

2) If you have good reasons to have it all in one solution, you can start separate debugging sessions by right clicking on the web service and going to Debug -> Start new instance. Then you can do the same with the web application project. Both will now be running and debugging in the single Visual Studio solution.

However, if both are running inside IIS you will have a conflict when trying to attach two debugging sessions to IIS. Try running one (or both) of them in a local development server. You can fix the IP# of the development server if you need to preserve a service reference.

babernethy