Visual Studio 2008, WCF Service Libraries, and CTRL-F5

Service Station, by Aaron Skonnard

Syndication

One of the cool new features in Visual Studio 2008 is automated debugging for WCF service libraries. Simply create a new WCF Service Library project (using the new WCF project templates), press F5, and voila!

When you press F5, Visual Studio launches WcfSvcHost.exe, a generic WCF host application that hosts your service library. WCF Service Library projects now come with an App.config file -- this is where WcfSvcHost.exe reads the service/endpoint configuration during initialization. A generic WCF client application (WcfTestClient.exe) is also started, and it communicates with your service via MEX to download metadata. It provides a generic mechanism for filling out the data required by each service operation, invoking the operation, and viewing the results. It even works with complex types unlike the ASMX-generated test forms. Sweet.

You can configure the service library to use a custom client application if you desire. Go to the Debug tab within the project properties and specify your app as a command-line argument ( /client:“YourClient.exe“ ).

Note: for some reason the latest drop of the BizTalk Services SDK (0.9.0324.0) breaks this feature. So if you have the BizTalk Services SDK installed and you try pressing F5, you'll most likely get the following exception:

Unhandled exception has occured in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.

Object reference not set to an instance of an object.

If you uninstall the BizTalk Services SDK, this feature will work normally once again.


Posted Nov 15 2007, 09:39 AM by Aaron Skonnard
Filed under:

Comments

Ben Walters wrote re: Visual Studio 2008, WCF Service Libraries, and CTRL-F5
on 12-14-2007 9:31 PM
Is there any way to disable this feature? We have a custom WCF host which is an NT service, and we can't stop the WcfSvcHost process from launching when we debug. The WcfSvcHost help and some blogs I've seen suggest setting the Start Action to "Start external program", but unfortunately this doesn't seem to work in a solution where the startup project is set to be something other than the host, and VS can't actually launch my NT service anyway. Unchecking the "Enable Visual Studio hosting process" option does nothing. Help!
jm wrote re: Visual Studio 2008, WCF Service Libraries, and CTRL-F5
on 12-18-2007 10:49 PM
For now you can remove the ProjectTypeGuids tag from the project file as a workaround.
blinnov wrote re: Visual Studio 2008, WCF Service Libraries, and CTRL-F5
on 01-03-2008 4:34 PM
Accidentally found that if app.config is made invalid in corresponding project, wcfsvchost still starts but cannot host the service
Colby Cavin wrote re: Visual Studio 2008, WCF Service Libraries, and CTRL-F5
on 01-24-2008 4:20 PM
Ben, Here's another possible solution. It doesn't remove the problem, it just works around it.
http://colbycavin.spaces.live.com/blog/cns!5FFDF795EBC7BEDF!176.entry
Scott Walters wrote re: Visual Studio 2008, WCF Service Libraries, and CTRL-F5
on 02-04-2008 1:58 PM
It may not be the most elegant solution, but I disabled the WcfSvcHost on debug feature by locating WcfSvcHost.exe on my hard drive and renaming it.
Andreas Tamm wrote re: Visual Studio 2008, WCF Service Libraries, and CTRL-F5
on 04-15-2008 1:08 AM
You can disabble the hosting in VS by deleteing the app.config and delete the commandline arguments in the project settings on the Debug tab.
Erik wrote re: Visual Studio 2008, WCF Service Libraries, and CTRL-F5
on 08-20-2008 2:57 PM

in Visual Studio 2008, there's a new tab in the properties of the project where you can prevent WcfSvcHost from starting while debugging.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?