Debugging a site using web service with Visual Studio 2008 - debugging

I've got a solution with many projects
One of these proejcts is a "MyProject.Web" web application.
This has a web reference to MyProject.WebService" project -
I have a breakpoint in the WebService project, and i call the method on one of my Web forms, the break point is not hit....
How can i enable this?

Right-click on the solution and choose "Set Startup Projects". Choose to start multiple projects and select both your web site and web service to start with debugging. Then when you start the debugger they will both fire up and you should have full debugging in both.

I ran into this too a while back and this is what I followed:
http://dansen.wordpress.com/2008/04/15/debugging-wcf-clients-and-services/
Visual Studio has feature that
supports attaching to multiple
projects when starting up.
In this example, I have a WCF service
hosted in IIS which lives in the
Wcf.Demo.IisServiceHost project. I
also have a Wcf.Demo.TestHarness
project which calls the service. I
want to be able to attach the debugger
to both the client and service by
simply pressing F5.

Related

SharePoint 2013 - Set as startup project breaks debugging

I'm using Visual Studio 2013 and I create an App for SharePoint with Provider Hosting (MVC). I then immediately put a break-point on the Index of the Home controller and click play, break point gets hit all is good :)
I then right click the SharePoint app and set as start up project. Then I run again and my break-point doesn't get hit.
To get debugging back again I have to start a new debug instance of the MVC project and then start a new debug instance of my SharePoint app.
What's going on?
As a work around to this problem you shouldn't set the startup project by right clicking, instead follow these steps:
Right click your solution -> select Properties
Select the Multiple startup projects option
Set all your projects action to None
Now go ahead and set your ASP.NET (Provider hosted web app) to Start
Next (if you have multiple SharePoint apps) select the one you are currently working on and set its action to Start
Now when pressing F5 your breakpoints will be hit inside your provider hosted app.

How to debug two web applications/services on IIS from within Visual Studio?

