Visual Studio 2008 Service Pack 1

Now available here.

My installation took about 2 hours and 15 minutes to download and install.  Make sure you set aside some time for updating your development machine.

In this post, I am going to talk about some (not all) of the features I particularly like with regard to Windows Communication Foundation (WCF).  Refer to the MSDN documentation for more details about all the changes in this service pack.  I've basically split this post into two categories:

  1. Tooling Updates, where I describe features specific to tools.  For example, the IDE, WCF Test Client, etc.
  2. API changes, where I describe changes to classes, methods, properties, etc.

Tooling Updates

WCF Project Options

It is no longer necessary to manually edit your project file as described here to prevent the WCF Service Host from starting when you want to debug your service in a custom host application in the same solution.  Now, you just pop over to your project settings, click on the WCF Options tab and uncheck the option to start the WCF Service Host.

image

WCF Test Client

The WCF Test Client has also picked up some very nice new features that I'll describe here.

Can stand up on its own

Previously, to start the WCF Test Client, you would press F5 and the IDE would take care of launching it (and the WCF Service Host) for you.  Or, if you wanted to use the client to test against a service outside of your solution, you could do so as long as you passed in the base address (as a command line parameter) of a running service so that the WCF Test Client could get to the metadata.

Now, we can start the WCF Test Client without having to pass in the base address.  When the WCF Test Client window opens, go to the File menu and select Add Service... to enter the metadata address for the service(s) you want to test against.  There's even a nice list of previous services you have tested that you can access from the Recent Services menu option. 

image

If you want to test multiple services from the same instance of the WCF Test Client, go right ahead.  This new UI makes it really easy.  You no longer have to open a separate instance of the WCF Test Client for each service.

Another nice addition is the ability to edit the client configuration file.  Just right-click the Config File node in the tree view and select Edit with SvcConfigEditor.

image

From the Service Configuration Editor you can make your modifications as you normally would.  When you are finished and you want to test those changes out, right-click on the service node in the tree view and select Refresh Service to test out your new configuration settings.  Remember, these are client side configuration settings you're editing, not the service's configuration.

image

Can support MessageContracts

Yes, you can now test your services that expose [MessageContract]'s.  This is not something I do much of but knowing that I don't have to write a test client in these situations is worthy of an applause.

Can support XmlSerializer

The WCF Test Client can now support services that use the XmlSerializer for serializing data.

Support for sessions

Suppose you have a service that requires sessions.  Again, in the past you pretty much had to write your own client to test such a service if your service maintained state between calls.  Now, the WCF Test Client maintains the same proxy internally when making calls to a service.  That is, the first time you invoke the service from your client a proxy is created.  The next time you invoke the service, that same proxy instance is used (ie: the same session).  So, for example, if I have a service operation (lets just call it AddNumber) that adds a number (how about 2) to running total and I invoke that operation 5 times, I can expect the result to be 10 as shown here.

image

So, what if I want to create a new session?  Very simple - just check the Start a new proxy checkbox and invoke the service.  This will create new proxy internally and therefore a new instance of the service with the running total initialized to 0.  After the call, the result will be 2 as shown here.  To continue using the new session, uncheck the Start a new proxy checkbox.

image

In light of all these new capabilities, I've promoted the WCF Test Client to my Quick Launch window so I can quickly test a service (or services) without having to load up the IDE.

Publish WCF Service Wizard

There is a new wizard for WCF projects to facilitate publishing of WCF services.  You can access this from the Build menu in Visual Studio 2008, or by right-clicking your WCF service library project and selecting Publish.  This makes publishing ( to IIS for example ) extremely easy.

image

If you create a WCF Service Library project initially and later want to then publish that service to IIS, this option will setup the virtual directories in IIS for you and it will also create the .svc file you will need for that hosting environment.

API Changes

Plain Old CLR Objects (POCO)

This is a great new feature that eases the migration from ASP.NET Web Services to WCF.  Aaron describes this nicely in DataContracts without attributes (POCO support) in .NET 3.5 SP1 so I won't explain it here.  When I first heard of this it smelled non-SOA to me because you don't explicitly define your data.  However, I have come to realize the value of this new feature when it comes to migrating existing ASP.NET Web Services to WCF.  Otherwise, I prefer the explicitness of using [DataContract]'s to define your data.

System.ServiceModel.Web.UriTemplate

The UriTemplate class took on some changes, many of which are used by other parts of the framework.  But, a couple of notables for us WCF folks are described here.

There is a new Defaults property now that enables you to define default values for parameters defined in the template string.  This allows us to do things like this in our service cotracts:

image

If you access the service from your browser and omit the parameter in your URI, then your method will receive this default value.

Compound template segments were also added which allows you to do things like this:

image

From your browser, you would be able to invoke the operation using a URI like this.

http://localhost/myproducts/product(12)