<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.wintellect.com/CS/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>Justin Smith's Blog</title><link>http://www.wintellect.com/CS/blogs/jsmith/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.2)</generator><item><title>The Learning Channels...</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2007/01/19/the-learning-channels.aspx</link><pubDate>Sat, 20 Jan 2007 04:35:31 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2829</guid><dc:creator>jsmith</dc:creator><slash:comments>3</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2829.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2829</wfw:commentRss><description>&lt;P&gt;The following is a rapid-fire description of channels, where they come from, and a code sample to illustrate:&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;Channels are one of the more complex parts of a WCF application. For those that are new to WCF, a channel is a sink or a source of a message, and they are largely hidden from the purview of the application developer. In fact, it is entirely possible (and common) to write a fully functional WCF application and not know a thing about channels. Even though they are not easily visible at the ServiceModel layer, they are busy behind the scenes sending, receiving, or otherwise mangling messages. &lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;All channels are not created equal. In the WCF type system, there are channels for each supported transport, security functionality, and messaging protocol. Furthermore, a channel has at least one shape. For a description of channel shapes, see &lt;A href="http://kennyw.com/indigo/13"&gt;Kenny Wolf's blog&lt;/A&gt;. Since messaging applications frequently need to send messages securely over a given transport with a given protocol or choreography, channels can be stacked. Each channel in the stack is responsible for a specific set of functionality in the application.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;User code never directly instantiates a channel; that job is reserved for special factory objects in the WCF type system. These factory objects come in two flavors: Channel Listeners and Channel Factories. Channel listeners create receiving channels, and channel factories create sending channels. Channel listeners have the added pleasure of listening for incoming connections (think sockets). A given channel factory or channel listener can create more than one kind of channel, but they are typically grouped based on functionailty. For example, the WCF type system contains a channel listener for TCP/IP traffic, and another one for MSMQ traffic. Since channels reside in a stack, and channel listeners/factories create channels, channel listeners/factories are also stacked at runtime.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;User code never directly instantiates a channel listener or channel factory; that job is reserved for a BindingElement. The WCF API contains several BindingElements, and each one represents some messaging functionality (e.g. transport, messaging protocols, security, transactional support, encoding). All BindingElements have a common base type, and that base type defines methods called BuildChannelFactory and BuildChannelListener. As their name implies, these methods build at least one channel factory or channel listener, respectively.&amp;nbsp;Application code can&amp;nbsp;instantiate and use&amp;nbsp;BindingElement to build a single channel listener or channel factory. It is a one-stop shop for both the sender and the receiver. &lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;In practice, however, BindingElements are most frequently created by a Binding. A Binding’s primary job is to create a collection of BindingElements, and use that collection of BindingElements to build either a stack of channel factories or a stack of channel listeners. All Bindings have a common base type, and that base type defines a method named CreateBindingElements. At runtime, either the sending application or the receiving application calls this method, and then uses the returned BindingElementCollection to create a stack of channel listeners or channel factories.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;Channel listeners, channel factories, and channels all have a common state machine. Since these objects are typically arranged in a stack, the entire stack must transition through the state machine in harmony.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;To summarize:&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI class=MsoNormal style="MARGIN:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;Binding begat a BindingElementCollection&lt;o:p&gt;&lt;/o:p&gt; 
&lt;LI class=MsoNormal style="MARGIN:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;BindingElementCollection begat a stack of channel listeners or channel factories&lt;o:p&gt;&lt;/o:p&gt; 
&lt;LI class=MsoNormal style="MARGIN:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;RECEIVER: stack of channel listeners begat a stack of channels&lt;o:p&gt;&lt;/o:p&gt; 
&lt;LI class=MsoNormal style="MARGIN:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1;tab-stops:list .5in;"&gt;SENDER: stack of channel factories begat a stack of channels&lt;o:p&gt;&lt;/o:p&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Trying to keep this straight can be challenging at first. If you add the state transitions, and the fact that a channel listener or factory stack can create multiple channel stacks, it can be quite confusing at first. In the end, however, this model provides tremendous extensibility and functionality, so I think it is a good one.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;One great way to&amp;nbsp;learn channels and the impact ServiceModel code has on them is to&amp;nbsp;write a custom channel, plug it into a running application, and watch what&amp;nbsp;is going on. The following code sample does just that: &lt;A href="http://www.wintellect.com/cs/DasBlogContentBinary/DelegatorChannelDemo1.zip"&gt;DelegatorChannelDemo1.zip (140.11 KB)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;
&lt;P&gt;The zip file contains two projects: TestApp and DelegatorChannel. DelegatorChannel project contains a channel factory, a channel listener, a BindingElement, and a Binding that will place a custom channel in the channel stack at runtime. These channels simply dump text to the console for all state changes, as well as all method calls. The channel factory and channel listener do the same. The Binding in the DelegatorChannel project inserts a custom BindingElement in the BindingElementCollection for the BasicHttpBinding, NetTcpBinding, WsHttpBinding, and NetMsmqBinding. The TestApp project flexes this binding in several different MEPS (Datagram, Request/Reply, and Duplex).&lt;/P&gt;
&lt;P&gt;BTW - My book should be on the bookshelves by TechEd (yay).&lt;/P&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2829" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>The API that Weebles and Wobbles</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/08/11/the-api-that-weebles-and-wobbles.aspx</link><pubDate>Sat, 12 Aug 2006 00:21:39 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2830</guid><dc:creator>jsmith</dc:creator><slash:comments>0</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2830.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2830</wfw:commentRss><description>&lt;P&gt;It has been a while since I have blogged - my apologies. Life has been hectic.&lt;/P&gt;
&lt;P&gt;One of the "not so fun" parts of writing a book on a beta technology like WCF is the constant movement of the API (not to mention changing the ship vehicle).&lt;/P&gt;
&lt;P&gt;One change in the June CTP (appears to persist in the July CTP as well) that caught my attention is the change to the WS-MEX default behavior. In the old days (a few months ago) you could add an address to ServiceHost's constructor, and a WS-Mex endpoint would automagically&amp;nbsp;appear. No mas. As of the June CTP, WS-Mex is off by default. There is quite a bit of documentation regarding how to enable WS-Mex in config files, but I could find none about how to do it imperatively. I think config files are great, but I like the ability to program too. After some time in the debugger and in reflector, it appears to be possible, but not pretty.&lt;/P&gt;
&lt;P&gt;To configure a ServiceHost to open a WS-Mex endpoint in a simple WCF receiving app, do the following:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;using System;&lt;BR&gt;using System.ServiceModel;&lt;BR&gt;using System.ServiceModel.Channels;&lt;BR&gt;using System.ServiceModel.Description;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;// implement the IHelloWCF interface&lt;BR&gt;sealed class Receiver : IHelloWCF {&lt;BR&gt;&amp;nbsp; static void Main(){&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // define the base address to listen on&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Uri baseAddress = new Uri("&lt;/FONT&gt;&lt;A href="http://localhost:5000/HelloWCF"&gt;&lt;FONT face="Courier New"&gt;http://localhost:5000/HelloWCF&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // create the Binding&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BasicHttpBinding binding = new BasicHttpBinding();&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // new-up a ServiceHost type in a using statement&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using(ServiceHost svc = new ServiceHost(typeof(Receiver), baseAddress)){&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // use the contract, binding, and address to configure main endpoint&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svc.AddServiceEndpoint(typeof(IHelloWCF), binding, String.Empty);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // add the Service Metadata behavior **NEW**&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ServiceMetadataBehavior mexBehavior = new ServiceMetadataBehavior();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svc.Description.Behaviors.Add(mexBehavior);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;add the endpoint for metadata requests&amp;nbsp;**NEW**&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Binding mexBinding = MetadataExchangeBindings.CreateMexHttpBinding();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svc.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, "mex");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;begin listening on all endpoints&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svc.Open();&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("the receiver is ready");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.ReadLine();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; // implement the method defined in the service contract&lt;BR&gt;&amp;nbsp; public void Say(String input){&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("Message received, the body contains: {0}", input);&lt;BR&gt;&amp;nbsp; }&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;// define the service contract&lt;BR&gt;[ServiceContract]&lt;BR&gt;interface IHelloWCF {&lt;BR&gt;&amp;nbsp; [OperationContract]&lt;BR&gt;&amp;nbsp; void Say(String input);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The new stuff has **NEW** in the comments. Basically, you now have to add a Mex endpoint manually. There are a few catches though. First, you have to call the MetadataExchangeBindings.CreateMexHttpBinding method to get the correct mex binding. It is worth noting that this is the only binding that defines factory methods. Also, you have to add the ServiceMetadataBehavior to the description BEFORE you add the mex endpoint.&lt;/P&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2830" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>The New Name Game</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/06/10/the-new-name-game.aspx</link><pubDate>Sat, 10 Jun 2006 23:20:06 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2831</guid><dc:creator>jsmith</dc:creator><slash:comments>0</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2831.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2831</wfw:commentRss><description>&lt;P&gt;What we have come to know and love as WinFx is now called the .NET Framework 3.0 (see &lt;A href="http://www.eweek.com/article2/0,1895,1974865,00.asp"&gt;http://www.eweek.com/article2/0,1895,1974865,00.asp&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;It doesn' t look like this is anything more than a branding stunt, but&amp;nbsp;I now have to go back and change parts of my book :)&lt;/P&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2831" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>Life of a WCF Message webcast source code....</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/06/07/life-of-a-wcf-message-webcast-source-code.aspx</link><pubDate>Wed, 07 Jun 2006 06:14:52 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2833</guid><dc:creator>jsmith</dc:creator><slash:comments>4</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2833.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2833</wfw:commentRss><description>&lt;P&gt;Last week I presented an MSDN webcast titled "&lt;A href="http://msevents.microsoft.com/cui/eventdetail.aspx?eventID=1032299306&amp;amp;Culture=en-US"&gt;The Lifetime of a WCF Message&lt;/A&gt;". As promised, the demo code shown is here: &lt;A href="http://www.wintellect.com/cs/DasBlogContentBinary/LifeOfAMessage.zip"&gt;LifeOfAMessage.zip ( KB)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;A couple of&amp;nbsp;things to remember&amp;nbsp;about the source:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;It was built with the WinFx Feb CTP, but should upgrade to Beta 2 with no problem :) 
&lt;LI&gt;Demos 1 and 2: set WCFReceiver101 and WCFSender101 as the startup projects 
&lt;LI&gt;Demo 3: run the BindingElements project, then the MessageEncodings project 
&lt;LI&gt;Demo 4: Set PerfTestSender and PerfTestReceiver as the startup project&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2833" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>InstanceContextMode and ConcurrencyMode</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/05/16/instancecontextmode-and-concurrencymode.aspx</link><pubDate>Tue, 16 May 2006 04:19:36 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2835</guid><dc:creator>jsmith</dc:creator><slash:comments>4</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2835.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2835</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;WCF is all about sending and receiving messages. There are many settings that have an impact on how a WCF application will scale. The following describes how the settings for instancing modes and concurrency mode impact the scalability of a WCF receiving application, and when they make thread synchronization necessary in your code.&lt;/P&gt;
&lt;H3 style="MARGIN:12pt 0in 6pt;"&gt;Instancing Background Info&lt;/H3&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;When a receiving application receives a message, that message gets dispatched to an object’s instance method. The lifetime of this receiving object can be tied to one or more received messages. The WCF programming model allows developers and administrators to change this association through the InstanceContextMode instance property on the ServiceBehaviorAttribute type. The possible settings are:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;Single&lt;/B&gt;: every received message is dispatched to the same object (a singleton)&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;PerCall (default)&lt;/B&gt;: every received message is dispatched to a newly created object&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;PerSession&lt;/B&gt;: messages received within a session (usually a single sender) are dispatched to the same object&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;Shareable&lt;/B&gt;: messages received within a session (can be one or more senders) are dispatched to the same object&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;The following is a service contract and receiving type definition that sets the InstanceContextMode to Single:&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;[ServiceContract]&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;public interface ISomeContract&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;[OperationContract(IsOneWay=true)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;void SomeOperation(Int32 number);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT face="Courier New" size=2&gt;}&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;[ServiceBehavior(&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;InstanceContextMode=InstanceContextMode.Single)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;sealed class Receiver : ISomeContract {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;internal Receiver() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Console.WriteLine("the receiver has been created\n");&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;public void SomeOperation(Int32 number) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// Do work here&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;As you may have guessed, this setting has a direct impact on the lifetime of the receiving object, and it impacts the way we can share receiver object state when processing messages.&lt;/P&gt;
&lt;H3 style="MARGIN:12pt 0in 6pt;"&gt;Concurrency Background&lt;/H3&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;Since WCF is an asynchronous messaging platform. It makes extensive use of asynchronous I/O, and as a result, each received message may be dispatched to a receiving object by different threads. This feature allows WCF to use the CPU efficiently, and as a result, allows WCF applications to scale. The WCF programming model allows developers and administrators to choose how threads are utilized when messages are dispatched through the ConcurrencyMode instance property on the ServiceBehaviorAttribute type. The possible settings are:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;Single (default)&lt;/B&gt;: only one thread may access the receiver object at a time&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;Multiple&lt;/B&gt;: multiple threads may access the receiver object concurrently&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;Reentrant:&lt;/B&gt; only one thread may access the receiver object at a time, but callbacks may re-enter that object on another thread (Useful when performing asynchronous I/O)&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;The following is a service contract and receiving type definition that sets the ConcurrencyMode to Multiple.&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;[ServiceContract]&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;public interface ISomeContract&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;[OperationContract(IsOneWay=true)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;void SomeOperation(Int32 number);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT face="Courier New" size=2&gt;}&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;[ServiceBehavior(&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;mso-ansi-language:FR;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;InstanceContextMode=InstanceContextMode.Single,&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;mso-ansi-language:FR;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;ConcurrencyMode=ConcurrencyMode.Multiple)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;sealed class Receiver : ISomeContract {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;internal Receiver() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Console.WriteLine("the receiver has been created\n");&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;public void SomeOperation(Int32 number) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// Do work here (must consider multiple threads)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3 style="MARGIN:12pt 0in 6pt;"&gt;When is synchronization necessary?&lt;/H3&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;Both the InstanceContextMode and the ConcurrencyMode instance properties on the ServiceBehaviorAttribute type play a role in determining whether or not it is necessary to synchronize access to a receiver’s state. &lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;Let’s first consider the default settings of InstanceContextMode=InstanceContextMode.PerCall and ConcurrencyMode=Single. These settings dictate that a new receiver object will be created for every received message that is properly formatted, and that a single thread will invoke the instance method on the receiver object. The following service contract and receiver type definition can be used to test how these settings influence message processing (Sender code omitted for clarity):&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall,&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;ConcurrencyMode=ConcurrencyMode.Single)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;sealed class Receiver : ISomeContract {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;// member variable for race condition&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Int32 someNumber;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;internal Receiver() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Console.WriteLine("a receiver has been created");&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;static void Main(string[] args){&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// create the address and binding&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Uri address = new Uri("net.tcp://localhost:4000/ISomeContract");&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, false);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// create the service host and add an endpoint&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Console.WriteLine("Creating ServiceHost");&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ServiceHost svc = new ServiceHost(typeof(Receiver));&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;svc.AddServiceEndpoint(typeof(ISomeContract), binding, address);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// show the concurrency mode&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ServiceBehaviorAttribute annotation = svc.Description.Behaviors.Find&amp;lt;ServiceBehaviorAttribute&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof:yes;mso-ansi-language:FR;"&gt;Console.WriteLine("important behaviors:");&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;mso-ansi-language:FR;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Console.WriteLine("\tconcurrency mode = {0}", annotation.ConcurrencyMode);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;mso-ansi-language:FR;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Console.WriteLine("\tinstance context mode = {0}", annotation.InstanceContextMode);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-no-proof:yes;mso-ansi-language:FR;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;// open the service host (Start listening, among other things)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Console.WriteLine("opening ServiceHost");&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;svc.Open();&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Console.WriteLine("the Receiver is ready\n");&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// wait before exiting process&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Console.ReadLine();&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;// method can only be used with Concurrency Mode = PerCall&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;public void SomeOperation(Int32 number) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// set the field value to the parameter and wait&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;someNumber = number;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Random rand = new Random();&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Thread.Sleep(rand.Next(1000));&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// show the current value of the field and parameter&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// with percall, they will always be the same&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Console.WriteLine("parameter = {0}, somenumber = {1}, thread = {2}\n", &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;number.ToString(), &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;someNumber.ToString(), &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Thread.CurrentThread.ManagedThreadId);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=CodeBlock style="MARGIN:0in -59.75pt 3pt 0.25in;"&gt;&lt;SPAN style="mso-no-proof:yes;"&gt;&lt;FONT face="Courier New" size=2&gt;}&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;If a sending application sends 5 messages to this receiving application, the SomeOperation method is invoked 5 times synchronously by the same thread. The following is the console output:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&amp;nbsp;&lt;IMG src="http://www.wintellect.com/cs/DasBlogContentBinary/img1.bmp" border=0&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;Since one and only one thread can interact with the receiver object at a time, and each message is dispatched to a new receiver object, there is no need write thread synchronization code in our receiver type definition.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;If we change the InstanceContextMode to Single, we see the following output:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;IMG src="http://www.wintellect.com/cs/DasBlogContentBinary/img2.bmp" border=0&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;Here we have a single instance of the receiver type, but since the ConcurrencyMode is still Single, there is no need to write thread synchronization code in the SomeOperation method.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;If, however, we change the ConcurrencyMode to Multiple, we see the following:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;IMG src="http://www.wintellect.com/cs/DasBlogContentBinary/img3.bmp" border=0&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;Clearly, we now have a race condition, and as a result, we have to write synchronization code in our SomeOperation method. While this can be quite a chore, allows us to service received messages more efficiently than if we allow only one thread at a time to work with the receiver object. &lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;Repeating this process for the different settings of InstanceContextMode and ConcurrencyMode, the following grid becomes apparent (the non-shaded cells indicate whether or not synchronization code is necessary):&lt;/P&gt;
&lt;TABLE class=MsoNormalTable style="BORDER-RIGHT:medium none;BORDER-TOP:medium none;BORDER-LEFT:medium none;BORDER-BOTTOM:medium none;BORDER-COLLAPSE:collapse;mso-border-alt:solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;mso-border-insideh:.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext;" cellSpacing=0 cellPadding=0&gt;

&lt;TR style="mso-yfti-irow:0;mso-yfti-firstrow:yes;"&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:windowtext 1pt solid;PADDING-LEFT:5.4pt;BACKGROUND:silver;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:124.15pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;" rowSpan=2&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;TEXT-ALIGN:center;" align=center&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;InstanceContextMode&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:windowtext 1pt solid;PADDING-LEFT:5.4pt;BACKGROUND:silver;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:265.65pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;" colSpan=3&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;TEXT-ALIGN:center;" align=center&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;ConcurrencyMode&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow:1;"&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;BACKGROUND:silver;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Single (Default)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;BACKGROUND:silver;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Multiple&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;BACKGROUND:silver;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Reentrant&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow:2;"&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;BACKGROUND:silver;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:124.15pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Single&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;No&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Yes&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Yes&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow:3;"&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;BACKGROUND:silver;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:124.15pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Shareable&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;No&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Yes&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Yes&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow:4;"&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;BACKGROUND:silver;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:124.15pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;PerSession&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;No&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Yes&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;Yes&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow:5;mso-yfti-lastrow:yes;"&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;BACKGROUND:silver;PADDING-BOTTOM:0in;BORDER-LEFT:windowtext 1pt solid;WIDTH:124.15pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;mso-border-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;PerCall (Default)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;No&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;No&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT:windowtext 1pt solid;PADDING-RIGHT:5.4pt;BORDER-TOP:#ece9d8;PADDING-LEFT:5.4pt;PADDING-BOTTOM:0in;BORDER-LEFT:#ece9d8;WIDTH:88.55pt;PADDING-TOP:0in;BORDER-BOTTOM:windowtext 1pt solid;BACKGROUND-COLOR:transparent;mso-border-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;"&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;TEXT-INDENT:0in;LINE-HEIGHT:normal;"&gt;&lt;SPAN style="mso-bidi-font-size:12.0pt;"&gt;No&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;H3 style="MARGIN:12pt 0in 6pt;"&gt;Some thoughts on the table above…&lt;/H3&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;1) Reentrant seems goofy&lt;/B&gt;. I don't see the compelling reason to use it (it is like single, but callbacks must be synchronized).&lt;SPAN style="LINE-HEIGHT:200%;mso-bidi-font-size:12.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;2) Single seems like a huge scalability limiter&lt;/B&gt;, and I don't think it should be used.&lt;SPAN style="LINE-HEIGHT:200%;mso-bidi-font-size:12.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:6pt 0in 12pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;3) ConcurrencyMode should be set to Multiple.&lt;/B&gt; In my view, if a receiving application is going to scale, it must set concurrency mode to Multiple. If single or Reentrant are used, messages stack up as they wait to be processed, and that is badness.&lt;SPAN style="LINE-HEIGHT:200%;mso-bidi-font-size:12.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2835" width="1" height="1"&gt;</description><enclosure url="http://www.wintellect.com/cs/DasBlogContentBinary/img1.bmp" length="0" type="application/octet-stream" /><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>WCF and WS-RM</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/04/12/wcf-and-ws-rm.aspx</link><pubDate>Wed, 12 Apr 2006 04:08:11 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2838</guid><dc:creator>jsmith</dc:creator><slash:comments>3</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2838.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2838</wfw:commentRss><description>&lt;P&gt;I spoke briefly at Devscovery NYC&amp;nbsp;tonight about WCF and WS-ReliableMessaging. As promised, the&amp;nbsp;code is here:&lt;/P&gt;
&lt;DIV&gt;&lt;A href="http://www.wintellect.com/cs/DasBlogContentBinary/ReliableMessaging.zip"&gt;ReliableMessaging.zip (113.38 KB)&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Read the readme.txt file in the archive before running the sample.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Some other things you can do with this sample:&lt;/DIV&gt;
&lt;DIV&gt;1) Add IsInitiating and/or IsTerminating to the SubmitOrder OperationContract&lt;/DIV&gt;
&lt;DIV&gt;2) Create a new channel stack in the loop on the Sender.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;When I have a bit more time (in the next week or so)&amp;nbsp;I will expand on what these settings do...&lt;/DIV&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2838" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>WCF XmlDictionaries</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/03/28/wcf-xmldictionaries.aspx</link><pubDate>Tue, 28 Mar 2006 20:35:49 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2841</guid><dc:creator>jsmith</dc:creator><slash:comments>11</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2841.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2841</wfw:commentRss><description>&lt;DIV&gt;One of the cooler things about WCF shown at PDC last year was the use of WCF's custom XML stack. In a nutshell, WCF wraps the functionality of existing System.Xml types to allow greater messaging functionality. The types in WCF's xml stack are defined in the System.Runtime.Serialization assembly. Some interesting types in this assembly are System.Xml.XmlDictionary, System.Xml.XmlDictionaryReader, and System.Xml.XmlDictionaryWriter. This post extends part of Doug Purdy's COM326 PDC talk.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Consider the following XML content:&lt;BR&gt;&lt;FONT face="Courier New"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&amp;lt;Company&amp;gt;Wintellect&amp;lt;/Company&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Using pre-WCF types we write/read this content to/from a stream using the following code:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // write content to stream using XmlWriter&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MemoryStream stream = new MemoryStream();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (XmlWriter writer = XmlWriter.Create(stream))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.WriteElementString("Company", "Wintellect");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.Flush();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // shows 70 bytes written&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("XmlWriter wrote {0} bytes", stream.Position);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stream.Position = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("data read from stream:\n{0}\n", new StreamReader(stream).ReadToEnd());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Writing roughly the equivalent code using the XML Stack in WCF is as follows:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // write content to stream using the text flavor of WCF's XmlDictionaryWriter&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stream = new MemoryStream();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream, Encoding.UTF8, false))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.WriteStartDocument();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.WriteElementString("Company", "Wintellect");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.Flush();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // shows 67 bytes written&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("XmlDictionaryWriter (Text-UTF8) wrote {0} bytes", stream.Position);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stream.Position = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("data read from stream:\n{0}\n", new StreamReader(stream).ReadToEnd());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;From a messaging perspective, what if we wanted to create MTOM encoded XML? Well, we can do the following:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // write content to stream using the MTOM flavor of WCF's XmlDictionaryWriter&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stream = new MemoryStream();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateMtomWriter(stream, Encoding.UTF8, Int32.MaxValue, "Application/soap+xml"))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.WriteStartDocument();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.WriteElementString("Company", "Wintellect");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.Flush();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // show that 546 bytes were written&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("XmlDictionaryWriter (MTOM-UTF8) wrote {0} bytes", stream.Position);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stream.Position = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("data read from stream:\n{0}\n", new StreamReader(stream).ReadToEnd());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;BR&gt;&lt;/DIV&gt;
&lt;DIV&gt;One of the takeways from the previous example is that MTOM is not always optimal! It is important to remember that MTOM is intended for transporting binary data and allowing signatures to be safely applied to that data (But I digress).&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;You may have seen that WCF fully supports the XmlInfoset. Nowhere is this more apparent than when writing binary XML. Keep in mind that binary XML is still XML, it is just encoded differently. You can write binary XML with the WCF XML stack like the following:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // write content to stream using the binary flavor of WCF's XmlDictionaryWriter&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // without using a dictionary&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stream = new MemoryStream();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(stream, null, null))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.WriteStartDocument(); // does nothing in Feb CTP&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.WriteElementString("Company", "Wintellect");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.Flush();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // shows that 21 bytes were written&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("XmlDictionaryWriter (Binary, no dictionary) wrote {0} bytes", stream.Position);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stream.Position = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlDictionaryReader reader = XmlDictionaryReader.CreateBinaryReader(stream);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reader.Read();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("data read from stream:\n{0}\n", reader.ReadOuterXml());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Now to the dictionary part of the XmlDictionaryWriter / XmlDictionaryReader. The WCF XML stack allows XML data to be substitued with other data. In practical terms, this allows you to substitue XML content and "compress" the resultant data. The following code snippet shows how:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // write content to stream using the binary flavor of WCF's XmlDictionaryWriter&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // with a custom dictionary&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stream = new MemoryStream();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlDictionary dictionary = new XmlDictionary();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlDictionaryString entry = dictionary.Add("Company");&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(stream, dictionary, null))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.WriteStartDocument(); // does nothing in FebCTP&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.WriteElementString(entry, XmlDictionaryString.Empty, "Wintellect");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.Flush();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// shows 14 bytes written&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("XmlDictionaryWriter (Binary w/dictionary) wrote {0} bytes", stream.Position);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stream.Position = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlDictionaryReader reader = XmlDictionaryReader.CreateBinaryReader(stream, dictionary);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reader.Read();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("data read from stream:\n{0}\n", reader.ReadOuterXml());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;In my view, this is way cool. The Project is available here:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;A href="http://www.wintellect.com/cs/DasBlogContentBinary/Dictionaries.zip"&gt;Dictionaries.zip (14.26 KB)&lt;/A&gt;&amp;nbsp;&amp;nbsp;(NOTE: This sample requires the FebCTP of WCF....)&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;And will produce output like the following:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;IMG src="http://www.wintellect.com/cs/DasBlogContentBinary/output.jpg" border=0&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2841" width="1" height="1"&gt;</description><enclosure url="http://www.wintellect.com/cs/DasBlogContentBinary/output.jpg" length="0" type="image/jpg" /><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>VS2005 WCF Solution template</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/03/27/vs2005-wcf-solution-template.aspx</link><pubDate>Mon, 27 Mar 2006 05:05:59 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2842</guid><dc:creator>jsmith</dc:creator><slash:comments>1</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2842.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2842</wfw:commentRss><description>&lt;P&gt;As anyone who has written a WCF application knows, getting a "Hello World" app to run takes a bit more effort than doing the equivalent in Windows Forms. Don't get me wrong, it is pretty straightforward and simple after you get the hang of it, but it does take a few minutes of effort. The attached&amp;nbsp;VS Template&amp;nbsp;is a way to streamline that process a little bit more. &lt;/P&gt;
&lt;P&gt;The template&amp;nbsp;creates contract, receiver, and sender projects and sets all the references properly (for the Feb CTP).&lt;/P&gt;
&lt;P&gt;To install the template, download the zip file and place&amp;nbsp;it&amp;nbsp;in your My Documents\Visual Studio 2005\Templates\ProjectTemplates folder.&lt;/P&gt;
&lt;P&gt;You can download the template here: &lt;A href="http://www.wintellect.com/cs/DasBlogContentBinary/WCF%20Solution.zip"&gt;WCF Solution.zip (28.6 KB)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;When installed, the Solution appears as follows:&lt;/P&gt;
&lt;DIV align=left&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;IMG src="http://www.wintellect.com/cs/DasBlogContentBinary/TemplateShot1.JPG" border=0&gt;&lt;/DIV&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2842" width="1" height="1"&gt;</description><enclosure url="http://www.wintellect.com/cs/DasBlogContentBinary/TemplateShot1.JPG" length="0" type="application/octet-stream" /><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>Looking for a "Few Good Reviewers"</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/03/24/looking-for-a-few-good-reviewers.aspx</link><pubDate>Fri, 24 Mar 2006 22:41:49 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2843</guid><dc:creator>jsmith</dc:creator><slash:comments>3</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2843.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2843</wfw:commentRss><description>&lt;P&gt;As some of you know, I began working on a WCF book several months ago. Currently I am looking to increase the size of my “Review Crew” (John Robbin’s term). Hopefully I am not opening myself up to hoards of email, but if you are interested in reviewing my book see the last section of this post. My hope is that more viewpoints will ensure the book:&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp;addresses the topics developers must know,&lt;BR&gt;2)&amp;nbsp;properly addresses the topics developers are most interested in, and&lt;BR&gt;3)&amp;nbsp;explains WCF at the proper level of detail. &lt;/P&gt;
&lt;P&gt;In general, this book is targeted at an advanced audience, and describes WCF internals from the inside-out. I expect to have the book on bookshelves by the Vista launch. &lt;/P&gt;
&lt;H3&gt;About the book&lt;/H3&gt;
&lt;P&gt;WCF is fundamentally a service-oriented XML messaging platform. The WCF team has successfully abstracted the XML messaging infrastructure away from the object model developers are most likely to use. Given this fact, three approaches are possible when explaining this technology:&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp;Focus strictly on the Object Model (since this is where developers will most likely spend all of their time)&lt;BR&gt;2)&amp;nbsp;Focus strictly on WCF internals and the theory behind WCF&lt;BR&gt;3)&amp;nbsp;Blend the previous two approaches&lt;/P&gt;
&lt;P&gt;This book takes the third approach, and I have taken some flack over it. Many believe that #1 is the best approach. Their belief stems from the assumption that the level of abstraction in the WCF platform releases developers from having to consider WCF internals or service-orientation in general.&lt;/P&gt;
&lt;P&gt;My counterpoint is pretty straightforward. While it is true that WCF does not force developers to directly deal with the messy business of angle brackets and WS-* protocols, it does not completely release the developer from the responsibility making the mental shift to service-orientation. In much the same way that successful adoption of an object-oriented language like C++ or Java required developers to shift their thinking from procedural programming to object-orientation, successful adoption of WCF requires developers to evolve from a component-oriented mindset to a service-oriented mindset. If we fail to make this shift, we run the risk of missing out on many of the features offered through service orientation.&lt;/P&gt;
&lt;P&gt;Even if we do not care about the features service-orientation offers, we should understand WCF infrastructure. In essence, we should know our platform. The CLR offers supporting evidence for this stance. The CLR team did a great job abstracting the Garbage Collector and the JIT Compiler away from the developer. As a result, it is technically possible for us to write .NET applications with little or no knowledge of how these subsystems work. Failing to understand these concepts, however, increases the risk that we will write inefficient applications. For example, a C++ developer moving to C# without any knowledge of the garbage collector will instinctively add a finalizer to all type declarations. Unknowingly, this developer will have increased the time required to allocate these objects and increased the lifetime of these objects. Technically this is not a bug, but it is certainly an inefficiency that could have been averted with a couple of hours spent in a book or a presentation on the topic.&lt;/P&gt;
&lt;P&gt;In a similar vein, understanding WCF infrastructure can avert unnecessary inefficiencies in WCF applications, and allows developers to better leverage the functionality available in WCF. For example, changing the reliable session parameter in the constructor of a binding has a dramatic impact on the messaging choreography between endpoints. The WCF team has rightfully abstracted this choreography away from the developer and partially exposed it via compatible bindings. From the perspective of the developer, this messaging choreography is sometimes necessary, and sometimes it is not. It is only through an understanding of this choreography that a developer can make the decision whether or not to use this feature (not to mention what it would take to debug the interaction!). Indirectly, understanding the reliable messaging choreography requires a grasp of service orientation. &lt;/P&gt;
&lt;P&gt;This book aims to achieve the right mix of service-orientation concepts and a deep exploration of the WCF programming model, thereby equipping the reader with the knowledge necessary to design, build, maintain, and version WCF applications.&lt;/P&gt;
&lt;H3&gt;If you disagree with my viewpoint&lt;/H3&gt;
&lt;P&gt;Feel free to send me an email (justins care of this company) and let me know your approach and why it’s better.&lt;/P&gt;
&lt;H3&gt;If you would like to be a member of the Review Crew&lt;/H3&gt;
&lt;P&gt;In general, I am looking for experienced .NET developers and architects that have full lifecycle experience with distributed applications. I am also open to hearing from folks who are experienced with WebSphere, BEA, etc. If you are interested, send me an email at (justins care of this company) that contains the following:&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp;What is your experience with .NET&lt;BR&gt;2)&amp;nbsp;What is your experience with distributed applications&lt;BR&gt;3)&amp;nbsp;Are you a professional developer / architect? If so, what company(s) do you work for?&lt;/P&gt;
&lt;P&gt;You might be asking yourself, “What’s in it for me?” &lt;BR&gt;1)&amp;nbsp;You will get to read the book before anyone else&lt;BR&gt;2)&amp;nbsp;You will have the satisfaction of a job well-done, and acknowledgement in the book&lt;BR&gt;3)&amp;nbsp;A free dinner next time I am in your area (or next time you are in Atlanta)&lt;BR&gt;4)&amp;nbsp;A signed copy of the book (the signature might actually reduce the value of the book ).&lt;/P&gt;
&lt;P&gt;You might also be asking yourself, “What would I be signing up for?”&lt;BR&gt;1)&amp;nbsp;Checking technical accuracy of the book&lt;BR&gt;2)&amp;nbsp;Giving me feedback on how what you think&lt;BR&gt;3)&amp;nbsp;Letting me know what questions you have about the technology&lt;BR&gt;4)&amp;nbsp;Telling me what you would like to see added / removed from the book&lt;BR&gt;5)&amp;nbsp;Reviewing chapters in a timely manner&lt;BR&gt;6)&amp;nbsp;Agreeing in principle to an NDA&lt;/P&gt;
&lt;P&gt;I will be accepting new members to the review crew over the next two weeks, so the deadline for submission is April 7.&lt;/P&gt;
&lt;P&gt;I look forward to hearing from you!&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2843" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>WPF (Feb CTP) crashes Visual Studio 2005</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/03/17/wpf-feb-ctp-crashes-visual-studio-2005.aspx</link><pubDate>Fri, 17 Mar 2006 08:34:13 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2845</guid><dc:creator>jsmith</dc:creator><slash:comments>1</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2845.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2845</wfw:commentRss><description>&lt;P&gt;I just moved a WPF / WCF application from my laptop to my workstation, and it suddenly started crashing Visual Studio as soon as the project loaded (those darn CTPs). After some hunting and pecking around, I came across this post:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=234330&amp;amp;SiteID=1&amp;amp;PageID=2"&gt;http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=234330&amp;amp;SiteID=1&amp;amp;PageID=2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It seems that WPF (at least the Feb CTP) will not work on multi-processor machines. I am sure this will be fixed soon, but in the meantime, you have to start VS, then force Visual Studio to use one processor...&lt;/P&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2845" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>ClickOnce partial download thoughts</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/03/16/clickonce-partial-download-thoughts.aspx</link><pubDate>Fri, 17 Mar 2006 02:03:03 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2846</guid><dc:creator>jsmith</dc:creator><slash:comments>3</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2846.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2846</wfw:commentRss><description>&lt;P&gt;One interesting feature of ClickOnce deployments is the capability to dynamically download files. These files can be anything: assemblies, images, help files, etc. This feature makes sense when you are trying to speed up installation time, or your application requires files that are used occasionally.&lt;/P&gt;
&lt;P&gt;When compared to the default ClickOnce scenario,&amp;nbsp;taking advantage of &amp;nbsp;this functionality requires two additional steps:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;changing the application manifest to include one or more optional file groups 
&lt;LI&gt;using the System.Deployment types to programmatically download the files in these optional file groups&lt;/LI&gt;&lt;/OL&gt;
&lt;DIV&gt;When I searched on how to do this, all of the code samples I found used this feature for downloading everything &lt;EM&gt;except for assemblies&lt;/EM&gt;. In my application I wanted to use this feature to download an assembly. My assumption was that I could just add the assemblies to a file group and all would be right. Well, that isn't the way it works out. Let me illustrate with an example.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Let's say I am writing a Notepad variant called &amp;nbsp;SecureMyNotepad, and I want to offer email functionality in my version of SecureMyNotepad. Let's also say that I want to split the email functionality into a separate assembly. We now have&amp;nbsp;two assemblies - SecureMyNotepad.exe and WintellectMail.dll. Let's also assume that I want WintellectMail.dll to download only when the menu item "Email" is selected (see below)&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;IMG src="http://www.wintellect.com/cs/DasBlogContentBinary/MyNotepad1.gif" border=0&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;The first thing I need to do is setup my applicatoin manifest. To do this, I go to the Publish tab in the Properties of my VS project and select "Application Files"&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;IMG src="http://www.wintellect.com/cs/DasBlogContentBinary/ApplicationManifest.gif" border=0&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Notice that the Download Group is changed to "Mail". Internally Visual Studio uses this information to create the following manifest snippet:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face="Courier New" color=#0000ff&gt;&amp;lt;dependency &lt;FONT color=#ff0000&gt;optional="true"&amp;gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp; &amp;lt;dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="WintellectMail.dll"&amp;nbsp; size="20480" &lt;FONT color=#ff0000&gt;group="Mail"&amp;gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;assemblyIdentity name="WintellectMail" version="1.0.0.0" publicKeyToken="EF7FE5810D23B378" language="neutral" processorArchitecture="msil" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;hash&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dsig:Transforms&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/dsig:Transforms&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dsig:DigestMethod Algorithm="&lt;/FONT&gt;&lt;A href="http://www.w3.org/2000/09/xmldsig#sha1"&gt;&lt;FONT face="Courier New" color=#0000ff&gt;http://www.w3.org/2000/09/xmldsig#sha1&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New" color=#0000ff&gt;" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dsig:DigestValue&amp;gt;g3tJEPdbE6y27FVgz/JrlF9Y1Ks=&amp;lt;/dsig:DigestValue&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/hash&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/dependentAssembly&amp;gt;&lt;BR&gt;&amp;lt;/dependency&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Now when we publish the application and install it via the normal ClickOnce process the WintellectMail.dll assembly is not downloaded with SecureMyNotepad.exe. We have to write some code in the menu item event handler to download the files in the Mail file group. That code looks like the following:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;private void&lt;/FONT&gt; emailToolStripMenuItem_Click(object sender, EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ClickOnce: Check to see if this app was deployed via ClickOnce&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // throw exception if it wasn't&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (ApplicationDeployment.IsNetworkDeployed)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#008000&gt;// ClickOnce: Get the current deployment&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deployment = ApplicationDeployment.CurrentDeployment;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#008000&gt;// ClickOnce: Check if the Mail FileGroup has been downloaded previously&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (!deployment.IsFileGroupDownloaded("Mail"))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // if not, get it&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deployment.DownloadFileGroup("Mail");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;throw&lt;/FONT&gt; new InvalidProgramException("this application was not deployed via ClickOnce.");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ClickOnce:&amp;nbsp;Call&amp;nbsp;method defined in WintellectMail.dll&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Bad Code!&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WintellectMail.SendMail();&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;The important point here is the SendMail call (last line of code). The type WintellectMail is defined in the newly downloaded&amp;nbsp;WintellectMail.dll. &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;At runtime,&amp;nbsp;this code&amp;nbsp;throws an&amp;nbsp;AssemblyLoadException. My first reaction was that I must not be downloading the assembly. After some thinking and some checking, I realized that indeed I wasn't, but&amp;nbsp;the reason&amp;nbsp;has nothing to do with the System.Deployment types.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Remember the JIT Compiler! When this method is invoked for the first time, the JIT Compiler goes to work. Among other things,&amp;nbsp;the JIT Compiler triggers the assembly loader. The assembly loader&amp;nbsp;is trying to load&amp;nbsp;the WintellectMail assembly before the first&amp;nbsp;instruction has been executed, hence the exception.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;To fix our bad code, all we have to do is refactor our call to Wintellect.SendMail() into a local method. The JIT Compiler will not complain.&amp;nbsp;The new code is below:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;private void&lt;/FONT&gt; emailToolStripMenuItem_Click(object sender, EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ClickOnce: Check to see if this app was deployed via ClickOnce&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // throw exception if it wasn't&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (ApplicationDeployment.IsNetworkDeployed)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#008000&gt;// ClickOnce: Get the current deployment&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deployment = ApplicationDeployment.CurrentDeployment;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#008000&gt;// ClickOnce: Check if the Mail FileGroup has been downloaded previously&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (!deployment.IsFileGroupDownloaded("Mail"))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // if not, get it&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deployment.DownloadFileGroup("Mail");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;throw&lt;/FONT&gt; new InvalidProgramException("this application was not deployed via ClickOnce.");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ClickOnce:&amp;nbsp;Call&amp;nbsp;SendMail method&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SendMail();&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // prevent inlining for all builds (good catch&amp;nbsp;Daniel!)&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[MethodImpl(MethodImplOptions.NoInlining)]&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt; private void&lt;/FONT&gt; SendMail()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#008000&gt;// ClickOnce:&amp;nbsp;Call&amp;nbsp;method defined in WintellectMail.dll&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WintellectMail.SendMail();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;As I said, this isn't exactly groundbreaking, but hopefully it saves someone some time... 
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=2846" width="1" height="1"&gt;</description><enclosure url="http://www.wintellect.com/cs/DasBlogContentBinary/MyNotepad1.gif" length="0" type="image/gif" /><category domain="http://www.wintellect.com/CS/blogs/jsmith/archive/tags/Justin+Smith/default.aspx">Justin Smith</category></item><item><title>Lost Chat</title><link>http://www.wintellect.com/CS/blogs/jsmith/archive/2006/01/13/lost-chat.aspx</link><pubDate>Fri, 13 Jan 2006 19:58:00 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:2850</guid><dc:creator>jsmith</dc:creator><slash:comments>2</slash:comments><comments>http://www.wintellect.com/CS/blogs/jsmith/comments/2850.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jsmith/commentrss.aspx?PostID=2850</wfw:commentRss><description>&lt;P&gt;Over the past year, I have become an avid viewer of the awful drama series &lt;I style="mso-bidi-font-style:normal;"&gt;Lost &lt;/I&gt;(awful because they show re-runs during the season). In honor of last night&amp;#8217;s new episodes, I have written a distributed system that I like to call Lost Chat. It is reminiscent of the chat between Michael and &amp;#8220;Walt&amp;#8221;&amp;#8230; &lt;/P&gt;
&lt;P&gt;Lost Chat is comprised of two WCF (the technology formerly known as Indigo) console applications and one contract assembly. These components can be used in a traditional &amp;#8220;chatting&amp;#8221; scenario (hence the name). From a technical perspective, these components may be interesting since they use duplex communication, contain no configuration files, and interact directly with the Message type. While it may not always be feasible to use the Message type and a purely imperative coding model in production, I have found them to be extremely helpful in understanding WCF architecture. The VS solution containing the code will be available soon, and please forgive the formatting (or lack therof).&lt;SPAN style="mso-bidi-font-size:7.0pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;SPAN style="COLOR:black;"&gt;Let&amp;#8217;s start with the contract. For simplicity, the contract is contained in a separate project and referenced by other Lost Chat components. The contract is simple:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;SPAN style="COLOR:black;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:green;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;// file: Contracts.cs&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:green;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; System;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; System.ServiceModel;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:green;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;// define the contract for the service&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;[&lt;SPAN style="COLOR:teal;"&gt;ServiceContract&lt;/SPAN&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Namespace = &lt;SPAN style="COLOR:maroon;"&gt;"http://wintellect.com/LostChat"&lt;/SPAN&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;CallbackContract=&lt;SPAN style="COLOR:blue;"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR:teal;"&gt;IChatCallback&lt;/SPAN&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Session=&lt;SPAN style="COLOR:blue;"&gt;false&lt;/SPAN&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;interface&lt;/SPAN&gt; &lt;SPAN style="COLOR:teal;"&gt;IChat&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR:teal;"&gt;OperationContract&lt;/SPAN&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Action=&lt;SPAN style="COLOR:maroon;"&gt;"urn:ServerChat"&lt;/SPAN&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;IsOneWay=&lt;SPAN style="COLOR:blue;"&gt;true&lt;/SPAN&gt; )]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; SendChat(&lt;SPAN style="COLOR:teal;"&gt;Message&lt;/SPAN&gt; msg);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:green;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;// define the contract for the callback&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;interface&lt;/SPAN&gt; &lt;SPAN style="COLOR:teal;"&gt;IChatCallback&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR:teal;"&gt;OperationContract&lt;/SPAN&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Action=&lt;SPAN style="COLOR:maroon;"&gt;"urn:ServerChatCallback"&lt;/SPAN&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;IsOneWay=&lt;SPAN style="COLOR:blue;"&gt;true&lt;/SPAN&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; SendCallbackChat(&lt;SPAN style="COLOR:teal;"&gt;Message&lt;/SPAN&gt; msg);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;SPAN style="COLOR:black;"&gt;Next, let&amp;#8217;s build the receiver service (the entity that receives a message in Simplex communication). Remember that we are using the duplex message exchange pattern, so the hard-coded name &amp;#8220;receiver&amp;#8221; only has context in the first message exchange. Our receiver service has the following implementation:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;"&gt;&lt;SPAN style="COLOR:black;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:green;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;// file: Receiver.cs&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:green;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; System;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; System.Xml;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; System.Text;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; System.ServiceModel;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; System.Diagnostics;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:teal;"&gt;Service&lt;/SPAN&gt; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR:teal;"&gt;IChatCallback&lt;/SPAN&gt; Callback = &lt;SPAN style="COLOR:blue;"&gt;null&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; Main() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;// define the binding for the service&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:teal;"&gt;WSDualHttpBinding&lt;/SPAN&gt; binding = &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:teal;"&gt;WSDualHttpBinding&lt;/SPAN&gt;(&lt;SPAN style="COLOR:teal;"&gt;WSDualHttpSecurityMode&lt;/SPAN&gt;.None);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;// use the Text encoder&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;binding.MessageEncoding = &lt;SPAN style="COLOR:teal;"&gt;WSMessageEncoding&lt;/SPAN&gt;.Text;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;// define the address for the service&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:teal;"&gt;Uri&lt;/SPAN&gt; addressURI = &lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:teal;"&gt;Uri&lt;/SPAN&gt;(&lt;SPAN style="COLOR:maroon;"&gt;@"http://localhost:8000/Chat"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;// instantiate a Service host using the MyService type&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;using&lt;/SPAN&gt; (&lt;SPAN style="COLOR:teal;"&gt;ServiceHost&lt;/SPAN&gt; svc = &lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:teal;"&gt;ServiceHost&lt;/SPAN&gt;(&lt;SPAN style="COLOR:blue;"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR:teal;"&gt;MyService&lt;/SPAN&gt;)))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;// add an endpoint to the service with the address, &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;// contract, and binding&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;svc.AddServiceEndpoint(&lt;SPAN style="COLOR:blue;"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR:teal;"&gt;IChat&lt;/SPAN&gt;), binding, addressURI);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;// open the service to start listening&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;svc.Open();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:teal;"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR:maroon;"&gt;"LOST chat"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:teal;"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR:maroon;"&gt;"The service is ready"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:teal;"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR:maroon;"&gt;"4 8 15 16 23 42 to exit"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:teal;"&gt;Console&lt;/SPAN&gt;.Write(&lt;SPAN style="COLOR:maroon;"&gt;"You:&amp;gt; "&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:teal;"&gt;String&lt;/SPAN&gt; cmdLine = &lt;SPAN style="COLOR:blue;"&gt;null&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;while&lt;/SPAN&gt; ((cmdLine = &lt;SPAN style="COLOR:teal;"&gt;Console&lt;/SPAN&gt;.ReadLine()) != &lt;SPAN style="COLOR:maroon;"&gt;"4 8 15 16 23 42"&lt;/SPAN&gt;){&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;if&lt;/SPAN&gt; (Callback != &lt;SPAN style="COLOR:blue;"&gt;null&lt;/SPAN&gt;) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Callback.SendCallbackChat(GenerateMessage(cmdLine, &lt;SPAN style="COLOR:maroon;"&gt;"urn:ServerChatCallback"&lt;/SPAN&gt;));&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;else&lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:teal;"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR:maroon;"&gt;"You must wait to be contacted first"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:teal;"&gt;Console&lt;/SPAN&gt;.Write(&lt;SPAN style="COLOR:maroon;"&gt;"You:&amp;gt; "&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:9pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;mso-layout-grid-align:none;"&gt;&lt;SPA