Can I debug two local projects running on IIS (not Cassini) - debugging

I have a WCF service and a web application that both need to be hosted in local IIS virtual directories. I start up the WCF project and then when I try to debug the web app at the same time a popup tells me "Unable to start debugging on the web server. Unable to do an AutoAttach." The same problem happens if I try to manually attach to aspnet_wp.exe after the WCF service has already started.

Have you tried firing them both off somehow (basically to get processes) then attaching the debugger to each manually?

Thanks Wyatt,
I created a solution with both projects. Then I set the Startup projects to have both projects start without debugging. Then after they start, I manually attach to the process and get debugging on both sides.

Related

Prevent visual studio 2010 start a local IIS

I have a solution with many types of projects, and some of them are websites. Usually, I debug a non-website projects, but everytime I start to debug any project in the solution, the local visual studio IIS starts runnning.
Is there any possible way to stop running the IIS server ???
Thanks!
Open your project and go to the projects Properties. In web apps, you should see a Web tab/choice. Click that, then you can configure which/what server you want to start. I think that the default is that VStudio likes to use it's internal IIS Express, but you can configure it to use IIS locally on the box or to use a custom server.
You can actually set the project to not start anything in the Start Action section on that 'tab' as well, and to simply wait until it registers a connection.
Note that if you are trying to debug using a non-local server, then remote debugging will have to be on on the server, which isn't a great idea in production environments.

Test Project in Visual Studio 2010 for a Windows Service Project

I am working now in a Windows Service Project and I am having a lot of headaches trying to debug the service, I found a lot of article on how to debug a service but none of them worked for me :(
How to: Debug Windows Service Applications
There is no way after attach the process to enter in my breakpoints (set breakpoints everywhere)
Then I found another creating a windows form inside the project but that Solution is kind of dirty (but a solution).Testing a Windows Service From Within Visual Studio
So the real question is, is there any possible way to create a test project to test the service? (I don't have experience with testing, but I know is a good practice)
Do you want to debug the service or code that service runs?
In the past I would create one project for a service, one project for a library that contains the logic, and one project for a console app that would be used to test and debug the logic locally. That setup covered most of the debugging needs.
Hope this helps!

Visual Studio: Unit Testing a web project in the same solution

I have a solution with a WebAPI project and a VS Test project.
My tests make calls to the API using RestSharp via a Url rather than instantiating the controller itself and injecting things (context etc).
My question, is there a way to tell the test project to launch the web project via IIS Express when a test run begins? Currently I just run two instances of VS, one with the web projected with debugging started and the other running the test package
If you are trying to debug both the test and the service, consider doing this
Launch to debug your Web service in Visual Studio.
Click Debug -> Detach All. IIS Express will keep running.
Set a break point and start Debuging your Unit Test.
(Skip this if you don't need to debug the web service) Click Debug -> Attach to Process. Find iisexpress.exe and attach.
However, you lose Edit and Continue on your web service which was detached.
I wouldn't recommend using the network to unit test Web API. You open yourself up to potential flakiness in the test and you end up testing a whole lot more than the service itself.
But if you really must do so, maybe to test that your client can exchange information with the API, then I'd suggest you look into self-hosting the service:
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/self-host-a-web-api
Self-hosting lets you start up a server for Web API with just a few lines of code and you could have your tests start up this server in the right places. In most cases, this should behave the same as having your service hosted in IIS Express. But there are some important distinctions. For example, you won't be able to use some System.Web concepts you may be used to (like HttpContext.Current).
Update:
I've written a blog post about testing Web API services that might help -
https://learn.microsoft.com/en-us/archive/blogs/youssefm/writing-tests-for-an-asp-net-web-api-service
Hope that helps.
I know this is an old post but I was just faced with this issue. I can provide a more detailed response if / when anyone reads this.
In short.. I created a console app referencing the unit test assembly and via reflection and a simple menu system you can run any one of your tests.
I then set multiple startup projects to be the Web project and the console project.
I can then F5 and debug both the unit test and the Web project from within the same session. No attaching to a process of multiple solutions needed.
Running your web service or site in release non-debug by CTRL-F5 makes it run independent from Visual Studio and you are free to run your Tests from inside VS
I know that this is late but I use this solution:
Start two instances of Visual Studios. Start debugging the API in one VS and then debug the test in another.

How to Add Service Reference when WCF lives in a console host app?

I want to self-host a WCF service in a console application for debugging that lives in my hosting layer. I also have a WPF application that needs to call this WCF service. However, I am unable to Add Service Reference to the console project from the WPF project. What do I do in this scenario? This is easy to do with IIS self-host, just add a .svc file and have it point to the WCF service, but how to do this with console host?
First run the console app and ensure that the service is running.
Then go to AddServiceReference in visual studio and follow your intuition
One alternative to using "add service reference" is to generate a client using SvcUtil. Just fire up the service hosted in your console app, and execute a command in the Visual Studio command prompt with a signature somehwat like this (all on one command line):
svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config
http://localhost:8000/ServiceModelSamples/service
The final bit is the actual address of your service, and may differ based on your host.

Start Web Service in Solution without Web Reference

When I work with a web service in Visual Studio and I'm using a web reference, the WCF web service project is automatically started as soon as I start the client application. Interestingly, this does not change when I remove the web reference.
Is there a setting in Visual Studio to get this behaviour, without actually referencing the service? (I'm working with a WebChannelFactory.)
In the solution's properties, under Common Properties, Startup Project, you can choose Multiple startup projects and select Start as the action for both the service and the consumer.

Resources