I wasted a couple of hours today due to unexpected behaviors when running the default Windows Service project in Visual Studio 2008.
I wanted to test replacing the default contract interface (IService1.cs) and service (Service1.svc). So, here are the simple steps that made me crazy.
1. Create a new C# WCF Service Application project.
2. Run the project. You'll see the metadata page. Stop running.
3. Delete Service1.svc and IService1.cs.
4. Right-click the solution, Add > New Item, choose WCF Service. Name it Service1.
5. Select the Solution in the Solution Explorer. (that's your first clue.) Run the project. You'll see a directory listing.
You can accuse me of being dense, or not thinking, but when I saw this different behavior, I assumed the service wasn't working right. Now add these factors.
* Sometimes, if I edited web.config at all, the directory listing would appear.
* Sometimes, if I edited the .svc file (using Open With > Text Editor), the metadata page would appear.
* Sometimes, I'd get an error "Unable to start program 'http://localhost:3571/Service1.svc'"
I kept trying things, including folder/file compares of a new project to a non-working one. (It turns out this would have led me to the answer eventually).
Finally, searching on "debug mode wfc service "directory listing", I found this site, and this sentence:
At this point, if you browse to the location http://localhost/ExchangeService using Internet Explorer, you'll be able to see a directory listing (as long as the settings are like those in the previous figure). If you click on the Service.svc, you are then brought to the default help screen generated by System.ServiceModel.Activiation.HttpHandler for *.svc extensions.
I ran the project showing a directory listing, clicked on Service1.svc, and sure enough got the metadata page. Then, the light bulb went on.
The WCF Service Application project automatically sets the project's default page to Service1.svc. When I deleted that page, the project reset to Current Page.
So, what about those behaviors where sometimes it showed the metadata page? Well, when I was editing the web.config file, it would show the directory listing. When I was editing the Service1.svc file, it would show the metadata, because that was the current page.
What a fucking waste of my time.