<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://bloggingabout.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Dennis van der Stelt : WCF</title><link>http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx</link><description>Tags: WCF</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Databases and coupling</title><link>http://bloggingabout.net/blogs/dennis/archive/2013/01/04/databases-and-coupling.aspx</link><pubDate>Fri, 04 Jan 2013 22:36:12 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:578249</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=578249</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=578249</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2013/01/04/databases-and-coupling.aspx#comments</comments><description>&lt;p&gt;We probably all learned this at school. When you build software, you analyze requirements, find the nouns and build an &lt;a href="http://en.wikipedia.org/wiki/Entity-relationship_diagram"&gt;entity-relationship model&lt;/a&gt;, an ERD. You start with the first normal form and &lt;a href="http://en.wikipedia.org/wiki/Database_normalization"&gt;normalize the model&lt;/a&gt; until you start building software upon it. But when you’re building software in a distributed environment, multiple components will likely need to access the same data. In the most traditional of systems, you’ll have a single database with great value in it, because all data the is valuable to your company is in this database. And all those components are based on this data, so they need access to it. Being more concrete, you can think of this as multiple Visual Studio solutions with projects and they all have connection strings to this high value database.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/5187.reducecoupling_5F00_4DAA67EB.png"&gt;&lt;img title="reducecoupling" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;float:right;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="reducecoupling" align="right" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/3441.reducecoupling_5F00_thumb_5F00_49C4C56E.png" width="240" height="179" /&gt;&lt;/a&gt;We all know coupling is bad, however we don’t always know how to fix this. Because we don’t know where the worst coupling is. Let’s think about this for a minute. We build layers into our software, sometimes even separated through additional facades implemented through SOAP and XML. And than we tell ourselves the user interface is decoupled from the database. So that changes in the database can be made without affecting the upper layers and the user interface. We’ve hidden this behind a data-layer and use complex O/RM solutions to hide even more behind models with complex mappings to the database. Until even the slightest change means updating the model, the mapping, the data-layer and even business logic, facades and everything all the way up to the user interface. Even worse, this change, which took too long to build… it completely breaks other components in our distributed architecture. &lt;/p&gt;  &lt;p&gt;I’ve seen so many solutions trying to fix this. From stored procedures that can be changed on the fly (but without proper testing), to additional tools that should fix problems, to ad hoc data changes. And I just deliberately mentioned the three worst solutions, in my humble opinion. Because too many people execute these so called fixes, ranging from junior developers on the maintenance team to the senior DBA. The problem is, that all of them do this without proper knowledge of the business rules. Because these are actually in the code. So how come we still think we can solve all problems using the mentioned solutions?&lt;/p&gt;  &lt;p&gt;So coming back to our question, where the worst coupling is. It’s in the database! There’s so much hidden business logic in our data. Some of the data belongs together without anyone being able to notice this. One of the worst invisible coupling I’ve ever seen is where the status of a client was made up out of multiple records in a single table. The state of a client was reflected by a record and second record. Unless there was a third record with some information, than the client had another state. Unless the second record had its timestamp in the past, than it was in even another state. And this went on and on. In the end this resulted in hundreds of locations where all these conditions were checked. These states were however completely invisible in the database! One had to just &lt;em&gt;know&lt;/em&gt; what they could possible represent. Until some developer came along and made up another combination of records to present another state.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/5023.database_2D00_integration_5F00_6D807DB9.jpg"&gt;&lt;img title="database-integration" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;float:left;padding-top:0px;padding-left:0px;margin:0px 4px 0px 0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="database-integration" align="left" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/1643.database_2D00_integration_5F00_thumb_5F00_5ACB8402.jpg" width="240" height="180" /&gt;&lt;/a&gt;So how can this be solved? That’s difficult to answer. But a good way to start is try to divide and conquer. Everything that can be taken out of the big database, should be put in another database. That will make the problem smaller and more manageable. Of course it’s ridiculous to just add more connection strings to every single component, so that they can still access the same database. We’d still have the same coupling, but with added complexity of querying the databases. We can’t directly join tables anymore, and don’t get me started on SQL Server’s linked servers.&lt;/p&gt;  &lt;p&gt;Will SOAP and XML free us from the coupling? Not really. Or better yet, not at all. Not in the way most people intended to get rid of coupling. Coupling isn’t solved by taking out design time coupling. It’s the runtime coupling that’s difficult to solve. What if the webservice that queries your smaller database is offline, or it’s blocked by requests from other webservices. Or it’s simply not fast enough for your performance demands. &lt;/p&gt;  &lt;p&gt;The solution is to decouple these services even during runtime. This means they can’t call each other anymore. We have to make sure they know the answer, before these services are asking the question. How this can be achieved, is something for another post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=578249" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Architecture+and+Design/default.aspx">Architecture and Design</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category></item><item><title>What is messaging</title><link>http://bloggingabout.net/blogs/dennis/archive/2012/04/25/what-is-messaging.aspx</link><pubDate>Wed, 25 Apr 2012 06:45:40 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:577522</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=577522</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=577522</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2012/04/25/what-is-messaging.aspx#comments</comments><description>&lt;p&gt;I’ve written in SDN Magazine about messaging and how it relates to RPC. It isn’t about messaging vs. RPC, but more or less an attempt to explain what benefits messaging can add to your software. Monday April 23rd I gave a presentation about the same subject. With this post I want to show the code so people can have a better look at it. Remember that there’s so much more possible than I show. I’m not going all the way, just showing how spatial coupling can be solved. Platform coupling is solved by WCF and nServiceBus self and temporal coupling can be achieved by doing it asynchronously over MSMQ, for example. nServiceBus does this by default, WCF can do this by marking operations as OneWay and selecting the msmqBinding.&lt;/p&gt;  &lt;p&gt;So what did I show? First of all, let’s look at code that Visual Studio 2010 has in its WCF Service Application template. I sometimes get remarks that the info in a post is not complete, so here it goes&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Do File –&amp;gt; New Project&lt;/li&gt;    &lt;li&gt;Select “WCF” on the left and then the “WCF Service Application” template.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;You can see IService1 interface with a method named “GetData” which expects a single parameter and returns a string value. The client knows the method to execute and when something changes, the coupling of the client to the service might break the client. Versioning is only on of the many problems that might hit you. This is the implementation in the Service1 class.&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;public string GetData(int value)
{
    return string.Format(&amp;quot;You entered: {0}&amp;quot;, value);
}&lt;/pre&gt;

&lt;p&gt;Add a new Console Application to your solution, add a Service Reference without changing anything of the defaults. Then create the code to call this service. Your console application should look like this.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;class Program
{
    static void Main(string[] args)
    {
        ServiceReference1.Service1Client svc = new ServiceReference1.Service1Client();
        string result = svc.GetData(10);

        Console.WriteLine(&amp;quot;Result : {0}&amp;quot;, result);
    }
}&lt;/pre&gt;

&lt;p&gt;So the idea is that we don’t create separate methods for everything we want to send, but rather have something in place that finds the correct handler class for our message. So what we need is a single generic method in our service contract that accepts anything that conforms to a message we specify. Add the following method to your IService1 interface and make sure your code compiles. This means you’ll have to implement the method in the Service1 class.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;[OperationContract]
void Execute(Message message);&lt;/pre&gt;

&lt;p&gt;As you can see we specified the class Message as parameter so we’ll need to define it as well.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public class Message
{
}&lt;/pre&gt;

&lt;p&gt;Now the Execute method on our Service1 class needs to call a handler class that will contain our code. We’ll specify a default interface so that all our handlers adhere to this interface. That way we’ll be able to easily find all handlers via reflection. Let’s have a look at the interface.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public interface IHandleMessages&amp;lt;T&amp;gt; where T : Message
{
    void Handle(T message);
}&lt;/pre&gt;

&lt;p&gt;Now all we need to do is create a real message and a handler that will be able to work with this message.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public class GameOfTheYear : Message
{
    public string Name { get; set; }
    public int Year { get; set; }
}

public class GameOfTheYearHandler : IHandleMessages&amp;lt;GameOfTheYear&amp;gt;
{
    public void Handle(GameOfTheYear message)
    {
        Debug.WriteLine(&amp;quot;Game : &amp;quot; + message.Name);
    }
}&lt;/pre&gt;

&lt;p&gt;The message is quite simple and the implementation of our handler maybe even simpler. But these aren’t the point currently. What is important is how we actually execute the Handle method from our service. Here’s the code for it and we’ll go through it line by line.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public void Execute(Message message)
{
    Assembly assembly = (message.GetType()).Assembly;

    var allMessageHandlers =
            from type in assembly.GetTypes()
            where !type.IsAbstract
            from interfaceType in type.GetInterfaces()
            where interfaceType.IsGenericType
            where interfaceType.GetGenericTypeDefinition() == typeof(IHandleMessages&amp;lt;&amp;gt;)
            select type;

    Type messageInterface = typeof(IHandleMessages&amp;lt;&amp;gt;).MakeGenericType(message.GetType());
    var myMessageHandlers = allMessageHandlers
                                    .Where(type =&amp;gt; type.GetInterfaces()
                                    .Any(it =&amp;gt; it == messageInterface))
                                    .Distinct();

    foreach (var handler in myMessageHandlers)
    {
        object handlerInstance = Activator.CreateInstance(handler);
        MethodInfo methodInfo = handler.GetMethod(&amp;quot;Handle&amp;quot;);
        methodInfo.Invoke(handlerInstance, new[] { message });
    }
}&lt;/pre&gt;

&lt;p&gt;At line 3 we get the assembly of the message we’ve received. This is part of the convention over configuration you can use, which states that the handler for the message should be in the same handler. Of course you could scan every single assembly in the same folder as you. For performance benefits you can scan it a single time and store all handlers and its methods in memory. Again, we’re keeping it simple so it’s easier to understand. At line 5 we’re searching for all types that are not abstract (line 7), implement a generic interface (line 9) that are of type IHandleMessages (line 10).&lt;/p&gt;

&lt;p&gt;Then in line 13 we compose a type of the generic IHandleMessages interface with the type of our message. In line 14 we filter our just selected handlers so that we’ll only have the ones that actually implement our exact interface. Now that we have our actual handlers, we can try to create an instance of it (line 21), find the Handle method and invoke it with our message as its parameter.&lt;/p&gt;

&lt;p&gt;Now refresh your ServiceReference in your console application client by right-clicking the service reference and selecting the update item in the context menu. Now you should be able to create a GameOfTheYear object. However, although our service does recognize the “Execute” method, it has no knowledge of the GameOfTheYear class. This simply is because WCF doesn’t automatically provides every single class in its WSDL/MEX-endpoint so we need to provide this information to it. Open the IService1 interface again and change the contract for our Execute method so it looks like this.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;[OperationContract]
[ServiceKnownType(&amp;quot;GetKnownTypes&amp;quot;, typeof(MessageTypeFinder))]
void Execute(Message message);&lt;/pre&gt;

