Gaining control over WcfSvcHost.exe

 

As soon you switch to the new Visual Studio 2008 and the .NET 3.5 Framework and start coding WCF you will notice some nice new tools which will perhaps greatly simplify you development efforts. In the previous VS 2005 version using the WCF & WPF Extensions (November 2006 CTP) whenever you have created a new WCF Service Library project, additionally you have been forced to create some test-host application and a test-client. Often both of them were simple console applications with a very few lines of code; e.g. in the host instantiating new ServiceHost(…) and calling Open() on that new instance.

In VS2008 this practice can be promptly abandoned, except you have some good reasons to proceed in that old manner. In the new development environment the host and the test-client will be created automatically for you, as soon the F5 (debug) button is hit. Visual Studio 2008 will by default start a new WcfSvcHost.exe utility which will host your WCF Library according the recent app.config configuration details. The picture below displays the opened host. The second utility which will be also started automatically (except the host failed while attempting to host the library) is the WcfTestClient.exe GUI test-client. The picture below displays such test-client which is created against a simple math-library offering the four basic operations.

 

You can of course read more about these tools in the MSDN Library for VS2008 which is recommended to install along with VS 2008, so I stop annoying the public with such well known details. Anyone can figure them anyway. However a few details you will perhaps barely find in the documentation.

The first thing I was not really comfortable with is the fact that you cannot switch off this default hosting behavior. Even if you have explicitly created your own host, as soon you will start debugging (e.g. that host or any client) the WcfSvcHost.exe will pop-up unwanted. Unfortunately there is absolutely no way to turn this behavior off. Things become a little bit more annoying if your solution contains more than a single WCF Library. While starting the debugger, for each WCF Library in the solution, the VS 2008 IDE will automatically start a new WcfSvcHost.exe instance. You will notice this curiosity seeing the WcfSvcHost-Icons suddenly multiplying in the system toolbar (see the displayed picture). 

The good news is, there is simple tricky help to remedy things and to gain full control over this tool. Simply open-up the concerned library project file (.csproj for C#) which is an XML document and look for the line with the element <ProjectTypeGuids>. In that line there is a GUID number associated with the WcfSvcHost.exe utility: "{3D9AD99F-2412-4246-B90B-4EAA41C64699}". Simply delete this GUID number and save the project-file. The automatic hosting stops immediately. You have to delete the highlighted part like the line below shows.

<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

See you next time, by 🙂

Advertisements
This entry was posted in Uncategorized - Common. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s