Visual Studio and WCF applications: why does the WCF Test Client not start?
Posted: (EET/GMT+2)
If you are developing WCF (Windows Communication Foundation) applications with Visual Studio, you might have noticed that initially, when your press F5 to start debugging your service application, Visual Studio will (oftentimes) launch the built-in WCF Test Client application (WcfTestClient.exe).
However after starting to customize the default template application, you might noticed that suddenly, when you run the application, you won't see the WCF Test Client anymore, but instead your web browser will launch.
This is good for many situations, but sometimes, you might wish to get back to the WCF Test Client. However, this is not easy as it sounds, and requires in my experience three things to be correctly set:
- A special .proj file (Visual Studio project file) setting needs to be set to true
- You must have set your application’s startup file to point to a .SVC file
- When starting your application, you must have focus in the Solution Explorer. (This seems to depend on your Visual Studio version.)
Firstly, the project file setting. This setting is part of the WCF application template (such as the "WCF Service Application" template), but once your start changing your project file's settings, this setting disappears. This happens when you open the WCF project's properties, and change some settings and save your changes. Similarly, if you add a new project to the solution, the project file gets edited, and thus the setting is removed.
The settings, which is documented on MSDN blogs, is named EnableWcfTestClientForSVC. This setting must be manually added to your project file (.csproj, or .csproj.user) to the location:
Project/ProjectExtensions/VisualStudio/FlavorProperties/WebProjectProperties
This setting needs to be set to "True" to enable WCF Test Client functionality, i.e. the automatic launch of the test client when you run your application from Visual Studio:
<EnableWcfTestClientForSVCDefaultValue>True</EnableWcfTestClientForSVCDefaultValue>
It seems the location where this setting is added also affects the functionality of whether the WCF Test Client is launched or not, and seems to work best when added as the last element of the WebProjectProperties node.
With the setting in place in the project file, you need to make sure your service's .SVC file is set as the startup page of your application. This can be project's properties under Web and Start Action. Here, it's easiest to select the setting "Specific Page", and type in the name of your service, such as "Service1.svc".
These two settings might already fix the issue, but sometimes, you additionally need to focus the service file in the Solution Explorer, and then start your service application.
Note that even if all else fails, you can still start the test client manually. Locate WcfTestClient.exe under your Visual Studio's install folder, and run it. By default, it is stored under "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE".
Hope this helps!