May 2008 - Posts

WCF Best Practices

In our conversations with customers and partners, questions related to the design and development best practices are quite common and WCF is not an exception. Some of these questions are very specific to a customer scenario but most of them are generic questions around contract versioning, security, load balancing, etc. There are a number of resources on MSDN and CodePlex that cover these general topis and since I usually send these links to developers in the follow up emails, I think it is a good idea if I put these links in this blog post.

We highly recommend WCF developers to read these best practices in the early stages of the development because some of these practices need to be adopted from the very first version of your application. For example, in order to create Forward-Compatible Data Contracts you need to implement IExtensibleDataObject starting from the first version of the data contract.

So here we go... I will try to keep this list updated as I find other resources and write my own posts on this topic.

Contracts
Data Contract versioning
Service versioning

Clients
Avoiding problems with the "using" statement

Services and Hosting
IIS Hosting
Load balancing
Controlling resource consumption and improving performance

MSMQ bindings
Poison message handling in MSMQ 3.0 (Applicable to Windows XP and Windows Server 2003)
Poison message handling in MSMQ 4.0 (Applicable to Windows Vista and Windows Server 2008)

Security
WCF Security Guidance
Partial trust
Securing PeerChannel applications
Security concerns and useful tips for tracing

Communication
Reliabale Sessions

Deployment
Deploying WCF applications with ClickOnce

Posted by Mehran Nikoo | with no comments
Filed under:

How can I disable WcfSvcHost?

When we create a WCF application using some of the built-in WCF project templates (such as WCF Service Library) in Visual Studio 2008, a project type Guid (3D9AD99F-2412-4246-B90B-4EAA41C64699) is added to the PropertyTypeGuids element in the project file. When we debug a project that has this type Guid, Visual Studio runs WcfSvcHost.exe, which auto-hosts our service for debugging and testing purposes.



This is a useful feature if we want to get our service up and running quickly but we really want to use our own host application at some point so we need to be able to disable this functionality (ideally we should be able to switch it on/off). Nicholas Allen wrote a blog entry showing how to do this manually by editing the project file and removing the type Guid mentioned above. He also referred to an upcoming feature in Visual Studio 2008 SP1, which allows us to toggle this setting using the GUI.

So this is how this feature works in Visual Studio 2008 SP1 Beta. In the project properties window, an additional tab called "WCF Options" is displayed for those projects that have the WCF magic type Guid.



This tab has a checkbox entitled "Start WCF Service Host when debugging another project in the same solution" and this item is checked by default. This means Visual Studio will start WcfSvcHost.exe even if we are debugging another (let's say a console) application we want to use as our service host.





If we uncheck this box, WcfSvcHost.exe will be started only if we choose to debug our WCF Service Library project and it will not run when we debug the console application (which is our service host).

This is great as we don't have to edit the project file manually and we can easily switch this feature on/off.

Posted by Mehran Nikoo | with no comments
Filed under: ,