&lt;p&gt;Now recompile the project and update the service reference again. Everything should work flawlessly again. If this works, we can try to see if we can do something very valuable; create an additional handler that logs our messages to disk.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public class GameOfTheYearLogHandler : IHandleMessages&amp;lt;GameOfTheYear&amp;gt;
{
    public void Handle(GameOfTheYear message)
    {
        Logger.Write(&amp;quot;We&amp;#39;ve processed &amp;quot; + message.Name);
    }
}&lt;/pre&gt;

&lt;p&gt;The same code will execute both handlers without any changes. We’ve really decoupled the execution and handling of the message we’re sending from the initial service. As you can see we can create multiple handlers for a single message. What we can also do is create a single handler for multiple messages. We’ll first define the message and add an additional interface to our GameOfTheYearHandler.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public class GameReview : Message
{
    public string NameOfGame { get; set; }
    public string Review { get; set; }
}

public class GameOfTheYearHandler : IHandleMessages&amp;lt;GameOfTheYear&amp;gt;, IHandleMessages&amp;lt;GameReview&amp;gt;
{
    public void Handle(GameOfTheYear message)
    {
        Console.WriteLine(&amp;quot;Game : &amp;quot; + message.Name);
    }

    public void Handle(GameReview message)
    {
        Console.WriteLine(&amp;quot;Revied : &amp;quot; + message.NameOfGame);
    }
}&lt;/pre&gt;

&lt;p&gt;First thing to remember is that we need to make sure the GameReview message is specified as a KnownType to our service. As we don’t want many lines with ServiceKnownTypeAttribute statements there, we need a different solution. Add the following class to your code and then replace the original ServiceKnownType line with the last line in the following code.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public class MessageTypeFinder
{
    public static IEnumerable&amp;lt;Type&amp;gt; GetKnownTypes(ICustomAttributeProvider provider)
    {
        IEnumerable&amp;lt;Type&amp;gt; query =
                from type in typeof(Message).Assembly.GetTypes()
                where typeof(Message).IsAssignableFrom(type)
                select type;

        return query.ToArray();
    }
}

[ServiceKnownType(&amp;quot;GetKnownTypes&amp;quot;, typeof(MessageTypeFinder))]&lt;/pre&gt;

&lt;p&gt;Now we only need to tweak the execution of the handlers in the foreach loop to the following code.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;foreach (var handler in myMessageHandlers)
{
    var methods = from m in handler.GetMethods()
                                where m.Name == &amp;quot;Handle&amp;quot;
                                from p in m.GetParameters()
                                where p.ParameterType == message.GetType()
                                select m;

    object handlerInstance = Activator.CreateInstance(handler);
    var methodInfo = methods.Single();
    methodInfo.Invoke(handlerInstance, new[] { message });
}&lt;/pre&gt;

&lt;p&gt;We can’t simply select the Execute method anymore, as there are multiple. So we’re checking the parameter type and see if it’s the same type as our incoming message. There obviously cannot be more than one method with the exact same parameters, so we can select Single() on line 10 and then we’ll be able to execute the method.&lt;/p&gt;

&lt;p&gt;FYI: During the SDN event I forgot to create the actual instance of the handler and was trying to execute the Handle method on the type. This is obviously not possible. So now you know why it didn’t work during the presentation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;nServiceBus&lt;/strong&gt;

  &lt;br /&gt;So during the presentation I also mentioned nServiceBus. If you look at the code you need to write to use nServiceBus, this is exactly the handlers and messages as I’ve shown in the code above. However with nServiceBus you can use interfaces as messages so you can create message with complex inheritance trees. A method to “initiate” an interface is provided, which creates a proxy which you can then fill with your information. Since version 3.0 of nServiceBus you no longer need to implement the IMessage interface on your messages which makes creating libraries with messages that are shared, much easier, since you don’t need an assembly reference to nServiceBus anymore.&lt;/p&gt;

&lt;p&gt;Of course we have no need to write plumbing code, as nServiceBus has done this all for you.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Transactions are supported in WCF, but with nServiceBus everything is transactional by default.&lt;/li&gt;

  &lt;li&gt;As said, in WCF you can mark messages OneWay and select the msmqBinding to use msmq. nServiceBus does this by default.&lt;/li&gt;

  &lt;li&gt;nServiceBus makes it possible to do request/reply asynchronously. Due to the nature of queuing, it’s not possible to immediately send a response. The sending application however can specify a return queue in it’s message (nServiceBus does this for you) and with a Bus.Reply(myMessage) you send the return message.&lt;/li&gt;

  &lt;li&gt;Retry of message is supported with a variable amount of retries. After final failure the messages get enriched with exception information and transferred to a (configurable) error queue.&lt;/li&gt;

  &lt;li&gt;Publish/Subscribe is possible where one publisher has no knowledge of any clients receiving the messages. A variable number of clients can subscribe to the messages and nServiceBus takes care of subscriptions. Since version 3.0 you can store these in RavenDB.&lt;/li&gt;

  &lt;li&gt;Long running processes (called sagas) are supported where you can wait for multiple incoming messages before continuing.&lt;/li&gt;

  &lt;li&gt;Timeouts are supported so when within a saga messaging don’t arrive on time, you can send yourself a warning. Since version 3.0 you can also send messages to yourself in the future. These messages don’t arrive before the time you specified.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Conclusion
    &lt;br /&gt;&lt;/strong&gt;Again, messaging isn’t the silver bullet to your problems. It is however another way to communicate out of process to other applications or business components. It should provide additional options to implement without your architecture and you should seriously consider it if you haven’t used messaging and/or queuing frameworks before. Messaging has a lot of additional perks which I wrote about in my SDN article. When the new magazine arrives, I’ll post the PDF on my weblog. Until then, you are allowed to contact me and request the article.&lt;/p&gt;

&lt;p&gt;Download the &lt;a href="http://bloggingabout.net/media/p/577521.aspx"&gt;source here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=577522" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Architecture+and+Design/default.aspx">Architecture and Design</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/SDN/default.aspx">SDN</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF4/default.aspx">WCF4</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/nServiceBus/default.aspx">nServiceBus</category></item><item><title>WCF Simple Example in Visual Studio 2010 – part 2</title><link>http://bloggingabout.net/blogs/dennis/archive/2010/06/19/wcf-simple-example-in-visual-studio-2010-part-2.aspx</link><pubDate>Sat, 19 Jun 2010 20:24:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:483603</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=483603</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=483603</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2010/06/19/wcf-simple-example-in-visual-studio-2010-part-2.aspx#comments</comments><description>&lt;p&gt;This topic is covered in multiple posts&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/archive/2010/06/16/wcf-simple-example-in-visual-studio-2010.aspx"&gt;Creating simplest solution with default endpoints&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Manually adding and configuring the endpoints&amp;nbsp;(you&amp;#39;re reading it right now)&lt;/li&gt;
&lt;li&gt;More to come...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The previous post was the most &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2010/06/16/wcf-simple-example-in-visual-studio-2010.aspx"&gt;simple example&lt;/a&gt; of creating a WCF service and calling it from a client application. In this post you can read how you can achieve the exact same behavior, but now manually adding every bit of configuration. So we&amp;rsquo;ll basically override the default endpoints, configure our won, resulting in exactly the same behavior.&lt;/p&gt;
&lt;p&gt;The idea behind this is that you understand what WCF does and that you can do it yourself. Besides that, the previous .NET Framework versions don&amp;rsquo;t support the default endpoints, meaning that the solution at the end of this article also works in Visual Studio 2008.&lt;/p&gt;
&lt;p&gt;What will we do?&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Add BasicHttpBinding endpoint &lt;/li&gt;
&lt;li&gt;Add MEX endpoint &lt;/li&gt;
&lt;li&gt;Add Metadata behavior &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Metadata behavior &lt;br /&gt;&lt;/strong&gt;We&amp;rsquo;ll start with bullet three, simply because almost everything is already in place. The solution from the previous weblog post ended with this in the application configuration from the &lt;em&gt;ConsoleHost&lt;/em&gt; application.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;configuration&amp;gt;
    &amp;lt;system.serviceModel&amp;gt;
        &amp;lt;behaviors&amp;gt;
            &amp;lt;serviceBehaviors&amp;gt;
                &amp;lt;behavior&amp;gt;
                    &amp;lt;serviceMetadata httpGetEnabled=&amp;quot;True&amp;quot;/&amp;gt;
                &amp;lt;/behavior&amp;gt;
            &amp;lt;/serviceBehaviors&amp;gt;
        &amp;lt;/behaviors&amp;gt;
    &amp;lt;/system.serviceModel&amp;gt;
&amp;lt;/configuration&amp;gt;&lt;/pre&gt;
&lt;p&gt;The service behavior has no name, making it the default for all services in WCF4. All we have to do is give it a name. Change line 6 into the following.&lt;/p&gt;
&lt;pre class="brush: csharp; first-line: 6;"&gt;                &amp;lt;behavior name=&amp;quot;MyBehavior&amp;quot;&amp;gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Adding BasicHttpBinding endpoint &lt;br /&gt;&lt;/strong&gt;We&amp;rsquo;ll now add the first endpoint using the BasicHttpBinding. Right under &amp;lt;system.serviceModel&amp;gt; we&amp;rsquo;ll add the &amp;lt;services /&amp;gt; tag and add our service. Completely empty this will result in the following.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;&amp;lt;services&amp;gt;
    &amp;lt;service name=&amp;quot;&amp;quot;&amp;gt;
        &amp;lt;endpoint 
            address=&amp;quot;&amp;quot; 
            binding=&amp;quot;&amp;quot; 
            contract=&amp;quot;&amp;quot; /&amp;gt;
    &amp;lt;/service&amp;gt;
&amp;lt;/services&amp;gt;&lt;/pre&gt;
&lt;p&gt;Now we have to fill in the blanks. More information can be found in the articles about the &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/10/18/WCF-Part-1-_3A00_-Services-ABC.aspx"&gt;WCF ABC&lt;/a&gt; and &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/11/09/WCF-Part-3-_3A00_-Hosting-the-service.aspx"&gt;hosting the service&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Name&lt;/strong&gt; &lt;br /&gt;This is a bit misleading, as you can&amp;rsquo;t just enter any name, it&amp;rsquo;s actually the type of the service. &lt;br /&gt;This must be the fully qualified name of the implementation of our service. This means not the interface, but the class. Its name is &lt;span style="font-family:Courier New;font-size:x-small;"&gt;EmailValidator&lt;/span&gt; but its full name includes the namespace, resulting in &lt;span style="font-family:courier;font-size:x-small;"&gt;EmailService.EmailValidator&lt;/span&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Address &lt;br /&gt;&lt;/strong&gt;The address we don&amp;rsquo;t have to fill in, because the base address in our code already defines it. You can also define this in configuration as you can read in the post &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/11/29/WCF-Part-6-_3A00_-Address.aspx"&gt;Address&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Binding&lt;/strong&gt; &lt;br /&gt;The binding is simply basicHttpBinding. Note the camelCasing. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contract &lt;br /&gt;&lt;/strong&gt;Here we should enter the contract, which is our interface. As with the name attribute, we need to enter the fully qualified name, resulting in &lt;span style="font-family:Courier New;font-size:x-small;"&gt;EmailService.IEmailValidator&lt;/span&gt;. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can view the end result at the end of this article and in the download, also at the end of this article.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Adding MEX endpoint &lt;br /&gt;&lt;/strong&gt;The MEX endpoint needs the metadata behavior configured, but we&amp;rsquo;ll get back to that. First we need to add the endpoint. Again the WCF ABC, an address, binding and contract.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Address&lt;/strong&gt; &lt;br /&gt;Because we cannot have this endpoint at the same address as the BasicHttpBinding endpoint, we need to enter &amp;ldquo;mex&amp;rdquo; here. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Binding&lt;/strong&gt; &lt;br /&gt;This is simple, it&amp;rsquo;s just mexHttpBinding &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contract &lt;br /&gt;&lt;/strong&gt;This is simple as well, although a bit weird, it HAS to be &lt;span style="font-family:Courier New;font-size:x-small;"&gt;IMetadataExchange&lt;/span&gt;. Not the fully qualified name or anything, it has to be just this. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Enabling the metadata behavior &lt;br /&gt;&lt;/strong&gt;Now all we have to do is add the metadata behavior. This is done at the root of the service, where we first entered the name. There&amp;rsquo;s another attribute there called &lt;span style="font-family:Courier New;font-size:x-small;"&gt;behaviorConfiguration&lt;/span&gt;. We have to enter the name of our behavior configuration there, which is &lt;span style="font-family:Courier New;font-size:x-small;"&gt;MyBehavior&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;End result&lt;/strong&gt; &lt;br /&gt;This results in the following configuration.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;configuration&amp;gt;
    &amp;lt;system.serviceModel&amp;gt;
        &amp;lt;services&amp;gt;
            &amp;lt;service name=&amp;quot;EmailService.EmailValidator&amp;quot; behaviorConfiguration=&amp;quot;MyBehavior&amp;quot;&amp;gt;
                &amp;lt;endpoint 
                    address=&amp;quot;&amp;quot; 
                    binding=&amp;quot;basicHttpBinding&amp;quot; 
                    contract=&amp;quot;EmailService.IEmailValidator&amp;quot; /&amp;gt;
                &amp;lt;endpoint 
                    address=&amp;quot;mex&amp;quot; 
                    binding=&amp;quot;mexHttpBinding&amp;quot; 
                    contract=&amp;quot;IMetadataExchange&amp;quot; /&amp;gt;
            &amp;lt;/service&amp;gt;
        &amp;lt;/services&amp;gt;
        &amp;lt;behaviors&amp;gt;
            &amp;lt;serviceBehaviors&amp;gt;
                &amp;lt;behavior name=&amp;quot;MyBehavior&amp;quot;&amp;gt;
                    &amp;lt;serviceMetadata httpGetEnabled=&amp;quot;True&amp;quot;/&amp;gt;
                &amp;lt;/behavior&amp;gt;
            &amp;lt;/serviceBehaviors&amp;gt;
        &amp;lt;/behaviors&amp;gt;
    &amp;lt;/system.serviceModel&amp;gt;
&amp;lt;/configuration&amp;gt;&lt;/pre&gt;
&lt;p&gt;You can &lt;a href="http://bloggingabout.net/media/p/483608.aspx"&gt;download the Visual Studio 2010 and the Visual Studio 2008 solution right here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=483603" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+2.0/default.aspx">.NET Framework 2.0</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+4.0/default.aspx">.NET Framework 4.0</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF4/default.aspx">WCF4</category></item><item><title>WCF Simple Example in Visual Studio 2010</title><link>http://bloggingabout.net/blogs/dennis/archive/2010/06/16/wcf-simple-example-in-visual-studio-2010.aspx</link><pubDate>Wed, 16 Jun 2010 18:36:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:483568</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>48</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=483568</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=483568</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2010/06/16/wcf-simple-example-in-visual-studio-2010.aspx#comments</comments><description>&lt;p&gt;This topic is covered in multiple posts&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Creating simplest solution with default endpoints (you&amp;#39;re reading it right now)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/archive/2010/06/19/wcf-simple-example-in-visual-studio-2010-part-2.aspx"&gt;Manually adding and configuring the endpoints&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;More to come...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It&amp;rsquo;s been a long, long time since I wrote the original &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2007/04/20/wcf-simple-example.aspx"&gt;WCF Simple Example&lt;/a&gt; post. It was even before Visual Studio 2008 and since then, a lot of things changed. As still a lot of folks place comments and questions to that post, let&amp;rsquo;s have a look at what we currently have to do to get a service up and running and consume it in a client.&lt;/p&gt;
&lt;p&gt;This time we&amp;rsquo;ll start with a class library assembly (a .dll) and we&amp;rsquo;ll host the service inside a console application. The client will use a Windows Forms application again. Although we do everything in Visual Studio 2010, most will be usable in VS2008. I will mention it when it isn&amp;rsquo;t and provide an alternative. I&amp;rsquo;ll be a bit more descriptive about what we have to do, so this post is a little longer than the original.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Create Project &lt;br /&gt;&lt;/strong&gt;First create a new &amp;quot;class library&amp;quot;, this will become the implementation of our service. Choose New Project and select the &lt;em&gt;Class Library&lt;/em&gt; as project template. At the bottom, set as name for the project &amp;ldquo;EmailService&amp;rdquo; and the solution name &amp;ldquo;WCFSimpleExample2010&amp;rdquo;. If you can&amp;rsquo;t set the solution name, check the &lt;em&gt;Create directory for solution&lt;/em&gt; box.&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/0284.createnewproject_5F00_2128C507.png"&gt;&lt;img height="168" width="242" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/2308.createnewproject_5F00_thumb_5F00_555CEE4D.png" alt="createnewproject" border="0" title="createnewproject" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Create the contract &lt;br /&gt;&lt;/strong&gt;We&amp;rsquo;ll first create the contract with only one method; or &lt;em&gt;operation&lt;/em&gt; as they are called in WCF. The &amp;quot;class library&amp;quot; should have added a class called &amp;quot;Class1&amp;quot;, you should rename&amp;nbsp;it to IEmailValidator.cs and make it an interface with the same name.&lt;/p&gt;
&lt;p&gt;Now add a single method signature called ValidateAddress that takes one string argument called emailAddress and returns a boolean. This is a normal interface, nothing fancy and the end result is as follows:&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public interface IEmailValidator
{
    bool ValidateAddress(string emailAddress);
}&lt;/pre&gt;
&lt;p&gt;Now we need to tell WCF that this is our contract. We do that by adding attributes, but first we need to add a reference to System.ServiceModel. Right-click the project and select &lt;em&gt;Add reference&lt;/em&gt; and select System.ServiceModel from the list. I&amp;rsquo;m using the &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef"&gt;Visual Studio 2010 Pro Power Tools&lt;/a&gt; so my screen might look different from yours, but the idea is the same.&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/8737.AddReference1_5F00_6E58BE92.png"&gt;&lt;img height="169" width="242" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/6175.AddReference1_5F00_thumb_5F00_07548ED8.png" alt="AddReference in solution explorer" border="0" title="AddReference in solution explorer" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/0243.AddReference2_5F00_4E3DB1D5.png"&gt;&lt;img height="169" width="292" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/8750.AddReference2_5F00_thumb_5F00_6739821A.png" alt="AddReference2" border="0" title="AddReference2" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now you can add the attributes to your interface. On top of the interface place the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.aspx"&gt;ServiceContract&lt;/a&gt; attribute and on the operation place the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute.aspx"&gt;OperationContract&lt;/a&gt; attribute. Add the using System.ServiceModel at the top of your codefile, or let Visual Studio do it for you by having your cursor in on of the attribute names. When you typed it in correctly and case sensitive, you can press CTRL + . and a context menu should appear to let you add the using automatically. Your interface should finally look like this:*&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;[ServiceContract]
public interface IEmailValidator
{
    [OperationContract]
    bool ValidateAddress(string emailAddress);
}&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Create the service implementation&lt;/strong&gt; &lt;br /&gt;Now that we&amp;rsquo;ve created the contract we need to write code for the service to actually do what we want it to do. Create a new class and make it implement the interface. After that, use a regular expression to verify the email address and return true value if it&amp;rsquo;s correct. You should have something like the following code, or make up your own. :-)&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public class EmailValidator : IEmailValidator
{
    public bool ValidateAddress(string emailAddress)
    {
        Console.WriteLine(&amp;quot;Validating: {0}&amp;quot;, emailAddress);
        
        string pattern = @&amp;quot;^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$&amp;quot;;
        return Regex.IsMatch(emailAddress, pattern);
    }
}&lt;/pre&gt;
&lt;p&gt;Now you have the two most important classes for your service. You don&amp;rsquo;t actually have to use an interface, but it&amp;rsquo;s a best practice. That way you can inherit multiple interfaces for or do versioning with different interfaces.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Creating the host&lt;/strong&gt; &lt;br /&gt;As said, for our host we&amp;rsquo;ll initially use a console application. Choose to add a new project and now have a &lt;em&gt;Console Application&lt;/em&gt; as project template. Name it &amp;ldquo;ConsoleHost&amp;rdquo;.&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/7633.CreateConsoleHost_5F00_2E22A518.png"&gt;&lt;img height="168" width="242" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/2746.CreateConsoleHost_5F00_thumb_5F00_471E755D.png" alt="CreateConsoleHost" border="0" title="CreateConsoleHost" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Add the reference to &lt;em&gt;System.ServiceModel&lt;/em&gt; again and also to your &lt;em&gt;EmailService&lt;/em&gt; project. In your Main method, create a ServiceHost object and give it the correct arguments in the constructor, as shown below.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;Type serviceType = typeof(EmailValidator);
Uri serviceUri = new Uri(&amp;quot;http://localhost:8080/&amp;quot;);

ServiceHost host = new ServiceHost(serviceType, serviceUri);
host.Open();&lt;/pre&gt;
&lt;p&gt;On line 4 is the creation of the ServiceHost object. As first argument it receives the implementation of our service as a type. And a base address as second argument. Read &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/11/29/WCF-Part-6-_3A00_-Address.aspx"&gt;more about base addresses here&lt;/a&gt; and &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/11/09/WCF-Part-3-_3A00_-Hosting-the-service.aspx"&gt;more about hosting here&lt;/a&gt;. The type is defined on line 1 and the base address on line 2. Finally on line 5 our host is started.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WCF4 : Default endpoints&lt;/strong&gt; &lt;br /&gt;Now here&amp;rsquo;s a difference in .NET Framework 4.0 because this is not possible in previous version of .NET. Currently the default endpoints are used, which is a new feature to make configuration of your services less of a hassle. I like to explicitly define everything in detail so everyone knows what happens. But for our example, this works quite well. If you&amp;rsquo;re not using .NET 4.0 you might want to continue to&lt;a href="http://bloggingabout.net/blogs/dennis/archive/2010/06/19/wcf-simple-example-in-visual-studio-2010-part-2.aspx"&gt; part 2&lt;/a&gt; of this weblog post, which will be posted later.&lt;/p&gt;
&lt;p&gt;You could add the default endpoints yourself by adding host.AddDefaultEndpoints(); to the code, right before the host.Open(); statement.&lt;/p&gt;
&lt;p&gt;How can we see what endpoints are configured by default? I have a little script from &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/11/28/Display-WCF-host-details_3B00_-code-snippet.aspx"&gt;way back&lt;/a&gt; that displays everything currently running. I won&amp;rsquo;t go into details, just paste the following after the host.Open(); part.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;#region Output dispatchers listening
foreach (Uri uri in host.BaseAddresses)
{
    Console.WriteLine(&amp;quot;\t{0}&amp;quot;, uri.ToString());
}

Console.WriteLine();
Console.WriteLine(&amp;quot;Number of dispatchers listening : {0}&amp;quot;, host.ChannelDispatchers.Count);
foreach (System.ServiceModel.Dispatcher.ChannelDispatcher dispatcher in host.ChannelDispatchers)
{
    Console.WriteLine(&amp;quot;\t{0}, {1}&amp;quot;, dispatcher.Listener.Uri.ToString(), dispatcher.BindingName);
}

Console.WriteLine();
Console.WriteLine(&amp;quot;Press &amp;lt;ENTER&amp;gt; to terminate Host&amp;quot;);
Console.ReadLine();
#endregion&lt;/pre&gt;
&lt;p&gt;Now you should be able to see the endpoints like in the first following screenshot. You can use a browser like Internet Explorer to go to the service uri and look at the default &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/11/09/WCF-Part-4-_3A00_-Make-your-service-visible-through-metadata.aspx"&gt;MEX endpoint&lt;/a&gt;.&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/7853.ConsoleHostWithoutConfig_5F00_0E07985B.png"&gt;&lt;img height="172" width="341" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/6471.ConsoleHostWithoutConfig_5F00_thumb_5F00_06E85BE3.png" alt="ConsoleHostWithoutConfig" border="0" title="ConsoleHostWithoutConfig" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/0068.mexendpointwithoutconfig_5F00_1FE42C28.png"&gt;&lt;img height="172" width="240" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/1200.mexendpointwithoutconfig_5F00_thumb_5F00_7FC91F6A.png" alt="mexendpointwithoutconfig" border="0" title="mexendpointwithoutconfig" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;As you can see it&amp;rsquo;ll tell you that a MEX endpoint (aka metadata) isn&amp;rsquo;t configured yet. Now an easy way would be to do this via the new default endpoints. My first impression was that this would work.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;Type serviceType = typeof(EmailValidator);
Uri serviceUri = new Uri(&amp;quot;http://localhost:8080/&amp;quot;);

ServiceHost host = new ServiceHost(serviceType, serviceUri);
host.AddDefaultEndpoints();
// This actually doesn&amp;#39;t just simply work.
host.AddServiceEndpoint(new ServiceMetadataEndpoint());&lt;/pre&gt;
&lt;p&gt;On line 5 you can see that we add the default endpoints and line 7 adds the ServiceMetadataEndpoint, or the MEX endpoint. Unfortunately it cannot add the Metadata behavior itself, so you still have to do this yourself. The other way it to specify in configuration that you want metadata enabled. Also new in WCF4 is that you can inherit configuration. You can specify in either the machine.config or in your local configuration what should be enabled by default for WCF services. I recommend you don&amp;rsquo;t do this in machine.config, but that&amp;rsquo;s just my opinion. Here&amp;rsquo;s how I enabled it in my project configuration, the app.config of our console host. Remember that in the follow up post to this, we&amp;rsquo;ll do this the old fashioned way, which will work in Visual Studio 2008 and has my preference.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;
&amp;lt;configuration&amp;gt;
    &amp;lt;system.serviceModel&amp;gt;
        &amp;lt;behaviors&amp;gt;
            &amp;lt;serviceBehaviors&amp;gt;
                &amp;lt;behavior&amp;gt;
                    &amp;lt;serviceMetadata httpGetEnabled=&amp;quot;True&amp;quot;/&amp;gt;
                &amp;lt;/behavior&amp;gt;
            &amp;lt;/serviceBehaviors&amp;gt;
        &amp;lt;/behaviors&amp;gt;
    &amp;lt;/system.serviceModel&amp;gt;
&amp;lt;/configuration&amp;gt;&lt;/pre&gt;
&lt;p&gt;As you can see, I have not specified a name for the behavior so in WCF4 this means it&amp;rsquo;ll be used by all services. This also means that every service needs a base address for http endpoints.&lt;/p&gt;
&lt;p&gt;For reference, here&amp;rsquo;s the code for our console host:&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;static void Main(string[] args)
{
    Type serviceType = typeof(EmailValidator);
    Uri serviceUri = new Uri(&amp;quot;http://localhost:8080/&amp;quot;);

    ServiceHost host = new ServiceHost(serviceType, serviceUri);        
    host.Open();

    #region Output dispatchers listening
    foreach (Uri uri in host.BaseAddresses)
    {
        Console.WriteLine(&amp;quot;\t{0}&amp;quot;, uri.ToString());
    }

    Console.WriteLine();
    Console.WriteLine(&amp;quot;Number of dispatchers listening : {0}&amp;quot;, host.ChannelDispatchers.Count);
    foreach (System.ServiceModel.Dispatcher.ChannelDispatcher dispatcher in host.ChannelDispatchers)
    {
        Console.WriteLine(&amp;quot;\t{0}, {1}&amp;quot;, dispatcher.Listener.Uri.ToString(), dispatcher.BindingName);
    }

    Console.WriteLine();
    Console.WriteLine(&amp;quot;Press &amp;lt;ENTER&amp;gt; to terminate Host&amp;quot;);
    Console.ReadLine();
    #endregion
}&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Accessing the metadata &lt;br /&gt;&lt;/strong&gt;Because we now have enabled our service and our metadata endpoint, the MEX endpoint, we can view it through Internet Explorer or another browser. Execute the console host (it has to be alive or the endpoints won&amp;rsquo;t be accessible) and browse to the URI of your service : &lt;a href="http://localhost:8080/"&gt;http://localhost:8080/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If this shows a nice screen with a link to the WSDL you&amp;rsquo;re very likely done with the service.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Create client application &lt;br /&gt;&lt;/strong&gt;We&amp;rsquo;ll now add another project that will consume the service and will be able to verify if entered email addresses are valid, or at least according to our regular expression.&lt;/p&gt;
&lt;p&gt;Add a new console application like before and this time call it ConsoleClient. Make sure your service (the host) is running, but don&amp;rsquo;t have it running in debug mode. Easiest way is to set the ConsoleHost project as startup project en press CTRL + F5 to run it without debugging turned on.&lt;/p&gt;
&lt;p&gt;We now need a proxy class that sits between our client and service. There are two ways to create a proxy for our service. I have a preference for doing it manually, so you know what exactly is happening. I&amp;rsquo;ll show that first.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Manually create proxy&lt;/strong&gt; &lt;br /&gt;First start up a Visual Studio 2010 (or Visual Studio 2008) Command Prompt and move to the location of the &lt;em&gt;ConsoleClient&lt;/em&gt;. Because it&amp;rsquo;s a Visual Studio command prompt you should have access to the proxy generator svcutil.exe. Input the following commandline&lt;/p&gt;
&lt;p align="center"&gt;&lt;span style="font-family:Courier New;"&gt;svcutil http://localhost:8080/ /o:ServiceProxy.cs /config:App.Config /n:*,ConsoleClient&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This should generated two files, the service proxy and an application configuration file. Go back to Visual Studio and in your ConsoleClient application make all files visible through the icon at the top of the &lt;em&gt;Solution Explorer&lt;/em&gt;, as seen in the right screenshot. The App.Config and ServiceProxy.cs should become available and you can include these. &lt;br /&gt;&lt;span style="font-size:xx-small;"&gt;&lt;strong&gt;Update&lt;/strong&gt; : The console window screenshot shows ConsoleHost as namespace, this is incorrect and should be ConsoleClient as the full commandline statement above states.&lt;/span&gt;&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/7268.CreateProxy1_5F00_46B24268.png"&gt;&lt;img height="152" width="430" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/8321.CreateProxy1_5F00_thumb_5F00_0D9B6566.png" alt="CreateProxy1" border="0" title="CreateProxy1" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/2210.CreateProxy2_5F00_54848863.png"&gt;&lt;img height="152" width="187" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/0361.CreateProxy2_5F00_thumb_5F00_6D8058A8.png" alt="CreateProxy2" border="0" title="CreateProxy2" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When we ran svcutil.exe the first argument was the location of our service as specified in the host. This is the base address. The second argument is what the tool should output, our proxy. The third argument is that we also want it to update our application configuration and if it&amp;rsquo;s not available, create it. The last argument is the namespace our proxy should be placed in (or should have), which should now be the same as our application itself.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Call the service&lt;/strong&gt; &lt;br /&gt;Now we can finally start consuming the service. When you go to your &lt;em&gt;Main&lt;/em&gt; method in your &lt;em&gt;Program&lt;/em&gt; class again, you can access the proxy class, which is the name of your service with &lt;em&gt;Client&lt;/em&gt; suffixed. So ours is &lt;em&gt;EmailValidatorClient&lt;/em&gt;.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;EmailValidatorClient svc = new EmailValidatorClient();
bool result = svc.ValidateAddress(&amp;quot;dennis@bloggingabout.net&amp;quot;);&lt;/pre&gt;
&lt;p&gt;In line 1 you can see the proxy being initialized. Does doesn&amp;rsquo;t mean the connection is set up, this is done on first call. Line 2 shows the calling of the service and getting the result back.&lt;/p&gt;
&lt;p&gt;This is our entire method &lt;em&gt;Main&lt;/em&gt; which will continue to ask for email addresses until you enter none.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;static void Main(string[] args)
{
    while (true)
    {
        Console.WriteLine(&amp;quot;Enter an email address or press [ENTER] to quit...&amp;quot;);
        string emailAddress = Console.ReadLine();

        if (string.IsNullOrEmpty(emailAddress))
            return;

        EmailValidatorClient svc = new EmailValidatorClient();
        bool result = svc.ValidateAddress(emailAddress);

        Console.WriteLine(&amp;quot;Email address is valid : {0}&amp;quot;, result);
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Creating proxy through Visual Studio, the easy way. &lt;br /&gt;&lt;/strong&gt;Instead of creating the service proxy manually, via svcutil.exe, you can also let Visual Studio create it for you. Just right-click the project and select &amp;lsquo;Add Service Reference...&amp;rsquo; You&amp;rsquo;ll get a dialog window where you enter the address of your service and the namespace.&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/4784.CreateServiceReference_5F00_34697BA6.png"&gt;&lt;img height="194" width="240" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/2311.CreateServiceReference_5F00_thumb_5F00_4D654BEB.png" alt="CreateServiceReference" border="0" title="CreateServiceReference" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now we entered &lt;em&gt;ConsoleClient&lt;/em&gt; as namespace, but it concatenates this to the already existing namespace. So now you can access the &lt;em&gt;EmailValidatorClient&lt;/em&gt; via &lt;em&gt;ConsoleClient.ConsoleClient.EmailValidatorClient&lt;/em&gt;. One of the reasons I don&amp;rsquo;t like to use this automatically generated proxy class. You should now not forget to add a using statement to this namespace at the top of your class. Probably a better solution is to set the namespace to &lt;em&gt;Proxies&lt;/em&gt; or something, in the dialog, so the complete namespace makes more sense.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Run the client&lt;/strong&gt; &lt;br /&gt;While the service is still running (of not, restart it) you can right-click your ConsoleClient and select &lt;em&gt;Debug&lt;/em&gt; and &lt;em&gt;Start new instance&lt;/em&gt; and you&amp;rsquo;re done.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What next?&lt;/strong&gt; &lt;br /&gt;Next we&amp;rsquo;ll extend this blogpost with at least two more, step-by-step blogposts explaining how to manually add endpoints and how to host your service in IIS. You can &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2010/06/19/wcf-simple-example-in-visual-studio-2010-part-2.aspx"&gt;read more about it here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Download&lt;/strong&gt;&lt;br /&gt;Here&amp;#39;s the &lt;a href="http://bloggingabout.net/media/p/483576.aspx"&gt;download for VIsual Studio 2010&lt;/a&gt;. In the follow up article a Visual Studio 2008 solution is available.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=483568" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+3.0/default.aspx">.NET Framework 3.0</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+4.0/default.aspx">.NET Framework 4.0</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF4/default.aspx">WCF4</category></item><item><title>Microsoft AppFabric explained for SDN</title><link>http://bloggingabout.net/blogs/dennis/archive/2010/05/25/microsoft-appfabric-explained-for-sdn.aspx</link><pubDate>Tue, 25 May 2010 05:31:19 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:483383</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=483383</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=483383</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2010/05/25/microsoft-appfabric-explained-for-sdn.aspx#comments</comments><description>&lt;p&gt;Last Tuesday, may 18th 2010, I gave a presentation on Microsoft’s AppFabric. I explained that there are actually two themes of it; Windows Server AppFabric and Windows Azure AppFabric. They both have their own products.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Windows Server AppFabric&lt;/strong&gt;&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;Services and Workflow Management       &lt;br /&gt;This is sometimes called “Hosting” and was known under its codename “Dublin”&lt;/li&gt;      &lt;li&gt;Caching       &lt;br /&gt;Distributed caching which was known under its codename “Velocity”&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;&lt;strong&gt;Windows Azure AppFabric&lt;/strong&gt;      &lt;br /&gt;This was known under its previous name as “.NET Services”&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;ServiceBus       &lt;br /&gt;This is used to connect applications through firewalls, proxies and NAT.&lt;/li&gt;      &lt;li&gt;Access Control       &lt;br /&gt;Once you’ve connected your applications, you might want to secure the connection.        &lt;br /&gt;This is also used to map different identity stores so you don’t need federated identities.&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;You can download the &lt;a href="http://bloggingabout.net/media/p/483381.aspx"&gt;slidedeck&lt;/a&gt; and the &lt;a href="http://bloggingabout.net/media/p/483382.aspx"&gt;demos&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;A short review on all 4 products&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;Services and Workflow Manangement&lt;/strong&gt;      &lt;br /&gt;This seems quite cool and quite stable. Surely something you’d want to use asap if you’re running WCF services and/or WF workflows.&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Caching&lt;/strong&gt;      &lt;br /&gt;This one is quite hard to grasp at first, especially the terminology used. It’s also a shame there are no decent tools to work with and monitor stuff. Try to introduce this within your IT department as they need to provide one or more machines as a caching server. I’m going to try though!&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;ServiceBus&lt;/strong&gt;      &lt;br /&gt;Not very difficult to grasp and use, but you sure need to find a good project to be able to introduce this.&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Access Control&lt;/strong&gt;      &lt;br /&gt;One of the hardest parts of the AppFabric, but isn’t security always a ***? But Access Controls probably tops those all as there aren’t any good examples for mapping identities and no tools whatsoever to support it.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/contact.aspx"&gt;Let me know&lt;/a&gt; if you have any experience with these or if you’re planning on using it!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=483383" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/AppFabric/default.aspx">AppFabric</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Azure/default.aspx">Azure</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/SDN/default.aspx">SDN</category></item><item><title>AppFabric : Configuration binding extension could not be found.</title><link>http://bloggingabout.net/blogs/dennis/archive/2010/02/27/appfabric-configuration-binding-extension-could-not-be-found.aspx</link><pubDate>Sat, 27 Feb 2010 20:34:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482885</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=482885</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=482885</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2010/02/27/appfabric-configuration-binding-extension-could-not-be-found.aspx#comments</comments><description>&lt;p&gt;I have recently installed the Windows Azure AppFabric SDK because I&amp;rsquo;m writing an article for the Dutch .NET Magazine. Problem is I try to do everything in Visual Studio 2010 these days, just because it&amp;rsquo;s so cool to have something that&amp;rsquo;s buggy. Seriously! Sometimes you get headaches because you just can&amp;rsquo;t figure out why something&amp;rsquo;s not working, only to find out it&amp;rsquo;s because it really isn&amp;rsquo;t working because of the current beta version you&amp;rsquo;re working with. But on the other side it&amp;rsquo;s really fun and you learn a lot.&lt;/p&gt;
&lt;p&gt;As now, when I got the following message.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Configuration binding extension &amp;#39;system.serviceModel/bindings/netTcpRelayBinding&amp;#39; could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It&amp;rsquo;s a System.ConfigurationErrorsException which can mean that you might be right with what you configured, the .NET runtime just can&amp;rsquo;t figure out what it is that is wrong. This time it&amp;rsquo;s because some extensions to WCF weren&amp;rsquo;t added to the machine.config of .NET 4.0 RC. It was however added to the machine.config of .NET 2.0 so I took it from there. And for future reference for my dear readers and all others that come in via Google, I&amp;rsquo;m posting the fix here.&lt;/p&gt;
&lt;p&gt;Sidenote : I&amp;rsquo;m using 2.0.50727 and 4.0.30128 version of the .NET Framework, but the versions might differ on your machine.&lt;/p&gt;
&lt;p&gt;Go to C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\ and read the machine.config from there. In the node configuration\system.servicemodel\extensions\ you find two nodes. The first is bindingElementExtensions and the second is bindingExtensions. You&amp;rsquo;ll see some bindings with a name that contains &amp;ldquo;relay&amp;rdquo; in it. Copy these into notepad or so.&lt;/p&gt;
&lt;p&gt;Now open up C:\Windows\Microsoft.NET\Framework\v4.0.30128\Config\ and edit the machine.config there. Copy the lines from the 2.0 config that are missing in the 4.0 config and your AppFabric service should be able to start.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482885" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Azure/default.aspx">Azure</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+4.0/default.aspx">.NET Framework 4.0</category></item><item><title>"Add service reference" is disabled</title><link>http://bloggingabout.net/blogs/dennis/archive/2008/03/28/quot-add-service-reference-quot-is-disabled.aspx</link><pubDate>Fri, 28 Mar 2008 20:14:23 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:458096</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>15</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=458096</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=458096</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2008/03/28/quot-add-service-reference-quot-is-disabled.aspx#comments</comments><description>&lt;p&gt;In Visual Studio 2008 you can right-click a project and choose for &amp;quot;Add service reference&amp;quot; to create a proxy class for your web service. WCF preferred, of course.&lt;/p&gt; &lt;p&gt;But for some reason, the Visual Studio team disabled it when you&amp;#39;re in debug mode. Something that used to work in Visual Studio 2005, so after starting a host, you could add the reference. In VS2008 this is disabled, or grayed out&amp;#39;.&lt;/p&gt; &lt;p&gt;The solution is to set your host as startup project, press CTRL-F5 so it&amp;#39;ll be started &lt;em&gt;without debugging&lt;/em&gt; and then you&amp;#39;re able to choose to add the service reference.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=458096" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category></item><item><title>Hosting a WCF service in a Windows Service</title><link>http://bloggingabout.net/blogs/dennis/archive/2008/02/28/hosting-a-wcf-service-in-a-windows-service.aspx</link><pubDate>Thu, 28 Feb 2008 08:52:55 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:457968</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>48</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=457968</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=457968</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2008/02/28/hosting-a-wcf-service-in-a-windows-service.aspx#comments</comments><description>&lt;p&gt;In my last post I explained how you could use WCF and MSMQ to respond to messages asynchronously. We&amp;#39;ve setup a class library with our service, a console application for our host and a console application for our client. In this post I&amp;#39;ll explain how we can use the class library again for hosting our WCF service in a Windows Service.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;1: Add the Windows Service&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Add a new Windows Service project. Right-click the solution, choose &amp;quot;Add&amp;quot; -&amp;gt; &amp;quot;New Project...&amp;quot; and select &amp;quot;Windows&amp;quot; from the tree on the left. Then select &amp;quot;Windows Service&amp;quot; from the project templates. Call it &amp;quot;MailServiceHost&amp;quot; for example. It&amp;#39;ll create the project with a file (class) called &amp;#39;Service1.cs&amp;quot;. Rename it to &amp;#39;MailService.cs&amp;#39; using the solution explorer.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;2: Implement OnStart and OnStop methods&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;When you look into your MailService class, you&amp;#39;ll see that it&amp;#39;s derived from ServiceBase and that two methods are already defined. We&amp;#39;ll first implement the OnStart method. Here we&amp;#39;ll do exactly the same as in the console application created in the previous article.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Create the message-queue of it does not exist yet.  &lt;li&gt;Create and open the ServiceHost&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;The only difference now is that it&amp;#39;s a private member variable (defined on class level) because the OnStop method must have access to it as well.&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;ServiceHost&lt;/span&gt; _host = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; OnStart(&lt;span style="color:blue;"&gt;string&lt;/span&gt;[] args)&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt; {&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;string&lt;/span&gt; queueName = &lt;span style="color:#2b91af;"&gt;ConfigurationManager&lt;/span&gt;.AppSettings[&lt;span style="color:#a31515;"&gt;&amp;quot;SendMailQueueName&amp;quot;&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Trace&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;Starting Class-A E-mail Service...&amp;quot;&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;if&lt;/span&gt; (!&lt;span style="color:#2b91af;"&gt;MessageQueue&lt;/span&gt;.Exists(queueName))&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Trace&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;Creating queue : &amp;quot;&lt;/span&gt; + queueName);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;MessageQueue&lt;/span&gt;.Create(queueName, &lt;span style="color:blue;"&gt;true&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt;&amp;nbsp;&amp;nbsp; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&amp;nbsp; _host = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ServiceHost&lt;/span&gt;(&lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;SendMailService&lt;/span&gt;));&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp; 16&lt;/span&gt;&amp;nbsp;&amp;nbsp; _host.Open();&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;&amp;nbsp;&amp;nbsp; 17&lt;/span&gt; }&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Here&amp;#39;s a quick overview&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Line 1 declares the ServiceHost as member variable.  &lt;li&gt;Line 5 retrieves the queue name from your configuration file.  &lt;li&gt;Line 9 &amp;amp; 12 create the queue if it doesn&amp;#39;t exist yet.  &lt;li&gt;Line 15 &amp;amp; 16 instantiate and open the host.  &lt;li&gt;I&amp;#39;ve also added a few trace messages. The easiest way to see these is to get &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx"&gt;DebugView&lt;/a&gt; from &lt;a href="http://technet.microsoft.com/en-us/sysinternals/default.aspx"&gt;SysInternals&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Now we have to implement the OnStop method.&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; OnStop()&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Trace&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;Shutting down Class-A E-mail Service...&amp;quot;&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;if&lt;/span&gt; (_host != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; {&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _host.Close();&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _host = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Note that the above code does not do any error handling or check if the ServiceHost its state is actually open, etc, etc.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;3: Configuration&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Now we have to add configuration. Add a new Application Configuration file and just copy &amp;amp; paste the entire configuration file from our previous Console Application host project.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;4: ProjectInstaller&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;We&amp;#39;ve created our service, but aren&amp;#39;t done yet. For Windows Services it&amp;#39;s best if you add a ProjectInstaller so the service can easily be installed. Choose to add a new item to the project and select the &amp;quot;General&amp;quot; category and then the &amp;quot;Installer Class&amp;quot; template.&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;[&lt;span style="color:#2b91af;"&gt;RunInstaller&lt;/span&gt;(&lt;span style="color:blue;"&gt;true&lt;/span&gt;)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;partial&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ProjectInstaller&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;Installer&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; ProjectInstaller()&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; {&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;ServiceProcessInstaller&lt;/span&gt; processInstaller= &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ServiceProcessInstaller&lt;/span&gt;();&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;ServiceInstaller&lt;/span&gt; serviceInstaller = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ServiceInstaller&lt;/span&gt;();&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; processInstaller.Account = &lt;span style="color:#2b91af;"&gt;ServiceAccount&lt;/span&gt;.LocalSystem;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serviceInstaller.StartType = &lt;span style="color:#2b91af;"&gt;ServiceStartMode&lt;/span&gt;.Automatic;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serviceInstaller.ServiceName = &lt;span style="color:#a31515;"&gt;&amp;quot;Class-A E-Mail MSMQ Service&amp;quot;&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Installers.Add(serviceInstaller);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Installers.Add(processInstaller);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;In the above code we&amp;#39;ve added a &lt;a href="http://msdn2.microsoft.com/en-us/library/system.serviceprocess.serviceprocessinstaller.aspx"&gt;ServiceProcessInstaller&lt;/a&gt; and a &lt;a href="http://msdn2.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.aspx"&gt;ServiceInstaller&lt;/a&gt;. The ServiceProcessInstaller is used by InstallUtil.exe and we&amp;#39;re using it to specify that we want to use the Local System account to run our service. If you specify ServiceAccount.User and don&amp;#39;t provide a username and password, it&amp;#39;ll request these during installation of the service. With the ServiceInstaller we&amp;#39;re specifying that our service has to start automatically on Windows startup and the name of our service.&lt;/p&gt; &lt;p&gt;That&amp;#39;s it, our WCF service is now running inside a Windows (Managed) Service.&lt;/p&gt; &lt;p&gt;Download &lt;a href="http://bloggingabout.net/files/folders/demosolutions/entry457965.aspx"&gt;the solution&lt;/a&gt; for a complete view on what we&amp;#39;ve done.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=457968" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+3.0/default.aspx">.NET Framework 3.0</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category></item><item><title>WCF and MSMQ</title><link>http://bloggingabout.net/blogs/dennis/archive/2008/02/28/wcf-and-msmq.aspx</link><pubDate>Thu, 28 Feb 2008 08:52:33 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:457966</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>24</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=457966</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=457966</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2008/02/28/wcf-and-msmq.aspx#comments</comments><description>&lt;p&gt;It&amp;#39;s been a while since I blogged about one of my favorite topics, Windows Communication Foundation.&lt;/p&gt; &lt;p&gt;In this article I&amp;#39;ll explain how you can use MSMQ with WCF to really process messages asynchronously. It&amp;#39;s unbelievable how easy this is. Read my complete &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/10/18/WCF-Part-0-_3A00_-Introduction.aspx"&gt;WCF series&lt;/a&gt; on how to set up your first service. The idea in this example is that we have to send some e-mails, but we don&amp;#39;t want that to be done immediately.&lt;/p&gt; &lt;p&gt;We&amp;#39;ll setup the service with a Console Application. In another post we&amp;#39;ll host our service using a Windows Service.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;1: Make sure MSMQ is installed.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/WindowsLiveWriter/WCFandMSMQ_BAEC/WindowsComponentsVista_2.png"&gt;&lt;img height="165" alt="WindowsComponentsVista" src="http://bloggingabout.net/blogs/dennis/WindowsLiveWriter/WCFandMSMQ_BAEC/WindowsComponentsVista_thumb.png" width="189" align="right" border="0" /&gt;&lt;/a&gt; MSMQ must of course be installed. Check your Windows components to see if it&amp;#39;s installed. In Vista this is under &amp;quot;Control Panel&amp;quot; -&amp;gt; &amp;quot;Programs and Features&amp;quot; -&amp;gt; &amp;quot;Turn Windows features on or off&amp;quot;.&lt;/p&gt; &lt;p&gt;On the right you can see I&amp;#39;ve turned on everything. If it&amp;#39;s already installed you should be able to take a look at the queues. Right-click on the &amp;quot;Computer&amp;quot; icon and choose &amp;quot;Manage&amp;quot;. It&amp;#39;s under &amp;quot;Services and Applications&amp;quot;.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;2: Setup a class library.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Create a new project and make it a class library. Add a really simple interface. Again, if you want to know the how and why, read my complete WCF series.&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;[&lt;span style="color:#2b91af;"&gt;ServiceContract&lt;/span&gt;(Namespace=&lt;span style="color:#a31515;"&gt;&amp;quot;http://schemas.class-a.nl/msmq/example01/2008/02/&amp;quot;&lt;/span&gt;, SessionMode=&lt;span style="color:#2b91af;"&gt;SessionMode&lt;/span&gt;.NotAllowed)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;interface&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ISendMail&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; [&lt;span style="color:#2b91af;"&gt;OperationContract&lt;/span&gt;(Name = &lt;span style="color:#a31515;"&gt;&amp;quot;SubmitMessage&amp;quot;&lt;/span&gt;, IsOneWay = &lt;span style="color:blue;"&gt;true&lt;/span&gt;)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;void&lt;/span&gt; SubmitMessage(&lt;span style="color:#2b91af;"&gt;MailMessage&lt;/span&gt; message);&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Now we need an implementation for our service. In the code below I only output the message to the console. Normally you&amp;#39;d use tracing or logging for this, but in a bit we&amp;#39;ll build a console application to host everything.&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;SendMailService&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;ISendMail&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; SubmitMessage(&lt;span style="color:#2b91af;"&gt;MailMessage&lt;/span&gt; message)&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; {&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;To&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &amp;quot;&lt;/span&gt; + message.ToAddress);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;From&amp;nbsp;&amp;nbsp;&amp;nbsp; : &amp;quot;&lt;/span&gt; + message.FromAddress);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;Subject : &amp;quot;&lt;/span&gt; + message.Subject);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;Body&amp;nbsp;&amp;nbsp;&amp;nbsp; : &amp;quot;&lt;/span&gt; + message.Body);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;As you can see I&amp;#39;m transferring a MailMessage. Here&amp;#39;s the datacontract for it.&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;[&lt;span style="color:#2b91af;"&gt;DataContract&lt;/span&gt;(Name=&lt;span style="color:#a31515;"&gt;&amp;quot;MailMessage&amp;quot;&lt;/span&gt;, Namespace=&lt;span style="color:#a31515;"&gt;&amp;quot;http://schemas.class-a.nl/msmq/example01/2008/02/&amp;quot;&lt;/span&gt;)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MailMessage&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; [&lt;span style="color:#2b91af;"&gt;DataMember&lt;/span&gt;(Name=&lt;span style="color:#a31515;"&gt;&amp;quot;ToAddress&amp;quot;&lt;/span&gt;, IsRequired=&lt;span style="color:blue;"&gt;true&lt;/span&gt;, Order=1)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ToAddress { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; [&lt;span style="color:#2b91af;"&gt;DataMember&lt;/span&gt;(Name = &lt;span style="color:#a31515;"&gt;&amp;quot;FromAddress&amp;quot;&lt;/span&gt;, IsRequired = &lt;span style="color:blue;"&gt;true&lt;/span&gt;, Order = 2)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; FromAddress { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; [&lt;span style="color:#2b91af;"&gt;DataMember&lt;/span&gt;(Name = &lt;span style="color:#a31515;"&gt;&amp;quot;CCAddress&amp;quot;&lt;/span&gt;, IsRequired = &lt;span style="color:blue;"&gt;false&lt;/span&gt;, Order = 3)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; CCAddress { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; [&lt;span style="color:#2b91af;"&gt;DataMember&lt;/span&gt;(Name = &lt;span style="color:#a31515;"&gt;&amp;quot;BCCAddress&amp;quot;&lt;/span&gt;, IsRequired = &lt;span style="color:blue;"&gt;false&lt;/span&gt;, Order = 4)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; BCCAddress { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; [&lt;span style="color:#2b91af;"&gt;DataMember&lt;/span&gt;(Name = &lt;span style="color:#a31515;"&gt;&amp;quot;Subject&amp;quot;&lt;/span&gt;, IsRequired = &lt;span style="color:blue;"&gt;true&lt;/span&gt;, Order = 5)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; Subject { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; [&lt;span style="color:#2b91af;"&gt;DataMember&lt;/span&gt;(Name = &lt;span style="color:#a31515;"&gt;&amp;quot;Body&amp;quot;&lt;/span&gt;, IsRequired = &lt;span style="color:blue;"&gt;true&lt;/span&gt;, Order = 6)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; Body { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;That&amp;#39;s our service, let&amp;#39;s get to hosting&lt;/p&gt; &lt;p&gt;&lt;strong&gt;3: Create a host&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;In a next post I will explain hosting this WCF service in a Windows Service. For now, a Console Application will do. It&amp;#39;s also much simpler to debug and test our application that way. Add a new Console Application to your solution.&lt;/p&gt; &lt;p&gt;First thing we need to do, is make sure we have a queue. First create a reference to the System.Messaging assembly. Then past the following code in your Main() method.&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; queueName = &lt;span style="color:#2b91af;"&gt;ConfigurationManager&lt;/span&gt;.AppSettings[&lt;span style="color:#a31515;"&gt;&amp;quot;SendMailQueueName&amp;quot;&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;if&lt;/span&gt; (!&lt;span style="color:#2b91af;"&gt;MessageQueue&lt;/span&gt;.Exists(queueName))&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;MessageQueue&lt;/span&gt;.Create(queueName, &lt;span style="color:blue;"&gt;true&lt;/span&gt;);&lt;/p&gt;&lt;/div&gt; &lt;p&gt;As you can see, we&amp;#39;re getting the SendMailQueueName from the configuration and if it doesn&amp;#39;t exist yet, we&amp;#39;ll create it. For the configuration, just download the complete solution.&lt;/p&gt; &lt;p&gt;Now just create a ServiceHost and open it.&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt; serviceType = &lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;SendMailService&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;ServiceHost&lt;/span&gt; host = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ServiceHost&lt;/span&gt;(serviceType))&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; host.Open();&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Beside the fact we&amp;#39;ve checked for existence of the queue using System.Messaging, we did nothing so far concerning MSMQ. The only thing noticeable is setting the operation as a OneWay operation.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;4: Setting up the host configuration&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Let&amp;#39;s have a look at the services configuration. We&amp;#39;ve configured a single service, based on the SendMailService. It as two endpoints, but one&amp;#39;s for exchanging metadata (MEX endpoint). As you can see from the binding and the address of the other endpoint, this is the first time we&amp;#39;re specifying that we want to use MSMQ. We&amp;#39;re using the NetMsmqBinding and a private queue for our service.&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;services&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;service&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;MetadataBehavior&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;EmailService.SendMailService&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;endpoint&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;address&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;net.msmq://localhost/private/ClassA_SendMail&lt;/span&gt;&amp;quot;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;binding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;netMsmqBinding&lt;/span&gt;&amp;quot;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;contract&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;EmailService.ISendMail&lt;/span&gt;&amp;quot;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;SendMailNetMsmqBinding&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;endpoint&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;address&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;mex&lt;/span&gt;&amp;quot;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;binding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;mexHttpBinding&lt;/span&gt;&amp;quot;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;contract&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;IMetadataExchange&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;host&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;baseAddresses&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;add&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;baseAddress&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;http://localhost:8080/SendMail/&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;baseAddresses&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;host&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;service&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;services&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Pay attention to the &amp;#39;behaviorConfiguration&amp;#39; attribute on the service and my &amp;#39;SendMailNetMsmqBinding binding configuration&amp;#39;. The behavior configuration isn&amp;#39;t interesting, it&amp;#39;s just enabling the MEX endpoint to work. The binding configuration for the endpoint is slightly interesting. As you can see below I&amp;#39;ve set the security to &amp;#39;None&amp;#39;. That&amp;#39;s because my laptop isn&amp;#39;t attached to a domain. By default it&amp;#39;s on transport security, meaning it&amp;#39;ll use Active Directory integration, which won&amp;#39;t allow me to connect in my situation. You&amp;#39;ll get a nice :&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Binding validation failed because the binding&amp;#39;s MsmqAuthenticationMode property is set to WindowsDomain but MSMQ is installed with Active Directory integration disabled. The channel factory or service host cannot be opened.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;The deadLetterQueue attribute is Windows version specific, because I can only set it to custom on Vista and Windows Server 2008. No need for a custom created queue here, it&amp;#39;ll just group the messages in the dead-letter queue, so you&amp;#39;ll know they&amp;#39;re yours. Read &lt;a href="http://msdn2.microsoft.com/en-us/library/ms789035.aspx"&gt;this article on MSDN&lt;/a&gt; for more info.&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;bindings&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;netMsmqBinding&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;binding&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;SendMailNetMsmqBinding&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;deadLetterQueue&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Custom&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;security&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;None&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;binding&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;netMsmqBinding&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;bindings&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;&lt;strong&gt;5: Creating a client&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Normally our client is calling the service directly. We can&amp;#39;t do that, but we can get the metadata from our service, because we&amp;#39;ve set up a MEX endpoint. Add a new console application to your solution and create a service reference to the service. You can add a service reference by starting your service WITHOUT debugging. This way the option isn&amp;#39;t disabled in your console client.&lt;/p&gt; &lt;p&gt;Now open the proxy code and insert a message!&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;overflow:auto;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Main(&lt;span style="color:blue;"&gt;string&lt;/span&gt;[] args)&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;SendMailClient&lt;/span&gt; svc = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;SendMailClient&lt;/span&gt;();&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;MailMessage&lt;/span&gt; msg = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MailMessage&lt;/span&gt;();&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; msg.ToAddress = &lt;span style="color:#a31515;"&gt;&amp;quot;dennis@nospam.class-a.nl&amp;quot;&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; msg.FromAddress = &lt;span style="color:#a31515;"&gt;&amp;quot;dvdstelt@nospam.gmail.com&amp;quot;&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; msg.Subject = &lt;span style="color:#a31515;"&gt;&amp;quot;Test mail&amp;quot;&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; msg.Body = &lt;span style="color:#a31515;"&gt;&amp;quot;Wow, is this going to work?&amp;quot;&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; svc.SubmitMessage(msg);&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Isn&amp;#39;t that extremely simple?! The only difference is in the configuration. This proves a lot of what&amp;#39;s WCF is in the configuration.&lt;/p&gt; &lt;p&gt;Test MSMQ by stopping the service and just running the client. You can see the message in MSMQ. Start your host and it should disappear almost immediately.&lt;/p&gt; &lt;p&gt;Download &lt;a href="http://bloggingabout.net/files/folders/demosolutions/entry457965.aspx"&gt;the solution&lt;/a&gt; for a complete view on what we&amp;#39;ve done.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=457966" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+3.0/default.aspx">.NET Framework 3.0</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category></item><item><title>Mobile development</title><link>http://bloggingabout.net/blogs/dennis/archive/2007/10/24/mobile-development.aspx</link><pubDate>Wed, 24 Oct 2007 10:13:20 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:407888</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=407888</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=407888</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2007/10/24/mobile-development.aspx#comments</comments><description>&lt;p&gt;Two weeks ago Mike Schroepfer, a Mozilla developer, &lt;a href="http://weblogs.mozillazine.org/schrep/archives/2007/10/mozilla_and_mobile.html"&gt;announced&lt;/a&gt; that they&amp;#39;ll launch a version of Firefox that can be run mobile devices. If you own a Windows Mobile device, you&amp;#39;re probably craving for a better browsing experience, just like I am. I&amp;#39;ve seen Deepfish, a new browser by Microsoft, but it&amp;#39;s in early betas.&lt;/p&gt; &lt;p&gt;The interesting part however is that, according to Mike Schroepfer, mobile devices currently outsell computers 20 to 1. I remember Microsoft saying in some article or at some conference that by 2010 a total of 1 billion people will be accessing the internet using mobile devices. These numbers hopefully make you consider if the mobile market is worth investing in, especially being a developer.&lt;/p&gt; &lt;p&gt;At Class-A we&amp;#39;re busy with our own &lt;a href="http://www.class-a.nl/index.aspx?id=12&amp;amp;catID=12&amp;amp;sid=20"&gt;mobile development training&lt;/a&gt;. We&amp;#39;re not using standard Microsoft (MOC) material, but creating our own, so we can incorporate best practices and use .NET Compact Framework 3.5, which Microsoft probably won&amp;#39;t have material for, for a long time. This features LINQ and WCF which are great enhancements. I&amp;#39;ve just blogged about the .NETCF 2.0 application I&amp;#39;ve been building, and the next step is to build it again in .NETCF 3.5.&lt;/p&gt; &lt;p&gt;If you experience the Compact Framework for the first time, it might be a though start. But once you get it, it&amp;#39;s a really fun experience building on an entirely different platform. It&amp;#39;s not the C# that&amp;#39;s difficult, it&amp;#39;s the new challenges like the user interface, different screen resolutions, connections and synchronizing data between your device and the server, performance considerations that are completely different from the full .NET Framework, etc. But when you put some time in it, it&amp;#39;s really rewarding to see your application running on a mobile device and having other people enthusiastic about it.&lt;/p&gt; &lt;p&gt;Although LINQ is the &amp;#39;expected&amp;#39; next evolution in programming, I think people can&amp;#39;t even start to wonder what will happen in the mobile world. How it will advance on both hardware and software. Will we keep small screens or walk around with large &lt;a href="http://en.wikipedia.org/wiki/Ultra-Mobile_PC"&gt;origami&lt;/a&gt; like pc&amp;#39;s? What will be possible on your mobile, especially with Silverlight mobile on the way.&lt;/p&gt; &lt;p&gt;The mobile platform is sure something that has my attention and I hope more people will join me. Together we can create a great future.&lt;br /&gt;&lt;font color="#808080"&gt;Wow, does that sound like a dull marketing line! ;-)&lt;/font&gt;&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:d5edcc14-2d20-4887-8bb0-3d6edd0ff38e" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Windows%20Mobile" rel="tag"&gt;Windows Mobile&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Compact%20Framework" rel="tag"&gt;Compact Framework&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=407888" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Development/default.aspx">Development</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Compact+Framework+3.5/default.aspx">.NET Compact Framework 3.5</category></item><item><title>Class-A Summer Classes become Winter Classes</title><link>http://bloggingabout.net/blogs/dennis/archive/2007/10/04/class-a-summer-classes-become-winter-classes.aspx</link><pubDate>Thu, 04 Oct 2007 07:08:16 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:384974</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=384974</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=384974</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2007/10/04/class-a-summer-classes-become-winter-classes.aspx#comments</comments><description>&lt;p&gt;As I really enjoyed giving the &lt;a href="http://www.class-a.nl/index.aspx?id=82"&gt;Summer Classes&lt;/a&gt; a few weeks ago, the first ever real .NET 3.5 class world wide, I&amp;#39;m really pleased to announce the Winter Classes. Although the date hasn&amp;#39;t even been set, we&amp;#39;re planning it around the end of January or start of February. The classes will be the same as last time&lt;/p&gt; &lt;ul&gt; &lt;li&gt;.NET 3.5 Summer Class&lt;/li&gt; &lt;li&gt;Business Intelligence Summer Class&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The location to be will again be the &lt;a href="http://www.badhotel.com/nl/home.htm"&gt;Badhotel Domburg&lt;/a&gt;. We really enjoyed it there last time with great facilities and a great bar to hang out and reflect on the things learned that day.&lt;/p&gt; &lt;p&gt;We&amp;#39;ll redo the subjects from the last time, but update everything for the then expected to be released .NET Framework 3.5, with perhaps some new stuff that&amp;#39;ll be released by then. Subjects we covered in our .NET 3.5 class last time are:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Language enhancements in C# 3.0 and VB 9.0&lt;/li&gt; &lt;li&gt;Visual Studio 2008 enhancements&lt;/li&gt; &lt;li&gt;ASP.NET AJAX extensions&lt;/li&gt; &lt;li&gt;LINQ and LINQ to XML&lt;/li&gt; &lt;li&gt;LINQ to SQL&lt;/li&gt; &lt;li&gt;Where does LINQ (and LINQ to SQL) fit in my architecture?&lt;/li&gt; &lt;li&gt;WCF and WF integration&lt;/li&gt; &lt;li&gt;Programming the web with WCF v2&lt;/li&gt; &lt;li&gt;.NET Compact Framework 3.5&lt;/li&gt; &lt;li&gt;Silverlight&lt;/li&gt; &lt;li&gt;Entity Framework&lt;/li&gt; &lt;li&gt;What else is new in .NET 3.5 (for everything we didn&amp;#39;t cover yet)&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;This means a complete coverage of &lt;u&gt;everything new in .NET Framework 3.5&lt;/u&gt;. So when you&amp;#39;ve visited our class, you&amp;#39;ll know everything there is to know in a weeks time! And of course with the Class-A labs that make you think about the solution, instead of bothering you with setting colors on buttons and div&amp;#39;s! ;-)&lt;/p&gt; &lt;p&gt;We&amp;#39;ll also have enough discussion about everything new and you can ask questions just about anything. We&amp;#39;ll also prepare a few games so we can have some fun if you enjoy this!&lt;/p&gt; &lt;p&gt;For the Business Intelligence class and more info about the .NET 3.5 class you can &lt;a href="http://www.class-a.nl/index.aspx?id=12&amp;amp;catID=16&amp;amp;sid=22"&gt;visit the Class-A website&lt;/a&gt;. It&amp;#39;s currently not updated yet for the Winter Class, but it soon will be.&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:25a8750c-0a70-43c6-a551-6d8fe8a0d89e" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/WCF" rel="tag"&gt;WCF&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Silverlight" rel="tag"&gt;Silverlight&lt;/a&gt;, &lt;a href="http://technorati.com/tags/.NET%20Framework%203.5" rel="tag"&gt;.NET Framework 3.5&lt;/a&gt;, &lt;a href="http://technorati.com/tags/.NET%20Compact%20Framework%203.5" rel="tag"&gt;.NET Compact Framework 3.5&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Mobile%20Development" rel="tag"&gt;Mobile Development&lt;/a&gt;, &lt;a href="http://technorati.com/tags/LINQ" rel="tag"&gt;LINQ&lt;/a&gt;, &lt;a href="http://technorati.com/tags/LINQ%20to%20SQL" rel="tag"&gt;LINQ to SQL&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=384974" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Personal/default.aspx">Personal</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Compact+Framework+3.5/default.aspx">.NET Compact Framework 3.5</category></item><item><title>WCF serving AJAX troubleshooting</title><link>http://bloggingabout.net/blogs/dennis/archive/2007/08/14/wcf-serving-ajax-troubleshooting.aspx</link><pubDate>Tue, 14 Aug 2007 13:15:51 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:340334</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=340334</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=340334</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2007/08/14/wcf-serving-ajax-troubleshooting.aspx#comments</comments><description>&lt;p&gt;I hope in the RTM you&amp;#39;ll get more help solving your WCF Ajax problems then I currently get, because I&amp;#39;m getting mad from time to time. In my quest for getting things to work, I learned some stuff I wanted to share. Read: have a checklist for myself because I tend to forget this kind of stuff! ;-)&lt;/p&gt; &lt;ol&gt; &lt;li&gt;First, have a look at the errors your service reports. Right-click your service&amp;#39;s .svc file in Visual Studio 2008 and choose &amp;quot;View in browser&amp;quot;. &lt;br /&gt; &lt;li&gt;If you&amp;#39;re using the WebScriptServiceHostFactory in your .svc file you don&amp;#39;t need anything in your web.config and you can remove the entire &amp;lt;System.ServiceModel&amp;gt; part. This is how the .svc then should look like:  &lt;p class="MsoNormal" style="margin-bottom:0pt;line-height:normal;mso-layout-grid-align:none;"&gt;&lt;span style="font-size:10pt;background:yellow;font-family:&amp;#39;Lucida Console&amp;#39;;mso-bidi-font-family:&amp;#39;Courier New&amp;#39;;mso-highlight:yellow;mso-no-proof:yes;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Lucida Console&amp;#39;;mso-bidi-font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;@&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Lucida Console&amp;#39;;mso-bidi-font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt; &lt;span style="color:#a31515;"&gt;ServiceHost&lt;/span&gt; &lt;span style="color:red;"&gt;Language&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Debug&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Service&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;WebApplication1.WCFAjaxService&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;CodeBehind&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Service.svc.cs&amp;quot; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;color:red;font-family:&amp;#39;Lucida Console&amp;#39;;mso-bidi-font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;Factory&lt;/span&gt;&lt;span style="font-size:10pt;color:blue;font-family:&amp;#39;Lucida Console&amp;#39;;mso-bidi-font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;"&gt;=&amp;quot;System.ServiceModel.Activation.WebScriptServiceHostFactory&amp;quot;&lt;/span&gt;&lt;span style="font-size:10pt;background:yellow;font-family:&amp;#39;Lucida Console&amp;#39;;mso-bidi-font-family:&amp;#39;Courier New&amp;#39;;mso-highlight:yellow;mso-no-proof:yes;"&gt;%&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;li&gt;The default namespace of your service is &lt;a href="http://tempuri.org"&gt;http://tempuri.org&lt;/a&gt;. You need this in your javascript creating your proxy.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:10pt;color:blue;line-height:115%;font-family:&amp;#39;Lucida Console&amp;#39;;mso-bidi-font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;mso-fareast-font-family:calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language:en-us;mso-fareast-language:en-us;mso-bidi-language:ar-sa;"&gt;var&lt;/span&gt;&lt;span style="font-size:10pt;line-height:115%;font-family:&amp;#39;Lucida Console&amp;#39;;mso-bidi-font-family:&amp;#39;Courier New&amp;#39;;mso-no-proof:yes;mso-fareast-font-family:calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language:en-us;mso-fareast-language:en-us;mso-bidi-language:ar-sa;"&gt; proxy = &lt;span style="color:blue;"&gt;new&lt;/span&gt; tempuri.org.IWCFAjaxService();&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;When Internet Explorer tells you the object tempuri isn&amp;#39;t know, you can take a look at the generated javascript to see what the correct objectname is. By placing /js behind your service you can download the javascript.&lt;br /&gt;&lt;br /&gt;Example : http://localhost/service.svc/js&lt;br /&gt; &lt;li&gt;The service can&amp;#39;t handle multiple authentication schemes; meaning you can only have anonymous access or integrated security or another option. In IIS Management right-click your website (or virtual directory) and select the &amp;quot;Directory Security&amp;quot; tab, press the first &amp;quot;Edit&amp;quot; button for Authentication and access control and select only one checkbox.&lt;br /&gt;After this you&amp;#39;ll have to stop and start the website which can be done by using IISRESET in the command prompt.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;When I come across more I will post them here, including an update comment.&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:add1a68b-01b4-433d-98e8-7a7c5dfebfbe" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/WCF" rel="tag"&gt;WCF&lt;/a&gt;, &lt;a href="http://technorati.com/tags/.NET%203.5" rel="tag"&gt;.NET 3.5&lt;/a&gt;, &lt;a href="http://technorati.com/tags/ASP.NET" rel="tag"&gt;ASP.NET&lt;/a&gt;, &lt;a href="http://technorati.com/tags/ASP.NET%20AJAX" rel="tag"&gt;ASP.NET AJAX&lt;/a&gt;, &lt;a href="http://technorati.com/tags/AJAX" rel="tag"&gt;AJAX&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=340334" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category></item><item><title>Just to late: WF &amp; WCF beta 2 samples</title><link>http://bloggingabout.net/blogs/dennis/archive/2007/08/11/just-to-late-wf-amp-wcf-beta-2-samples.aspx</link><pubDate>Sat, 11 Aug 2007 17:16:04 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:337811</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=337811</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=337811</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2007/08/11/just-to-late-wf-amp-wcf-beta-2-samples.aspx#comments</comments><description>&lt;p&gt;Arrgh, these come out just a day or two too late. But that&amp;#39;s life when you&amp;#39;re always one step ahead. ;)&lt;/p&gt; &lt;p&gt;WF &amp;amp; WCF samples&lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=2611a6ff-fd2d-4f5b-a672-c002f1c09ccd&amp;amp;displaylang=en&amp;amp;tm"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=2611a6ff-fd2d-4f5b-a672-c002f1c09ccd&amp;amp;displaylang=en&amp;amp;tm&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Silverlight tools for beta 2&lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=b52aeb39-1f10-49a6-85fc-a0a19cac99af&amp;amp;displaylang=en&amp;amp;tm"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=b52aeb39-1f10-49a6-85fc-a0a19cac99af&amp;amp;displaylang=en&amp;amp;tm&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Microsoft® Visual Studio 2005 Team Edition for Database Professionals Power Tools&lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=da3f11ad-bd54-4eda-b08c-4df84df0d641&amp;amp;displaylang=en&amp;amp;tm"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=da3f11ad-bd54-4eda-b08c-4df84df0d641&amp;amp;displaylang=en&amp;amp;tm&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=337811" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category></item><item><title>Summer Class .NET 3.5, preparation</title><link>http://bloggingabout.net/blogs/dennis/archive/2007/08/07/summer-class-net-3-5-preparation.aspx</link><pubDate>Tue, 07 Aug 2007 21:58:31 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:335103</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=335103</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=335103</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2007/08/07/summer-class-net-3-5-preparation.aspx#comments</comments><description>&lt;p&gt;As &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2007/08/03/cannot-drop-database-because-of-replication.aspx"&gt;said&lt;/a&gt; &lt;a href="http://bloggingabout.net/blogs/dennis/archive/2007/06/08/summer-classes-2007.aspx"&gt;before&lt;/a&gt;, we&amp;#39;re currently on location at the &amp;quot;middle of nowhere&amp;quot;, creating material for the upcoming &lt;a href="http://www.class-a.nl/index.aspx?id=12&amp;amp;catID=16&amp;amp;sid=22"&gt;.NET 3.5 Summer Class&lt;/a&gt;. We&amp;#39;re having a blast, creating slides and hands on labs until way past midnight. I&amp;#39;m busy with the WCF Web stuff, Alex is creating Linq to SQL/XML stuff and Pascal is currently doing Silver (WCF/WF). Yesterday Mike came by to have some fun with us.&lt;/p&gt; &lt;p&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/WindowsLiveWriter/SummerClass.NET3.5preparation_15115/Hutje%20op%20de%20hei%202007%20004%20(Small).jpg"&gt;&lt;img height="225" alt="Hutje op de hei 2007 004 (Small)" src="http://bloggingabout.net/blogs/dennis/WindowsLiveWriter/SummerClass.NET3.5preparation_15115/Hutje%20op%20de%20hei%202007%20004%20(Small)_thumb.jpg" width="300" border="0" /&gt;&lt;/a&gt; &lt;a href="http://bloggingabout.net/blogs/dennis/WindowsLiveWriter/SummerClass.NET3.5preparation_15115/Hutje%20op%20de%20hei%202007%20012%20(Small).jpg"&gt;&lt;img height="225" alt="Hutje op de hei 2007 012 (Small)" src="http://bloggingabout.net/blogs/dennis/WindowsLiveWriter/SummerClass.NET3.5preparation_15115/Hutje%20op%20de%20hei%202007%20012%20(Small)_thumb.jpg" width="300" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Click the images for larger views.&lt;/p&gt; &lt;p&gt;Picture on the left, from left to right are Mike, Alex and Pascal. Second picture is me, Alex and Pascal.&lt;/p&gt; &lt;p&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:579b6c15-2d3c-42a6-adbb-febb45ab5268" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/WCF" rel="tag"&gt;WCF&lt;/a&gt;, &lt;a href="http://technorati.com/tags/WF" rel="tag"&gt;WF&lt;/a&gt;, &lt;a href="http://technorati.com/tags/.NET%203.5" rel="tag"&gt;.NET 3.5&lt;/a&gt;, &lt;a href="http://technorati.com/tags/SilverLight" rel="tag"&gt;SilverLight&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Linq" rel="tag"&gt;Linq&lt;/a&gt;&lt;/div&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=335103" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category></item><item><title>WCF Test Client</title><link>http://bloggingabout.net/blogs/dennis/archive/2007/08/07/wcf-test-client.aspx</link><pubDate>Tue, 07 Aug 2007 12:48:51 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:334794</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>13</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/rsscomments.aspx?PostID=334794</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/dennis/commentapi.aspx?PostID=334794</wfw:comment><comments>http://bloggingabout.net/blogs/dennis/archive/2007/08/07/wcf-test-client.aspx#comments</comments><description>&lt;p&gt;Two things that should&amp;#39;ve been there since WCF v1. My colleague Alex Thissen already blogged about the WCF Library projects and the &lt;a href="http://www.alexthissen.nl/blogs/main/archive/2007/03/04/wcf-library-projects.aspx"&gt;service host&lt;/a&gt; that comes with it. In beta 2 there&amp;#39;s a new &lt;strong&gt;test client&lt;/strong&gt; that&amp;#39;ll connect to your service and will show you the available operations, configuration and allows you to invoke the operations.&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/WindowsLiveWriter/WCFTestClient_C9B9/WCFTestClient_1.png"&gt;&lt;img height="153" alt="WCFTestClient" src="http://bloggingabout.net/blogs/dennis/WindowsLiveWriter/WCFTestClient_C9B9/WCFTestClient_thumb_1.png" width="497" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;When you take a look at the properties of your service library, you&amp;#39;ll notice that under the &amp;quot;Debug&amp;quot; tab page, a command line argument has been added: /client:&amp;quot;WcfTestClient.exe&amp;quot;. This allows it to start and connect to your service.&lt;/p&gt; &lt;p&gt;After a default installation, this client will crash upon connecting to your service. That&amp;#39;s because svcutil.exe isn&amp;#39;t signed in Beta 2, as you can &lt;a href="http://www.lhotka.net/weblog/VisualStudio2008Beta2AndNETFX35Beta2AreAvailableNow.aspx"&gt;read&lt;/a&gt; here and &lt;a href="http://blogs.thinktecture.com/cweyer/archive/2007/07/27/414897.aspx"&gt;here&lt;/a&gt;. Unfortunately both bloggers don&amp;#39;t tell you where you can find svcutil. You can find it right here:&lt;/p&gt; &lt;p&gt;C:\Program Files\Microsoft SDKs\Windows\v6.0a\bin\&lt;/p&gt; &lt;p&gt;Open the Visual Studio 2008 command prompt, browse to that folder and delay sign it by executing the following command:&lt;/p&gt; &lt;p&gt;sn.exe -Vr svcutil.exe&lt;/p&gt; &lt;p&gt;Now both Service Util and the WCF Test Client work.&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:17e5286c-db8d-44ca-9acd-b5034f558337" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/WCF" rel="tag"&gt;WCF&lt;/a&gt;, &lt;a href="http://technorati.com/tags/.NET%203.5" rel="tag"&gt;.NET 3.5&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Visual%20Studio%202008" rel="tag"&gt;Visual Studio 2008&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=334794" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/.NET+Framework+3.5/default.aspx">.NET Framework 3.5</category></item></channel></rss>