In Visual Studio 2010,
I want to debug two web applications running on IIS at the same time.
When debugging the first application it is ok. But when starting to debug the second application and first program is still in debug mode, Visual Studio prompts:
unable to start debugging on the web server. a debugger is already
attached
How can I solve this problem?
To summarize, one has to set different application pools in IIS for the two applications to debug.
Here is a rough instruction, given that both applications have been deployed to IIS once within Visual Studio.
Open the Internet Information Services (IIS) Manager
Click Application Pools on the left pane
On the right pane add another integrated application pool, let's name it Second ASP.NET 4.0 Integrated
For one application, open the Advanced Settings...
In the properties view finally select Second ASP.NET 4.0 Integrated as the application pool
This way the applications should be debuggable in parallel because each Application Pool spawns a new operating system process to which a separate debugger can be attached.
A windows process can only have one debugger attached to it at a given time. If you get that message it means that you're attempting to debug the same process twice which won't work. But that also means you should be able to debug both web applications in the instance of Visual Studio that's already attached. It may require a few extra steps though to get it to acknowledge the other code
Disable "Just My Code" (Tools -> Options -> Debugger, uncheck "Enable Just My Code"
You may need to manually load symbols for the other web application through the modules window (Debugger -> Windows -> Modules)
After that though (second step may not be necessary) you should be able to set break points in both web applications and otherwise debug them.

Debugging a Silverlight project with a WCF service

I have a WCF service hosted in IIS which is consumed by a Silverlight client application. When I run the Silverlight application, none of the break points seem to get hit (not breakpoints in the service, although they also don't get hit. That service is not in the same solution).
Normally when I've created SL projects in the past, they hit break points by default, and I can't thing I've changed any of the settings.
When I run the project, I do get a message box saying, "The Silverlight project you are about to debug uses web services. Calls to the web service will fail unless the Silverlight project is hosted in and launched from the same web project as the web services. Do you want to debug anyway?"
So I say 'yes'.
My break point is in a place that I know gets hit (InitializeComponent in MainPage.xaml.cs), so that's not it.
I don't know if it makes a difference to the client application, but the WCF service does have within its App.config the compilation debug set to 'true'.
Can anyone help?
Edit:
Some useful points: The project is set to debug. There is no web component to the SL project. The application compiles and runs normally. The code in the screen shot below is the code behind for the main page which is the default page (and the one I see when I start the project). The Visual Studio version is 2010 Ultimate (version 10.0.40219.1 SPRel) and I am not creating an OOB application. As well as just running regularly, I have specifically started from the Debug->Start Debugging option in Visual Studio.
Screen shot:
If that image isn't clear enough, there is the full resolution one here.
Second screen shot showing a break point on the InitializeComponent in MainPage.xaml.cs which doesn't fire (the previous one showed the constructor of the related view model).
Again, if that's not clear enough, the full resolution version is here.
The message your getting is unrelated to your breakpoints not being hit. This 'warning' isn't entirely true as well, as long a the webservice you're calling is running you'll be fine. You can happily ignore this warning.
As to not hitting breakpoints, I can think of two reasons. You could be building in release mode, or you could be starting the wrong project. You should not be starting the MyApp.Web project Visual Studio probably created for you, but the actual Silverlight project.
If it isn't one of those options you should provide a bit more detail about what you're doing, like Visual Studio versions, whether you're running an out-of-browser app, does the app actually work etc. There can be a few more things to check but it hard to guess it them with this little info.
I'm not seeing a test page.htm in your solution. How are you hosting / running the SL app?
If you were hosting it in an ASP.NET web app I'd say check that the Silverlight debugger was enabled on the web project project properties.
But as it is I can't see how the silverlight app is getting run at all...?

Visual Studio: Add service reference to service in a different project in my solution?

I have a Silverlight app that I want to access Azure storage. I have two projects in my solution: a SL project and a ASP web role.
The web role has a service. When I launch the project, I go to the service, and it works fine. (I am able to download the data.)
I'm not entirely sure what I can do through "Add Service Reference", but I suspect that might be what I'm supposed to do here to make use of the full power of WCF. I open the dialog box, and hit "Discover" to find services in my solution. Visual Studio finds my service, but when I click "Go" it fails with a 404 error. This is not terribly surprising, given that my ASP localhost server is not up at the moment.
It seems like I should be able to add the service reference when the devserver is running, but Visual Studio has the menu item to do so grayed out.
What am I supposed to do here? Am I completely confused about what service references are for? Should I just use WebClient, hardcode the URI, and de-serialize the XML into objects myself?
James's answer will work. However, an easier option if you have both service and consumer projects in the same solution is to use the "Discover" button to the right of the "Go" button in the "Add Service Reference" dialog. If you click on the little arrow you will see it says "Services in Solution". This will then make VS search the solution for any valid services you have implemented and thus you don't need to have the service running at the time.
Another option is to run the service locally under IIS.
I think using WebClient is probably overkill. I wouldn't re-implement simply to get around a Visual Studio usability issue (even if it is tempting).
Try opening the projects separately. By this I mean opening two Visual Studios, one with the web service and one with the Silverlight application. Run the web service (so you cansee it working in a browser) and then create a service reference directly to the URL of the service running in debug mode in the other Visual Studio.
Once the service reference is created and all of the proxies are built you won't need to do this again unless you change the interface of the service.

Exception when Deploying to SharePoint 2010 from Visual Studio 2010

I've done MOSS 2007 development for some time, and am just starting to get my feet wet with SharePoint 2010. I created a SharePoint project, added a Visual Web Part, and typed "Hello, World!" into the web part's user control.
Everything works fine the first time I deploy the project (by selecting Deploy from the project's context menu in the Solution Explorer). It deploys the project, activates the feature, and the web part is immediately available for use.
However...
The second time I deploy the project, I get an error in the Error List stating:
Error occurred in deployment step
'Recycle IIS Application Pool':
Invalid namespace
Now, if I go to SharePoint and manually delete the web part, deactivate the feature, and retract the solution, I can deploy from Visual Studio again; the error seems to only occur if the project has been deployed at least once.
I think I'm missing something obvious here. Any recommendations?
I found the answer!
But not on the Web, so I'll post it here as I did in a related posting on SharePoint.SE.
Apparently, VS 2010 uses WMI to control IIS during a redeploy. Without the features enabled, I got the error described above.
The solution was to: open the Turn Windows on or off menu in the Control Panel (under Programs), and enable WMI compatibility. The path to the feature is:
Internet Information Services -> Web
Management Tools -> IIS 6 Management
Compatibility -> IIS 6 WMI
Compatibility
Edit: For reference sake, this article has screenshots of which features should be activated on Windows 7 to support SharePoint.

Resources