Latest Event Updates

New Features in WCF 4.5

Posted on Updated on

With the release of Windows Communication Foundation (WCF) in version 3.0 of the .NET Framework in 2006, Microsoft set the stage for a unified framework for developing service-oriented applications in .NET. Since then, I have personally become quite a fan of WCF and have created countless services and service clients. WCF is flexible and robust, and with .NET 4.5 has become even better!

Though we won’t dive into detail, I would like to take a quick moment to briefly discuss some of the highlights of the new features in WCF 4.5. These are the new features that I have found to be most exciting:

Generated Configuration Files have been Simplified

When we Add a Service Reference via Visual Studio or use the svcutil.exe, a client config file is generated for us. In earlier versions, this file contained every binding present, including those that just had default values. Now the config files only contain those with non-default bindings.

Configuration Validation

When we build our project(s) via Visual Studio, the attributes that we implement within our project classes are validated against the values in the config files. This allows us to discover issues at built-time without having to wait for run-time.

ASP.NET Compabibility Mode Default

Through use of the aspNetCompatibilityEnabled attribute in the <serviceHostingEnvironment> node, WCF now gives developers access to the functionality of the HTTP pipeline when writing WCF services. Setting this to true enables us to access the HttpContext.

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

Support for Asynchronous Streaming

WCF now truly supports asynchronous streaming – this is a significant scalability enhancement!

IIS HTTPS Simplification

A new HTTPS protocol mapping which greatly simplifies implementing a WCF server over HTTPS when using IIS. I remember this being a slight pain in the past.

<system.serviceModel>
    <services>
         <service name="SampleService">
               <endpoint address=""
                     binding="basicHttpsBinding"
                     contract="ISampleService">
              </endpoint>
         </service>
    </services>
 </system.serviceModel>

Prior to WCF 4.5, we would have had a <basicHttpBinding> node and a <security> node with the mode attribute set to “Transport”. Now we just set a basicHttpsBinding attribute within the endpoint. Pretty cool!

Easier Configuration of WCF Services in Code

In the pre-4.5 days, we had to create a ServiceHostFactory that created the ServiceHost. in WCF 4.5, you merely create a public static method named Configure that accepts a ServiceConfiguration object.

public class MyService : IMyService
{
    public static void Configure(ServiceConfiguration config)
    {
        ServiceEndpoint serviceEndpoint = new ServiceEndpoint(new ContractDescription(&quot;IMyService1&quot;),
                new BasicHttpBinding(), new EndpointAddress(&quot;basic&quot;));
        serviceEndpoint.Behaviors.Add(new MyEndpointBehavior());
        config.AddServiceEndpoint(serviceEndpoint);

        ServiceDebugBehavior sdb = new ServiceDebugBehavior();
        sdb.HttpGetEnabled = true;
        config.Description.Behaviors.Add(sdb);

        ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
        smb.IncludeExceptionDetailInDefaults = true;
        config.Description.Behaviors.Add(smb);
    }
}

Multiple Authentication Types via a Single Binding

You read that right! Beginning with WCF 4.5, multiple authentication types can be used via a single endpoint if you are using HTTP with Transport security. Because IIS allows multiple authentication methods on a virtual directory, these same authentication types can be used by WCF for the virtual directory in which the web service is hosted.

WebSocket Support via Two New Bindings

Two new bindings, NetHttpBinding and NetHttpsBinding provide TCP-like performance over the standard HTTP and HTTPS ports (80 and 443) bidirectionally. The HTTP paradigm that we all know and love has been built based on the concepts of requests and responses. The WebSocket specification defines socket connections between a web browser and a server over HTTP. This is a wonderful enhancement because what we have is a connection between the client and the server and both parties can start sending information any time. A discussion of WebSockets is beyond the scope of this short feature overview, but it is a topic worth discussing at a later date.

UDP Support

Anyone familiar with UDP knows that it is a great way to very quickly send messages in one direction. WCF 4.5 now supports UDP!

Conclusion

Though there are other exciting enhancements in WCF 4.5, these are my favorites and in my mind some of the most interesting.

Advertisements

8004E00F – COM+ was unable to talk to Microsoft Distributed Transaction Coordinator

Posted on Updated on

Problem Overview

When you open the Windows Component Services Configuration Console (dcomcnfg), you see a red, downward-pointing arrow on the My Computer icon under Component Services as shown below.

MSDTC 8004E00F - COM+ was unable to talk to the Microsoft Distributed Transaction Coordinator

This error is commonly caused by the MSDTC service being set to run under the local system account instead of NT Authority\NetworkService.

If you check the MSDTC service and discover that this is indeed the problem, follow these steps to change the identity:

  1. Open the Registry Editor (regedit.exe).
  2. Find the following registry key: HKEY_LOCAL_MACHINE\Software\Microsoft\MSDTC
  3. Right-click TurnOffRpcSecurity, then select Modify. Add a value of 1.
  4. Open the Services Console and stop the MSDTC service.
  5. Right-click the service and select Properties on the popup menu.
  6. When the Properties dialog opens, click the Log On tab and change the identity to NT Authority\NetworkService (the password is blank).
  7. Click Apply then click OK.
  8. Return to the Services management console and restart the MSDTC service.

If the problem persists, check the Application Log within the Event Viewer and look for errors (red icons). The Event Viewer is a great resource for finding out what is really going on.

One possible solution is to stop the service, uninstall and then reinstall MSDTC. To do this, follow these steps:

  1. Stop the MSDTC service.
  2. Open a command prompt (cmd).
  3. Type “msdtc -uninstall”.
  4. Type “msdtc -install”
  5. Close the command prompt.