<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>Vipul Modi's Blog</title><link>http://blogs.msdn.com/vipulmodi/default.aspx</link><description>.NET 3.0 and Beyond - Web Service Discovery</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Dynamic Proxy and Memory Footprint</title><link>http://blogs.msdn.com/vipulmodi/archive/2008/10/16/dynamic-proxy-and-memory-footprint.aspx</link><pubDate>Fri, 17 Oct 2008 05:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9002693</guid><dc:creator>vipulm</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/9002693.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=9002693</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;A while back I published a post about &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx" mce_href="http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx"&gt;&lt;FONT face=Calibri size=3&gt;dynamic programming with WCF&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; using the &lt;/FONT&gt;&lt;A class="" href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&amp;amp;DownloadId=3939" target=_blank mce_href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&amp;amp;DownloadId=3939"&gt;&lt;FONT face=Calibri size=3&gt;dynamic proxy library&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; that allows you to create WCF client dynamically at runtime. Thank you for using the sample and sending your comments. Frequently I get feedback about the memory usage of the applications using this library. It seems that if you create many dynamic proxies during the lifetime of your application, the memory footprint keeps growing. This is a common problem that you encounter when using any dynamically created assembly in your application. You need to aware of this issue and take appropriate measure to make sure that you are not leaking memory. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The dynamic proxy creates the proxy assembly at runtime; this assembly is stored in a temporary location on your file system and loaded in the memory of your app domain. Now if you do not need the dynamic proxy anymore, there is no way to unload this temporary assembly. There isn’t. You need to unload the entire app domain. So what should you do if you need to create and destroy many dynamic proxies in your application? Simply, isolate the code that is creating and using the dynamic proxy and run it in a different app domain. Once you are done, simply unload that app domain. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Here is a simple modification to the example program from the &lt;A class="" href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&amp;amp;DownloadId=3939" target=_blank mce_href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&amp;amp;DownloadId=3939"&gt;&lt;FONT face=Calibri size=3&gt;dynamic proxy library&lt;/FONT&gt;&lt;/A&gt;&amp;nbsp;that runs the dynamic client in a new app domain. You will notice that the memory footprint of the application remains the same over large number of iterations. &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Program&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;public&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;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;string&lt;/SPAN&gt; serviceWsdlUri = &lt;SPAN style="COLOR: #a31515"&gt;"http://localhost:8080/WcfSamples/DynamicProxy?wsdl"&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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; (args.Length &amp;gt; 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;&amp;nbsp; &lt;/SPAN&gt;serviceWsdlUri = args[0];&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;for&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; i = 0; i &amp;lt; 1000; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;AppDomain&lt;/SPAN&gt; proxyDomain = &lt;SPAN style="COLOR: #2b91af"&gt;AppDomain&lt;/SPAN&gt;.CreateDomain(&lt;SPAN style="COLOR: #a31515"&gt;"ProxyExecutionDomain"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DynamicClient&lt;/SPAN&gt; dynamicClient = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DynamicClient&lt;/SPAN&gt;(serviceWsdlUri);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;&amp;nbsp; &lt;/SPAN&gt;proxyDomain.DoCallBack(&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;CrossAppDomainDelegate&lt;/SPAN&gt;(dynamicClient.CrossAppDomainCallback));&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;AppDomain&lt;/SPAN&gt;.Unload(proxyDomain);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&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;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;GC&lt;/SPAN&gt;.Collect();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;Serializable&lt;/SPAN&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DynamicClient&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;string&lt;/SPAN&gt; serviceWsdlUri;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;public&lt;/SPAN&gt; DynamicClient(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; serviceWsdlUri)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;this&lt;/SPAN&gt;.serviceWsdlUri = serviceWsdlUri;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; CrossAppDomainCallback()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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: green"&gt;// create the dynamic proxy factory, that downloads the service metadata &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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: green"&gt;// and create the dynamic factory.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Creating DynamicProxyFactory for "&lt;/SPAN&gt; + serviceWsdlUri);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; 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: #2b91af"&gt;DynamicProxyFactory&lt;/SPAN&gt; factory = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DynamicProxyFactory&lt;/SPAN&gt;(serviceWsdlUri);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: #f2f2f2; MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9002693" width="1" height="1"&gt;</description></item><item><title>WS-Discovery Sample Implementation</title><link>http://blogs.msdn.com/vipulmodi/archive/2006/12/21/ws-discovery-sample-implementation.aspx</link><pubDate>Fri, 22 Dec 2006 01:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1344107</guid><dc:creator>vipulm</dc:creator><slash:comments>28</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/1344107.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=1344107</wfw:commentRss><description>&lt;P&gt;The sample implementation of WS-Discovery protocol is now available at&amp;nbsp;&lt;A href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&amp;amp;DownloadId=3940"&gt;http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&amp;amp;DownloadId=3940&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Using this sample you can publish and find WCF services using WS-Discovery protocol. Please either submit your feedback directly on the sample page or send it to me (&lt;A href="mailto:vipul.modi@microsoft" mce_href="mailto:vipul.modi@microsoft"&gt;vipul.modi@microsoft&lt;/A&gt;.).&amp;nbsp;Your feedback will help in designing the discovery APIs for the next release.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1344107" width="1" height="1"&gt;</description></item><item><title>Dynamic Programming with WCF</title><link>http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx</link><pubDate>Thu, 16 Nov 2006 21:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1089021</guid><dc:creator>vipulm</dc:creator><slash:comments>23</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/1089021.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=1089021</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://wcf.netfx3.com/files/folders/development_tools/entry6148.aspx" mce_href="http://wcf.netfx3.com/files/folders/development_tools/entry6148.aspx"&gt;&lt;/A&gt;&lt;/P&gt;&lt;FONT face=Verdana size=2&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial"&gt;Update: Please check out the post on memory footprint and dynamic proxy (&lt;A href="http://blogs.msdn.com/vipulmodi/archive/2008/10/16/dynamic-proxy-and-memory-footprint.aspx"&gt;http://blogs.msdn.com/vipulmodi/archive/2008/10/16/dynamic-proxy-and-memory-footprint.aspx&lt;/A&gt;)&amp;nbsp;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial"&gt;-----&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial"&gt;Ever wonder what it would like to go from WSDL to code at runtime? Check out my WCF Dynamic Proxy tool that I posted on the wcf.nefx3.com community site. The WCF Dynamic Proxy downloads the WSDL, generate the code, compile the code and then allow you to invoke the web service operations using reflection, all at runtime. Here is the readme from the tool: &lt;A href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&amp;amp;DownloadId=3939"&gt;http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&amp;amp;DownloadId=3939&lt;/A&gt;&lt;A class="" href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&amp;amp;DownloadId=3939" target=_blank mce_href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&amp;amp;DownloadId=3939"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The DynamicProxy allows you to create the dynamic WCF client at runtime by specifying the WSDL URI of the service. The DynamicProxy does not depend on the precompiled proxy or configuration. The DynamicProxy uses the MetadataResolver to download the metadata from the service and WsdlImporter to create the contract and binding at runtime. The compiled dynamic proxy can be used to invoke the operations on the service using reflection. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The example shows how you can the dynamic proxy to invoke operations that use simple types and complex types. The flow of usage is as following.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;1. Create the ProxyFactory specifying the WSDL URI of the service.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DynamicProxyFactory factory = new DynamicProxyFactory("&lt;/FONT&gt;&lt;A href="http://localhost:8080/WcfSamples/DynamicProxy?wsdl" mce_href="http://localhost:8080/WcfSamples/DynamicProxy?wsdl"&gt;&lt;FONT face=Verdana size=2&gt;http://localhost:8080/WcfSamples/DynamicProxy?wsdl&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;2. Browse the endpoints, metadata, contracts etc. &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; factory.Endpoints&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; factory.Metadata&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; factory.Contracts&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; factory.Bindings&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;3. Create DynamicProxy to an endpoint by specifying either the endpoint or &lt;BR&gt;&amp;nbsp;&amp;nbsp; contract name.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DynamicProxy proxy = factory.CreateProxy("ISimpleCalculator");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OR &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DynamicProxy proxy = factory.CreateProxy(endpoint);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;BR&gt;4. Invoke operations on the DynamicProxy&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dobule result = (dobule)proxy.CallMethod("Add", 1d ,2d);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;5. Close the DynamicProxy&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; proxy.Close();&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1089021" width="1" height="1"&gt;</description></item><item><title>What's next</title><link>http://blogs.msdn.com/vipulmodi/archive/2006/11/16/what-s-next.aspx</link><pubDate>Thu, 16 Nov 2006 21:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1089003</guid><dc:creator>vipulm</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/1089003.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=1089003</wfw:commentRss><description>&lt;P&gt;Every once in while after a big release, the question comes to your mind, what's next? Well for me it is WS-Discovery, yes I am going to work on design and implementation of the web service discovery APIs for our next release. I have been involved been Discovery for a while including the WS-discovery specification work. I plan to release the sample implementation of WS-Discovery on top of .NET 3.0 on the netfx3.com community site soon. I would love to hear about your disovery requirements and scenarios, so that we can consider them in our design. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1089003" width="1" height="1"&gt;</description></item><item><title>Disabling JIT Debugging Dialog Box</title><link>http://blogs.msdn.com/vipulmodi/archive/2006/06/20/640749.aspx</link><pubDate>Wed, 21 Jun 2006 01:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:640749</guid><dc:creator>vipulm</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/640749.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=640749</wfw:commentRss><description>&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;When an executable throws unhandled exception by default JIT-debugging kicks in that allow you to attach a debugger to the dying process and investigate the issue. This useful feature can become annoying during the development where you just want to get the stack dump of the unhandled exception. The Visual Studio 2005 and Vista have JIT debugging enabled by default. &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;However it is really easy to turn it off. Change the value of the registry key&amp;nbsp; HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting to 1 to get the stack dump, the process will be terminated after that. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;FONT face=Verdana size=2&gt;For more information: &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconenablingjit-attachdebugging.asp"&gt;&lt;FONT face=Verdana size=2&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconenablingjit-attachdebugging.asp&lt;/FONT&gt;&lt;/A&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=640749" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vipulmodi/archive/tags/Indigo/default.aspx">Indigo</category></item><item><title>Modifying the Body of the Message</title><link>http://blogs.msdn.com/vipulmodi/archive/2005/09/16/469070.aspx</link><pubDate>Fri, 16 Sep 2005 17:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:469070</guid><dc:creator>vipulm</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/469070.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=469070</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The modification of the body is a common task required in many applications. The Message Fixer explained in "&lt;a href="http://blogs.msdn.com/vipulmodi/archive/2005/07/05/435822.aspx"&gt;Fixed the Messages&lt;/A&gt;" article performs body modification before the after the request is received and before the response is sent on the server side or before sending the request and after receiving the response on the client side. As explained in the article for smaller message one can create the XMLDocument from the message body by getting the Body reader from the message as shown below. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;// Fix the request&lt;BR&gt;XmlDocument doc = new XmlDocument();&lt;BR&gt;doc.Load(request.GetBodyReader());&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;However recently while working on an Interop application I discovered that this quick an easy way of modifying the body of the messages did not work in cases when the body content had elements or attributes of QName type. Specifically if the namespace for the prefix used in the value of element or attribute was defined before the Body element. The XML processors typically do not poke at the values and hence they try their best to preserve the context at which the namespace was declared.&amp;nbsp; In my case I was creating XML document from the Body element onwards. Hence if the namespace declaration was before the Body element, i..e at the Envelope level, which XML document never saw, the re declaration of the namespace occurred. The namespace was re declared when it was first used in the name of the element or attribute and NOT when it was used as the value of the element or attribute.&amp;nbsp; For example, if an XML document was created from the Body reader of the Message object for the following message the namespace http://mynamespace was re declared after it was used in one of the attribute values. You can see how this can result in failure of parsing the values later on.&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE id=table1 style="BORDER-COLLAPSE: collapse" width="95%" bgColor=#ffffcc border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width="50%"&gt;&lt;FONT face=Verdana size=2&gt;&lt;B&gt;Original Message&lt;/B&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;lt;s:Envelope xmlns:q="http://mynamespace" ...&amp;gt; &lt;BR&gt;&amp;nbsp; &amp;lt;s:Body&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MyRequest xmlns="http://tempuri.org" MyAttr="q:myattrvalue"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;q:value2&amp;gt; &amp;lt;/q:value2&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MyRequest&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/s:Body&amp;gt;&lt;BR&gt;&amp;lt;s:Envelope&amp;gt;&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top&gt;&lt;FONT face=Verdana size=2&gt;&lt;B&gt;Processed Message&lt;/B&gt;&lt;BR&gt;&lt;BR&gt;&amp;lt;s:Envelope&amp;nbsp; ...&amp;gt; &lt;BR&gt;&amp;nbsp; &amp;lt;s:Body&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MyRequest xmlns="http://tempuri.org" MyAttr="q:myattrvalue"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;q:value2 xmlns:q="http://mynamespace"&amp;gt; &amp;lt;/q:value2&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/MyRequest&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/s:Body&amp;gt;&lt;BR&gt;&amp;lt;s:Envelope&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;So how does on modifies the message? The easiest way to do this would be to preserve the complete message and then perform the modification on the body. Note that this is applicable to small messages that you can fit reasonably in memory. &lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Write out the entire message as string &lt;/FONT&gt;&lt;PRE style="COLOR: #000000; BACKGROUND-COLOR: #e5e5e5"&gt;&lt;FONT size=3&gt; StringBuilder builder = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; StringBuilder();
 XmlWriter writer = XmlWriter.Create(builder);
 origMsg.WriteMessage(writer);
 writer.Close();
 &lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; origMsgStr = builder.ToString()&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;BR&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Perform the modifications on the string or create the DOM using XMLDocument.LoadXml method. &lt;/FONT&gt;&lt;PRE style="COLOR: #000000; BACKGROUND-COLOR: #e5e5e5"&gt;&lt;FONT size=3&gt; XmlDocument origMsgDoc = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlDocument();
 origMsgDoc.LoadXml(origMsgStr);
    
 &lt;FONT color=#0000ff&gt;// modify the message&lt;/FONT&gt;
&lt;/FONT&gt;&lt;/PRE&gt;&lt;BR&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Recreate the message &lt;/FONT&gt;&lt;PRE style="COLOR: #000000; BACKGROUND-COLOR: #e5e5e5"&gt;&lt;FONT size=3&gt; XmlReader newMsgReader = XmlReader.Create(&lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; StringReader(origMsgStr));
 Message newMsg = Message.CreateMessage(newMsgReader, &lt;FONT color=#2e8b57&gt;&lt;B&gt;int&lt;/B&gt;&lt;/FONT&gt;.MaxValue);
&lt;/FONT&gt;&lt;/PRE&gt;&lt;BR&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Copy over the message properties &lt;/FONT&gt;&lt;PRE style="COLOR: #000000; BACKGROUND-COLOR: #e5e5e5"&gt;&lt;FONT size=3&gt; newMsg.Properties.CopyProperties(origMsg.Properties);&lt;/FONT&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=469070" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vipulmodi/archive/tags/Indigo/default.aspx">Indigo</category></item><item><title>Making it work - Fixing the Messages - Part 2</title><link>http://blogs.msdn.com/vipulmodi/archive/2005/07/05/435822.aspx</link><pubDate>Tue, 05 Jul 2005 22:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:435822</guid><dc:creator>vipulm</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/435822.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=435822</wfw:commentRss><description>&lt;H3&gt;IProxyMessageInspector - Fixing Messages: Service Side&lt;/H3&gt;
&lt;P&gt;The article &lt;a href="http://blogs.msdn.com/vipulmodi/archive/2005/05/20/420475.aspx"&gt;"Making it work - Fixing the Messages"&lt;/A&gt; describes&amp;nbsp;how to fix the messages on the client side&amp;nbsp;while trying to Interop with an alien service that sends invalid fault messages. This article describes fixing the messages either on the client side or service side. It also describes how to add these "MessageFixers" via config using the behavior extension feature of Indigo. &lt;/P&gt;
&lt;P&gt;Just like IProxyMessageInspector that allows you to inspect and optionally modify the messages on the client side; the IStubMessageInspector allows you to inspect and optionally modify the messages on the service side. The IStubMessageInspector interface has the following methods. &lt;/P&gt;
&lt;P&gt;&lt;PRE style="COLOR: #000000; BACKGROUND-COLOR: #e5e5e5"&gt;&lt;FONT size=2&gt;    
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; AfterReceiveRequest(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message request, IProxyChannel channel, ServiceSite site);
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; BeforeSendReply(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message reply, &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; correlationState);
&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;They are self explanatory, AfterReceiveRequest allows you to fix the requests received from the client before it is processed by the Indigo runtime. The object returned from this method will be returned as "correlationState" object in the BeforeSendReply method. This allows you to correlate request and responses. The BeforeSendReply allows you to fix the replies before they are sent to the client. &lt;/P&gt;
&lt;P&gt;The IServiceBehavior implementation provides an opportunity to add message inspectors in the service processing pipeline. The easiest way to add a behavior to service or channel factory is via code as shown below. The service can have more than one endpoint. This example adds the IStubMessageInspector on all those endpoints.&lt;/P&gt;
&lt;P&gt;&lt;PRE style="COLOR: #000000; BACKGROUND-COLOR: #e5e5e5"&gt;&lt;FONT size=2&gt;  
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; ServiceMessageFixer : IServiceBehavior, IStubMessageInspector
    {
&lt;FONT color=#a020f0&gt;        #region IServiceBehavior Members&lt;/FONT&gt;

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; ApplyBehavior(ServiceDescription description, Collection&amp;lt;DispatchBehavior&amp;gt; behaviors)
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;foreach&lt;/B&gt;&lt;/FONT&gt; (DispatchBehavior dispatchBehavior &lt;FONT color=#804040&gt;&lt;B&gt;in&lt;/B&gt;&lt;/FONT&gt; behaviors)
                dispatchBehavior.MessageInspectors.Add(&lt;FONT color=#804040&gt;&lt;B&gt;this&lt;/B&gt;&lt;/FONT&gt;);
        }

&lt;FONT color=#a020f0&gt;        #endregion&lt;/FONT&gt;
&lt;/FONT&gt;
&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;H3&gt;Adding Message Fixers via Config&lt;/H3&gt;
&lt;P&gt;We add the message inspector as behavior of the channel or the service using IChannelBehavior and IServiceBehavior implementations respectively. Since the behaviors can be added via config, it is possible to add message inspector implementations via config. Hence adding message inspectors via config is same as adding custom behaviors via config. &lt;/P&gt;
&lt;P&gt;The behaviors for the services and clients are specified under the "behaviors" section in the config. These behaviors are named and are referred by the "behaviorConfiguration" attribute on the "service" element.&amp;nbsp; The named behavior element lists the behaviors and their configuration. Each config section under the behavior element is handled by a BehaviorExtensionSection. The user defined config sections are registered by listed then under the behaviorExtensions element in extensions section.&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Following is the configuration for the custom behavior config handler that instantiates and adds the specified IServiceBehavior implementation to the service. The "type" attribute on the "CustomServiceBehavior" provides the IServiceBehavior implementation.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;PRE style="COLOR: #000000; BACKGROUND-COLOR: #e5e5e5"&gt;&lt;FONT size=2&gt;  
    &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;system&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;.&lt;/FONT&gt;&lt;FONT color=#008080&gt;serviceModel&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;

        &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;services&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;service&lt;/FONT&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;serviceType&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"HelloWorld.HelloWorldService"&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;behaviorConfiguration&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"ServiceBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
                &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;endpoint&lt;/FONT&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;address&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"&lt;A href='http://localhost:8080/HelloWorld/Service"'&gt;http://localhost:8080/HelloWorld/Service"&lt;/A&gt;&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#008080&gt;                          &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;bindingSectionName&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"wsProfileBinding"&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#008080&gt;                          &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;contractType&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"HelloWorld.IHelloWorldService"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt; /&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;/service&amp;gt;&lt;/FONT&gt;
        &lt;FONT color=#008080&gt;&amp;lt;/services&amp;gt;&lt;/FONT&gt;

        &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;behaviors&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;behavior&lt;/FONT&gt;&lt;FONT color=#008080&gt;  &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;configurationName&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"ServiceBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
                &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;CustomServiceBehavior&lt;/FONT&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;type&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"MessageFixer.ServiceMessageFixer, MessageFixer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt;/&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;/behavior&amp;gt;&lt;/FONT&gt;
        &lt;FONT color=#008080&gt;&amp;lt;/behaviors&amp;gt;&lt;/FONT&gt;

        &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;extensions&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;behaviorExtensions&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
                &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;add&lt;/FONT&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;name&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"CustomServiceBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                    &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;type&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"CustomBehaviorConfig.CustomServiceBehaviorSection,CustomBehaviorConfig, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt;/&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;/behaviorExtensions&amp;gt;&lt;/FONT&gt;
        &lt;FONT color=#008080&gt;&amp;lt;/extensions&amp;gt;&lt;/FONT&gt;

    &lt;FONT color=#008080&gt;&amp;lt;/system&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;.&lt;/FONT&gt;&lt;FONT color=#008080&gt;serviceModel&amp;gt;&lt;/FONT&gt;
&lt;/FONT&gt;
&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;The Complete Example &lt;/H3&gt;
&lt;P&gt;The following sample demonstrate the implementation of IProxyMessageInspector, IStubMessageInspector for fixing the messages on the client side and service side respectively via code and config. The MessageFixer classes should be compiled in to the MessageFixer.dll assembly and the BehaviorConfig classes should be compiled in to CustomBehaviorConfig.dll assembly, as the App.config file for HelloWorld program that demonstrate the use of these message fixers uses these assembly names. Please do send your feedback!&lt;/P&gt;
&lt;H4&gt;Message Fixer Classes&amp;nbsp;&amp;nbsp; - MessageFixer.dll &lt;/H4&gt;
&lt;P&gt;&lt;PRE style="COLOR: #000000; BACKGROUND-COLOR: #e5e5e5"&gt;&lt;FONT size=2&gt;&lt;B&gt;ClientMessageFixer.cs&lt;/B&gt;      
      
&lt;FONT color=#0000ff&gt;// Copyright Notice &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;// Use of this sample code is subject to the terms specified at &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;// &lt;A href="http://www.microsoft.com/info/cpyright.htm"&gt;http://www.microsoft.com/info/cpyright.htm&lt;/A&gt;&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;

&lt;FONT color=#2e8b57&gt;&lt;B&gt;namespace&lt;/B&gt;&lt;/FONT&gt; MessageFixer
{
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.Xml;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.ServiceModel;

    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; ClientMessageFixer : IChannelBehavior, IProxyMessageInspector
    {
&lt;FONT color=#a020f0&gt;        #region IChannelBehavior Members&lt;/FONT&gt;

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; ApplyBehavior(ChannelDescription description, ProxyBehavior behavior)
        {
            behavior.MessageInspectors.Add(&lt;FONT color=#804040&gt;&lt;B&gt;this&lt;/B&gt;&lt;/FONT&gt;);
        }

&lt;FONT color=#a020f0&gt;        #endregion&lt;/FONT&gt;

&lt;FONT color=#a020f0&gt;        #region IProxyMessageInspector Members&lt;/FONT&gt;


        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; BeforeSendRequest(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message request, IProxyChannel channel)
        {
            &lt;FONT color=#0000ff&gt;// Decide if you need to fix the request&lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;// if "I need to fix the message" &lt;/FONT&gt;
            {
                &lt;FONT color=#0000ff&gt;// Fix the request&lt;/FONT&gt;
                XmlDocument doc = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlDocument();
                doc.Load(request.GetBodyReader());

                &lt;FONT color=#0000ff&gt;// Perform the modification&lt;/FONT&gt;
                FixRequestMessage(doc);

                &lt;FONT color=#0000ff&gt;// Create new message&lt;/FONT&gt;
                XmlNodeReader reader = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlNodeReader(doc.DocumentElement);
                Message newMsg = Message.CreateMessage(request.Version,
                    &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;, reader);

                &lt;FONT color=#0000ff&gt;// Preserve the headers of the original message&lt;/FONT&gt;
                newMsg.Headers.CopyHeadersFrom(request);

                &lt;FONT color=#804040&gt;&lt;B&gt;foreach&lt;/B&gt;&lt;/FONT&gt; (&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; propertyKey &lt;FONT color=#804040&gt;&lt;B&gt;in&lt;/B&gt;&lt;/FONT&gt; request.Properties.Keys)
                    newMsg.Properties.Add(propertyKey, request.Properties[propertyKey]);

                &lt;FONT color=#0000ff&gt;// Close the original message and return new message&lt;/FONT&gt;
                request.Close();
                request = newMsg;
            }
            &lt;FONT color=#0000ff&gt;// end if - "I need to fix the message"&lt;/FONT&gt;

            &lt;FONT color=#0000ff&gt;// The returned value can be used for request-reply correlation.&lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;// The return object from this method will be supplied as the &lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;// correlationState parameter of the AfterReceiveReply method. &lt;/FONT&gt;
            &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;;
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; AfterReceiveReply(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message reply, &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; correlationState)
        {
            &lt;FONT color=#0000ff&gt;// Decide if you need to fix the reply&lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;// if "I need to fix the message" &lt;/FONT&gt;
            {
                &lt;FONT color=#0000ff&gt;// Fix the reply&lt;/FONT&gt;
                XmlDocument doc = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlDocument();
                doc.Load(reply.GetBodyReader());

                &lt;FONT color=#0000ff&gt;// Perform the modification&lt;/FONT&gt;
                FixReplyMessage(doc);

                &lt;FONT color=#0000ff&gt;// Create new message&lt;/FONT&gt;
                XmlNodeReader reader = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlNodeReader(doc.DocumentElement);
                Message newMsg = Message.CreateMessage(reply.Version,
                    &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;, reader);

                &lt;FONT color=#804040&gt;&lt;B&gt;if&lt;/B&gt;&lt;/FONT&gt; (reply.IsFault)
                {
                    MessageFault fault = MessageFault.CreateFault(newMsg);
                    newMsg.Close();

                    newMsg = Message.CreateMessage(reply.Version, fault,
                        &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;);
                }

                &lt;FONT color=#0000ff&gt;// Preserve the headers of the original message&lt;/FONT&gt;
                newMsg.Headers.CopyHeadersFrom(reply);

                &lt;FONT color=#804040&gt;&lt;B&gt;foreach&lt;/B&gt;&lt;/FONT&gt; (&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; propertyKey &lt;FONT color=#804040&gt;&lt;B&gt;in&lt;/B&gt;&lt;/FONT&gt; reply.Properties.Keys)
                    newMsg.Properties.Add(propertyKey, reply.Properties[propertyKey]);

                &lt;FONT color=#0000ff&gt;// Close the original message and return new message&lt;/FONT&gt;
                reply.Close();
                reply = newMsg;

            }

            &lt;FONT color=#0000ff&gt;// end if - "I need to fix the message"&lt;/FONT&gt;
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;private&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; FixRequestMessage(XmlDocument doc)
        {
            &lt;FONT color=#0000ff&gt;// Fix the request message here.&lt;/FONT&gt;
            Console.WriteLine(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"Fixing the request to be sent to the server."&lt;/FONT&gt;&lt;/SPAN&gt;);
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;private&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; FixReplyMessage(XmlDocument doc)
        {
            &lt;FONT color=#0000ff&gt;// Fix the reply message here.&lt;/FONT&gt;
            Console.WriteLine(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"Fixing the reply received from the server."&lt;/FONT&gt;&lt;/SPAN&gt;);
        }

&lt;FONT color=#a020f0&gt;        #endregion&lt;/FONT&gt;
    }
}

&lt;B&gt;ServiceMessageFixer.cs&lt;/B&gt;

&lt;FONT color=#0000ff&gt;// Copyright Notice &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;// Use of this sample code is subject to the terms specified at &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;// &lt;A href="http://www.microsoft.com/info/cpyright.htm"&gt;http://www.microsoft.com/info/cpyright.htm&lt;/A&gt;&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;

&lt;FONT color=#2e8b57&gt;&lt;B&gt;namespace&lt;/B&gt;&lt;/FONT&gt; MessageFixer
{
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.Xml;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.ServiceModel;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.Collections.ObjectModel;

    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; ServiceMessageFixer : IServiceBehavior, IStubMessageInspector
    {
&lt;FONT color=#a020f0&gt;        #region IServiceBehavior Members&lt;/FONT&gt;

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; ApplyBehavior(ServiceDescription description, Collection&amp;lt;DispatchBehavior&amp;gt; behaviors)
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;foreach&lt;/B&gt;&lt;/FONT&gt; (DispatchBehavior dispatchBehavior &lt;FONT color=#804040&gt;&lt;B&gt;in&lt;/B&gt;&lt;/FONT&gt; behaviors)
                dispatchBehavior.MessageInspectors.Add(&lt;FONT color=#804040&gt;&lt;B&gt;this&lt;/B&gt;&lt;/FONT&gt;);
        }

&lt;FONT color=#a020f0&gt;        #endregion&lt;/FONT&gt;

&lt;FONT color=#a020f0&gt;        #region IStubMessageInspector Members&lt;/FONT&gt;

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; AfterReceiveRequest(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message request, IProxyChannel channel, ServiceSite site)
        {
            &lt;FONT color=#0000ff&gt;// Decide if you need to fix the request&lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;// if "I need to fix the message" &lt;/FONT&gt;
            {
                &lt;FONT color=#0000ff&gt;// Fix the request&lt;/FONT&gt;
                XmlDocument doc = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlDocument();
                doc.Load(request.GetBodyReader());

                &lt;FONT color=#0000ff&gt;// Perform the modification&lt;/FONT&gt;
                FixRequestMessage(doc);

                &lt;FONT color=#0000ff&gt;// Create new message&lt;/FONT&gt;
                XmlNodeReader reader = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlNodeReader(doc.DocumentElement);
                Message newMsg = Message.CreateMessage(request.Version,
                    &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;, reader);

                &lt;FONT color=#0000ff&gt;// Preserve the headers of the original message&lt;/FONT&gt;
                newMsg.Headers.CopyHeadersFrom(request);

                &lt;FONT color=#804040&gt;&lt;B&gt;foreach&lt;/B&gt;&lt;/FONT&gt; (&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; propertyKey &lt;FONT color=#804040&gt;&lt;B&gt;in&lt;/B&gt;&lt;/FONT&gt; request.Properties.Keys)
                    newMsg.Properties.Add(propertyKey, request.Properties[propertyKey]);

                &lt;FONT color=#0000ff&gt;// Close the original message and return new message&lt;/FONT&gt;
                request.Close();
                request = newMsg;
            }
            &lt;FONT color=#0000ff&gt;// end if - "I need to fix the message"&lt;/FONT&gt;

            &lt;FONT color=#0000ff&gt;// The returned value can be used for request-reply correlation.&lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;// The return object from this method will be supplied as the &lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;// correlationState parameter of the BeforeSendReply method. &lt;/FONT&gt;
            &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;;
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; BeforeSendReply(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message reply, &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; correlationState)
        {
            &lt;FONT color=#0000ff&gt;// Decide if you need to fix the reply&lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;// if "I need to fix the message" &lt;/FONT&gt;
            {
                &lt;FONT color=#0000ff&gt;// Fix the reply&lt;/FONT&gt;
                XmlDocument doc = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlDocument();
                doc.Load(reply.GetBodyReader());

                &lt;FONT color=#0000ff&gt;// Perform the modification&lt;/FONT&gt;
                FixReplyMessage(doc);

                &lt;FONT color=#0000ff&gt;// Create new message&lt;/FONT&gt;
                XmlNodeReader reader = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlNodeReader(doc.DocumentElement);
                Message newMsg = Message.CreateMessage(reply.Version,
                    &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;, reader);

                &lt;FONT color=#804040&gt;&lt;B&gt;if&lt;/B&gt;&lt;/FONT&gt; (reply.IsFault)
                {
                    MessageFault fault = MessageFault.CreateFault(newMsg);
                    newMsg.Close();

                    newMsg = Message.CreateMessage(reply.Version, fault,
                        &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;);

                    Console.WriteLine(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"It is a fault !!!!!"&lt;/FONT&gt;&lt;/SPAN&gt;);
                }

                &lt;FONT color=#0000ff&gt;// Preserve the headers of the original message&lt;/FONT&gt;
                newMsg.Headers.CopyHeadersFrom(reply);

                &lt;FONT color=#804040&gt;&lt;B&gt;foreach&lt;/B&gt;&lt;/FONT&gt; (&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; propertyKey &lt;FONT color=#804040&gt;&lt;B&gt;in&lt;/B&gt;&lt;/FONT&gt; reply.Properties.Keys)
                    newMsg.Properties.Add(propertyKey, reply.Properties[propertyKey]);

                &lt;FONT color=#0000ff&gt;// Close the original message and return new message&lt;/FONT&gt;
                reply.Close();
                reply = newMsg;

            }

            &lt;FONT color=#0000ff&gt;// end if - "I need to fix the message"&lt;/FONT&gt;
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;private&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; FixRequestMessage(XmlDocument doc)
        {
            &lt;FONT color=#0000ff&gt;// Fix the request message here.&lt;/FONT&gt;
            Console.WriteLine(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"Fixing the request received from the client."&lt;/FONT&gt;&lt;/SPAN&gt;);
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;private&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; FixReplyMessage(XmlDocument doc)
        {
            &lt;FONT color=#0000ff&gt;// Fix the reply message here.&lt;/FONT&gt;
            Console.WriteLine(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"Fixing the reply to be sent to the client."&lt;/FONT&gt;&lt;/SPAN&gt;);
        }

&lt;FONT color=#a020f0&gt;        #endregion&lt;/FONT&gt;
    }
}

&lt;B&gt;AssemblyInfo.cs&lt;/B&gt;

&lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.Reflection;

[assembly: AssemblyCulture(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;""&lt;/FONT&gt;&lt;/SPAN&gt;)]
[assembly: AssemblyVersion(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"1.0.0.0"&lt;/FONT&gt;&lt;/SPAN&gt;)]
[assembly: AssemblyFileVersion(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"1.0.0.0"&lt;/FONT&gt;&lt;/SPAN&gt;)]
&lt;/FONT&gt;
&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;H4&gt;Custom Config Classes&amp;nbsp;&amp;nbsp; - CustomBehaviorConfig.dll &lt;/H4&gt;
&lt;P&gt;&lt;PRE style="COLOR: #000000; BACKGROUND-COLOR: #e5e5e5"&gt;&lt;FONT size=2&gt;
&lt;B&gt;CustomClientBehaviorSection.cs&lt;/B&gt;

&lt;FONT color=#0000ff&gt;// Copyright Notice &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;// Use of this sample code is subject to the terms specified at &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;// &lt;A href="http://www.microsoft.com/info/cpyright.htm"&gt;http://www.microsoft.com/info/cpyright.htm&lt;/A&gt;&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;

&lt;FONT color=#2e8b57&gt;&lt;B&gt;namespace&lt;/B&gt;&lt;/FONT&gt; CustomBehaviorConfig
{
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.Configuration;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.ServiceModel;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.ServiceModel.Configuration;

    &lt;FONT color=#0000ff&gt;///&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#804040&gt;&lt;B&gt;summary&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
    &lt;FONT color=#0000ff&gt;///&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Adds the custom behavior to the client. &lt;/FONT&gt;
    &lt;FONT color=#0000ff&gt;///&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#804040&gt;&lt;B&gt;summary&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; CustomClientBehaviorSection : BehaviorExtensionSection
    {
        [ConfigurationProperty(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"type"&lt;/FONT&gt;&lt;/SPAN&gt;)]
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; TypeName
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;get&lt;/B&gt;&lt;/FONT&gt;
            {
                &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; (&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt;)&lt;FONT color=#804040&gt;&lt;B&gt;base&lt;/B&gt;&lt;/FONT&gt;[&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"type"&lt;/FONT&gt;&lt;/SPAN&gt;];
            }
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;protected&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;override&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; CreateBehavior()
        {
            &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; behavior = &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;;

            &lt;FONT color=#804040&gt;&lt;B&gt;if&lt;/B&gt;&lt;/FONT&gt; ((&lt;FONT color=#804040&gt;&lt;B&gt;this&lt;/B&gt;&lt;/FONT&gt;.TypeName != &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;) &amp;amp;&amp;amp; (&lt;FONT color=#804040&gt;&lt;B&gt;this&lt;/B&gt;&lt;/FONT&gt;.TypeName.Trim().Length &amp;gt; &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;0&lt;/FONT&gt;&lt;/SPAN&gt;))
            {
                Type channelBehaviorImplType = Type.GetType(&lt;FONT color=#804040&gt;&lt;B&gt;this&lt;/B&gt;&lt;/FONT&gt;.TypeName, &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;true&lt;/FONT&gt;&lt;/SPAN&gt;);
                &lt;FONT color=#804040&gt;&lt;B&gt;if&lt;/B&gt;&lt;/FONT&gt; (&lt;FONT color=#804040&gt;&lt;B&gt;typeof&lt;/B&gt;&lt;/FONT&gt;(IChannelBehavior).IsAssignableFrom(channelBehaviorImplType))
                {
                    behavior = Activator.CreateInstance(channelBehaviorImplType);
                }
            }

            &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; behavior;
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;override&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; ConfiguredSectionName
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;get&lt;/B&gt;&lt;/FONT&gt; { &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"CustomClientBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;; }
        }
    }
}

&lt;B&gt;CustomServiceBehaviorSection.cs&lt;/B&gt;

&lt;FONT color=#0000ff&gt;// Copyright Notice &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;// Use of this sample code is subject to the terms specified at &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;// &lt;A href="http://www.microsoft.com/info/cpyright.htm"&gt;http://www.microsoft.com/info/cpyright.htm&lt;/A&gt;&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;

&lt;FONT color=#2e8b57&gt;&lt;B&gt;namespace&lt;/B&gt;&lt;/FONT&gt; CustomBehaviorConfig
{
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.Configuration;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.ServiceModel;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.ServiceModel.Configuration;

    &lt;FONT color=#0000ff&gt;///&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#804040&gt;&lt;B&gt;summary&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
    &lt;FONT color=#0000ff&gt;///&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Adds the custom behavior to the service. &lt;/FONT&gt;
    &lt;FONT color=#0000ff&gt;///&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#804040&gt;&lt;B&gt;summary&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; CustomServiceBehaviorSection : BehaviorExtensionSection
    {
        [ConfigurationProperty(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"type"&lt;/FONT&gt;&lt;/SPAN&gt;)]
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; TypeName
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;get&lt;/B&gt;&lt;/FONT&gt;
            {
                &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; (&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt;)&lt;FONT color=#804040&gt;&lt;B&gt;base&lt;/B&gt;&lt;/FONT&gt;[&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"type"&lt;/FONT&gt;&lt;/SPAN&gt;];
            }
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;protected&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;override&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; CreateBehavior()
        {
            &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; behavior = &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;;

            &lt;FONT color=#804040&gt;&lt;B&gt;if&lt;/B&gt;&lt;/FONT&gt; ((&lt;FONT color=#804040&gt;&lt;B&gt;this&lt;/B&gt;&lt;/FONT&gt;.TypeName != &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;) &amp;amp;&amp;amp; (&lt;FONT color=#804040&gt;&lt;B&gt;this&lt;/B&gt;&lt;/FONT&gt;.TypeName.Trim().Length &amp;gt; &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;0&lt;/FONT&gt;&lt;/SPAN&gt;))
            {
                Type serviceBehaviorImplType = Type.GetType(&lt;FONT color=#804040&gt;&lt;B&gt;this&lt;/B&gt;&lt;/FONT&gt;.TypeName, &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;true&lt;/FONT&gt;&lt;/SPAN&gt;);
                &lt;FONT color=#804040&gt;&lt;B&gt;if&lt;/B&gt;&lt;/FONT&gt; (&lt;FONT color=#804040&gt;&lt;B&gt;typeof&lt;/B&gt;&lt;/FONT&gt;(IServiceBehavior).IsAssignableFrom(serviceBehaviorImplType))
                {
                    behavior = Activator.CreateInstance(serviceBehaviorImplType);
                }
            }

            &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; behavior;
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;override&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; ConfiguredSectionName
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;get&lt;/B&gt;&lt;/FONT&gt; { &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"CustomServiceBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;; }
        }
    }
}

&lt;B&gt;AssemblyInfo.cs&lt;/B&gt;

&lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.Reflection;

[assembly: AssemblyCulture(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;""&lt;/FONT&gt;&lt;/SPAN&gt;)]
[assembly: AssemblyVersion(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"1.0.0.0"&lt;/FONT&gt;&lt;/SPAN&gt;)]
[assembly: AssemblyFileVersion(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"1.0.0.0"&lt;/FONT&gt;&lt;/SPAN&gt;)]

&lt;/FONT&gt;
&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;H4&gt;HelloWorld Sample using MessageFixers &lt;/H4&gt;
&lt;P&gt;&lt;PRE style="COLOR: #000000; BACKGROUND-COLOR: #e5e5e5"&gt;&lt;FONT size=2&gt;
&lt;B&gt;HelloWorld.cs&lt;/B&gt;

&lt;FONT color=#0000ff&gt;// Copyright Notice &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;// Use of this sample code is subject to the terms specified at &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;// &lt;A href="http://www.microsoft.com/info/cpyright.htm"&gt;http://www.microsoft.com/info/cpyright.htm&lt;/A&gt;&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;//&lt;/FONT&gt;

&lt;FONT color=#2e8b57&gt;&lt;B&gt;namespace&lt;/B&gt;&lt;/FONT&gt; HelloWorld
{
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.Collections.ObjectModel;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.Xml;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.ServiceModel;

    [ServiceContract]
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;interface&lt;/B&gt;&lt;/FONT&gt; IHelloWorldService
    {
        [OperationContract]
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; Greetings(&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; name);
    }

    [ServiceBehavior]
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; HelloWorldService : IHelloWorldService
    {
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; Greetings(&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; name)
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; &lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"Hello "&lt;/FONT&gt;&lt;/SPAN&gt; + name;
        }
    }

    &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; Program
    {
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;static&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; Main(&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt;[] args)
        {
            StartService();
            StartClient();

            Console.WriteLine(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#6a5acd&gt;\n&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;Press Enter to exit."&lt;/FONT&gt;&lt;/SPAN&gt;);
            Console.ReadLine();
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;private&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;static&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; StartService()
        {
            HelloWorldService serviceObj = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; HelloWorldService();
            ServiceHost&amp;lt;HelloWorldService&amp;gt; serviceHost =
                &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; ServiceHost&amp;lt;HelloWorldService&amp;gt;();

            &lt;FONT color=#0000ff&gt;// Uncomment the following line to add the ServiceMessageFixer via code&lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;// serviceHost.Description.Behaviors.Add(new MessageFixer.ServiceMessageFixer());&lt;/FONT&gt;

            serviceHost.Open();

            Console.WriteLine(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"HelloWorldService is ready"&lt;/FONT&gt;&lt;/SPAN&gt;);
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;private&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;static&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; StartClient()
        {
            Console.WriteLine(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"Connecting the HelloWorld server."&lt;/FONT&gt;&lt;/SPAN&gt;);

            ChannelFactory&amp;lt;IHelloWorldService&amp;gt; factory =
                &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; ChannelFactory&amp;lt;IHelloWorldService&amp;gt;(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"HelloWorldClientConfig"&lt;/FONT&gt;&lt;/SPAN&gt;);

            &lt;FONT color=#0000ff&gt;// Uncomment the following line to add ClientMessageFixer via code &lt;/FONT&gt;
            &lt;FONT color=#0000ff&gt;// factory.Description.Behaviors.Add(new MessageFixer.ClientMessageFixer());&lt;/FONT&gt;
            IHelloWorldService proxy = factory.CreateChannel();

            Console.WriteLine(proxy.Greetings(&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"Indigo Developer!"&lt;/FONT&gt;&lt;/SPAN&gt;));
            factory.Close();
        }
    }
}

&lt;B&gt;App.config&lt;/B&gt;

&lt;FONT color=#0000ff&gt;&amp;lt;?&lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;xml&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt; &lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;version&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"1.0"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt; &lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;encoding&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"utf-8"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt; &lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;?&amp;gt;&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;lt;!&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;-- &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;    Copyright Notice &lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;    Use of this sample code is subject to the terms specified at &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;    &lt;A href="http://www.microsoft.com/info/cpyright.htm"&gt;http://www.microsoft.com/info/cpyright.htm&lt;/A&gt;&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;--&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;
&lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;configuration&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
    &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;system&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;.&lt;/FONT&gt;&lt;FONT color=#008080&gt;serviceModel&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;

        &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;services&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;service&lt;/FONT&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;serviceType&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"HelloWorld.HelloWorldService"&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;behaviorConfiguration&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"ServiceBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
                &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;endpoint&lt;/FONT&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;address&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"&lt;A href='http://localhost:8080/HelloWorld/Service"'&gt;http://localhost:8080/HelloWorld/Service"&lt;/A&gt;&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#008080&gt;                          &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;bindingSectionName&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"wsProfileBinding"&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#008080&gt;                          &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;contractType&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"HelloWorld.IHelloWorldService"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt; /&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;/service&amp;gt;&lt;/FONT&gt;
        &lt;FONT color=#008080&gt;&amp;lt;/services&amp;gt;&lt;/FONT&gt;

        &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;client&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;endpoint&lt;/FONT&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;configurationName&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"HelloWorldClientConfig"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;address&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"&lt;A href='http://localhost:8080/HelloWorld/Service"'&gt;http://localhost:8080/HelloWorld/Service"&lt;/A&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;bindingSectionName&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"wsProfileBinding"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;contractType&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"HelloWorld.IHelloWorldService"&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;behaviorConfiguration&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"ClientBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;FONT color=#008080&gt;            /&amp;gt;&lt;/FONT&gt;
        &lt;FONT color=#008080&gt;&amp;lt;/client&amp;gt;&lt;/FONT&gt;

        &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;behaviors&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;behavior&lt;/FONT&gt;&lt;FONT color=#008080&gt;  &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;configurationName&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"ServiceBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
                &lt;FONT color=#0000ff&gt;&amp;lt;!&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;-- Uncomment the following line to add the ServiceMessageFixer via config. --&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;
                &lt;FONT color=#0000ff&gt;&amp;lt;!&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;-- &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;                &amp;lt;CustomServiceBehavior type="MessageFixer.ServiceMessageFixer, MessageFixer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/&amp;gt;&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;                --&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;/behavior&amp;gt;&lt;/FONT&gt;

            &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;behavior&lt;/FONT&gt;&lt;FONT color=#008080&gt;  &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;configurationName&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"ClientBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
                &lt;FONT color=#0000ff&gt;&amp;lt;!&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;-- Uncomment the following line to add the ClientMessageFixer via config. --&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;
                &lt;FONT color=#0000ff&gt;&amp;lt;!&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;-- &lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;                &amp;lt;CustomClientBehavior type="MessageFixer.ClientMessageFixer, MessageFixer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/&amp;gt;&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;                --&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;/behavior&amp;gt;&lt;/FONT&gt;
        &lt;FONT color=#008080&gt;&amp;lt;/behaviors&amp;gt;&lt;/FONT&gt;

        &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;extensions&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;behaviorExtensions&lt;/FONT&gt;&lt;FONT color=#008080&gt;&amp;gt;&lt;/FONT&gt;
                &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;add&lt;/FONT&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;name&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"CustomServiceBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                    &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;type&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"CustomBehaviorConfig.CustomServiceBehaviorSection,CustomBehaviorConfig, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt;/&amp;gt;&lt;/FONT&gt;

                &lt;FONT color=#008080&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;add&lt;/FONT&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;name&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"CustomClientBehavior"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt; &lt;/FONT&gt;
&lt;FONT color=#008080&gt;                &lt;/FONT&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;type&lt;/B&gt;&lt;/FONT&gt;=&lt;SPAN style="BACKGROUND-COLOR: #f2f2f2"&gt;&lt;FONT color=#ff00ff&gt;"CustomBehaviorConfig.CustomClientBehaviorSection,CustomBehaviorConfig, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color=#008080&gt;/&amp;gt;&lt;/FONT&gt;
            &lt;FONT color=#008080&gt;&amp;lt;/behaviorExtensions&amp;gt;&lt;/FONT&gt;
        &lt;FONT color=#008080&gt;&amp;lt;/extensions&amp;gt;&lt;/FONT&gt;

    &lt;FONT color=#008080&gt;&amp;lt;/system&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;.&lt;/FONT&gt;&lt;FONT color=#008080&gt;serviceModel&amp;gt;&lt;/FONT&gt;
&lt;FONT color=#008080&gt;&amp;lt;/configuration&amp;gt;&lt;/FONT&gt;

&lt;/FONT&gt;
&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at &lt;A href="http://www.microsoft.com/info/cpyright.htm" target=_blank&gt;http://www.microsoft.com/info/cpyright.htm&lt;/A&gt;. &lt;/I&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=435822" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vipulmodi/archive/tags/Indigo/default.aspx">Indigo</category></item><item><title>Making it work - Fixing the Messages</title><link>http://blogs.msdn.com/vipulmodi/archive/2005/05/20/420475.aspx</link><pubDate>Fri, 20 May 2005 16:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:420475</guid><dc:creator>vipulm</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/420475.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=420475</wfw:commentRss><description>&lt;P&gt;Indigo provides great interoperability with various web services stacks. However one or the other time you will encounter an implementation that in certain scenario either produces or accepts invalid messages. For example, messages which are not complaint with SOAP schema. In such situations Indigo will do the right thing and reject the message. What if you don’t want to reject the message and want to Interop with the invalid implementation! What should you do?&lt;/P&gt;
&lt;P&gt;How about fixing the invalid message before sending or receiving on the Indigo side? That sound neat, but how can you do such a thing? Let's explore from the client side. As a client you want to fix the request before sending it to the alien service and/or fix the response received from the alien service. The IProxyMessageInspector is the way to go. The MessageInspector in Indigo allows you to inspect and optionally modify the messages generated by runtime or consumed by runtime. The IProxyMessageInspector is a client side message inspector that has following methods&lt;/P&gt;
&lt;P&gt;&lt;PRE&gt;&lt;FONT size=3&gt;    
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; BeforeSendRequest(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message request, IProxyChannel channel);
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; AfterReceiveReply(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message reply, &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; correlationState);
&lt;/FONT&gt;
&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;They are self explanatory, BeforeSendRequest allows you to fix the requests before sending them and AfterReceieveReply allow you to fix the reply before it is processed by the Indigo runtime. For example consider trying to Interop with an alien service that sends invalid fault messages, the fault messages that are not complaint with SOAP schema. We want the Indigo runtime to process these faults and return appropriate faults to our client application. Following is the simple implementation of AfterReceiveReply that achieves the purpose. The FixMessage method performs the required modification on the message. This implementation works fine for simple fixes on small messages.&lt;/P&gt;
&lt;P&gt;&lt;PRE&gt;&lt;FONT size=3&gt;    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; FaultFixer : IProxyMessageInspector
    {
&lt;FONT color=#a020f0&gt;        #region IProxyMessageInspector Members&lt;/FONT&gt;

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; AfterReceiveReply(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message reply, &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; correlationState)
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;if&lt;/B&gt;&lt;/FONT&gt; (reply.IsFault)
            {
                &lt;FONT color=#0000ff&gt;// Load the reply message in DOM for easier modification&lt;/FONT&gt;
                XmlDocument doc = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlDocument();
                doc.Load(reply.GetBodyReader());

                &lt;FONT color=#0000ff&gt;// Perform the modification&lt;/FONT&gt;
                FixMessage(doc);

                &lt;FONT color=#0000ff&gt;// Create new message&lt;/FONT&gt;
                XmlNodeReader reader = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlNodeReader(doc.DocumentElement);
                Message tempMsg = Message.CreateMessage(reply.Version,
                    reply.Headers.Action, reader);
                MessageFault fault = MessageFault.CreateFault(tempMsg);
                tempMsg.Close();

                Message newMsg = Message.CreateMessage(reply.Version, fault,
                    reply.Headers.Action);

                &lt;FONT color=#0000ff&gt;// Preserve the headers of the original message&lt;/FONT&gt;
                newMsg.Headers.CopyHeadersFrom(reply);

                &lt;FONT color=#804040&gt;&lt;B&gt;foreach&lt;/B&gt;&lt;/FONT&gt;(&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; propertyKey &lt;FONT color=#804040&gt;&lt;B&gt;in&lt;/B&gt;&lt;/FONT&gt; reply.Properties.Keys)
                    newMsg.Properties.Add(propertyKey, reply.Properties[propertyKey]);

                &lt;FONT color=#0000ff&gt;// Close the original message and return new message&lt;/FONT&gt;
                reply.Close();
                reply = newMsg;
            }
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;private&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; FixMessage(XmlDocument doc)
        {
            &lt;FONT color=#0000ff&gt;// Fix the fault message here.&lt;/FONT&gt;
            Console.WriteLine(&lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;"Fixing the fault received from the alien service .."&lt;/FONT&gt;&lt;/SPAN&gt;);
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; BeforeSendRequest(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message request, IProxyChannel channel)
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; &lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;;
        }

&lt;FONT color=#a020f0&gt;        #endregion&lt;/FONT&gt;
    }
&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;We now have the code that fixes the replies from the alien service, but how can we bring this code to life? We must hook it up to the message processing pipeline of Indigo. There are few ways of doing this; however the easiest one is to do it imperatively in code. We add the IChannelBehavior implementation to the contract description. When the runtime is created, the ApplyBehavior method of IChannelBehavior implementation will be called, giving us the opportunity to modify the behavior of the created proxy. We add our IMessageInspector implementation to the proxy behavior. &amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;PRE&gt;&lt;FONT color=#2e8b57&gt;&lt;B&gt;&lt;FONT size=3&gt;public&lt;/FONT&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;FONT size=3&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; FaultFixerCreator : IChannelBehavior
{
&lt;FONT color=#a020f0&gt;    #region IChannelBehavior Members&lt;/FONT&gt;

    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; ApplyBehavior(ChannelDescription description, ProxyBehavior behavior)
    {
        behavior.MessageInspectors.Add(&lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; FaultFixer());
    }

&lt;FONT color=#a020f0&gt;    #endregion&lt;/FONT&gt;
}&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;As mentioned above we add our FaultFixerCreator to the contract description of the channel factory.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;PRE&gt;&lt;FONT size=3&gt;
    proxy.ChannelFactory.Description.Behaviors.Add(&lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; FaultFixerCreator());
    &lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;We are done, from now on whenever a fault message is sent from the alien service; our code in the FaultFixer will be invoked. Following is the complete implementation. I have combined the implementation of IChannelBehavior in the FaultFixer thus avoiding the need for additional FaultFixerCreator class. &lt;BR&gt;&lt;BR&gt;In the future posting we will learn about fixing the messages on the server side as well as fixing the messages on the client side for DuplexContract. Do send me your feedback!&lt;/P&gt;&lt;PRE&gt;&lt;FONT size=3&gt;
&lt;FONT color=#2e8b57&gt;&lt;B&gt;namespace&lt;/B&gt;&lt;/FONT&gt; HelloWorld
{
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.Xml;
    &lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System.ServiceModel;

    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; Constants
    {
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;const&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; Address = &lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;"&lt;A href='http://localhost:8089/HelloWorld/Server"'&gt;http://localhost:8089/HelloWorld/Server"&lt;/A&gt;&lt;/FONT&gt;&lt;/SPAN&gt;;
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;static&lt;/B&gt;&lt;/FONT&gt; Binding binding;
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;static&lt;/B&gt;&lt;/FONT&gt; Constants()
        {
            binding = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; WSProfileBinding();
        }
    }

    [ServiceContract]
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;interface&lt;/B&gt;&lt;/FONT&gt; IHelloWorldService
    {
        [OperationContract]
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; Greetings(&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; name);
    }


    [ServiceBehavior(ReturnUnknownExceptionsAsFaults = &lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;true&lt;/FONT&gt;&lt;/SPAN&gt;)]
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; HelloWorldService : IHelloWorldService
    {
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; Greetings(&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; name)
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;throw&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; ApplicationException(&lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;"Just like that!"&lt;/FONT&gt;&lt;/SPAN&gt;);
        }
    }

    &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; Program
    {
        &lt;FONT color=#2e8b57&gt;&lt;B&gt;static&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; Main(&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt;[] args)
        {
            StartService();
            StartClient();

            Console.WriteLine(&lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;"&lt;/FONT&gt;&lt;FONT color=#6a5acd&gt;\n&lt;/FONT&gt;&lt;FONT color=#ff00ff&gt;Press Enter to exit."&lt;/FONT&gt;&lt;/SPAN&gt;);
            Console.ReadLine();
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;private&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;static&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; StartService()
        {
            HelloWorldService serviceObj = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; HelloWorldService();
            ServiceHost&amp;lt;HelloWorldService&amp;gt; serviceHost = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; ServiceHost&amp;lt;HelloWorldService&amp;gt;(
                    &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; Uri(Constants.Address));
            serviceHost.AddEndpoint(&lt;FONT color=#804040&gt;&lt;B&gt;typeof&lt;/B&gt;&lt;/FONT&gt;(IHelloWorldService), Constants.binding);
            serviceHost.Open();
            Console.WriteLine(&lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;"HelloWorldService is ready"&lt;/FONT&gt;&lt;/SPAN&gt;);
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;private&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;static&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; StartClient()
        {
            Console.WriteLine(&lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;"Connecting to server at "&lt;/FONT&gt;&lt;/SPAN&gt; + Constants.Address);

            ChannelFactory&amp;lt;IHelloWorldService&amp;gt; factory = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; ChannelFactory&amp;lt;IHelloWorldService&amp;gt;(
                &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; Uri(Constants.Address), Constants.binding);

            &lt;FONT color=#0000ff&gt;// Add the fault fixer&lt;/FONT&gt;
            factory.Description.Behaviors.Add(&lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; FaultFixer());

            IHelloWorldService proxy = factory.CreateChannel();

            Console.WriteLine(proxy.Greetings(&lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;"Indigo Developer!"&lt;/FONT&gt;&lt;/SPAN&gt;));
            factory.Close();
        }
    }

    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; FaultFixer : IChannelBehavior, IProxyMessageInspector
    {
&lt;FONT color=#a020f0&gt;        #region IChannelBehavior Members&lt;/FONT&gt;

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; ApplyBehavior(ChannelDescription description, ProxyBehavior behavior)
        {
            behavior.MessageInspectors.Add(&lt;FONT color=#804040&gt;&lt;B&gt;this&lt;/B&gt;&lt;/FONT&gt;);
        }

&lt;FONT color=#a020f0&gt;        #endregion&lt;/FONT&gt;

&lt;FONT color=#a020f0&gt;        #region IProxyMessageInspector Members&lt;/FONT&gt;

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; AfterReceiveReply(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message reply, &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; correlationState)
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;if&lt;/B&gt;&lt;/FONT&gt; (reply.IsFault)
            {
                &lt;FONT color=#0000ff&gt;// Load the reply message in DOM for easier modification&lt;/FONT&gt;
                XmlDocument doc = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlDocument();
                doc.Load(reply.GetBodyReader());

                &lt;FONT color=#0000ff&gt;// Perform the modification&lt;/FONT&gt;
                FixMessage(doc);

                &lt;FONT color=#0000ff&gt;// Create new message&lt;/FONT&gt;
                XmlNodeReader reader = &lt;FONT color=#804040&gt;&lt;B&gt;new&lt;/B&gt;&lt;/FONT&gt; XmlNodeReader(doc.DocumentElement);
                Message newMsg = Message.CreateMessage(reply.Version,
                    reply.Headers.Action, reader);
                MessageFault fault = MessageFault.CreateFault(newMsg);
                newMsg.Close();

                newMsg = Message.CreateMessage(reply.Version, fault,
                    reply.Headers.Action);

                &lt;FONT color=#0000ff&gt;// Preserve the headers of the original message&lt;/FONT&gt;
                newMsg.Headers.CopyHeadersFrom(reply);

                &lt;FONT color=#804040&gt;&lt;B&gt;foreach&lt;/B&gt;&lt;/FONT&gt;(&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt; propertyKey &lt;FONT color=#804040&gt;&lt;B&gt;in&lt;/B&gt;&lt;/FONT&gt; reply.Properties.Keys)
                    newMsg.Properties.Add(propertyKey, reply.Properties[propertyKey]);

                &lt;FONT color=#0000ff&gt;// Close the original message and return new message&lt;/FONT&gt;
                reply.Close();
                reply = newMsg;
            }
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;private&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; FixMessage(XmlDocument doc)
        {
            &lt;FONT color=#0000ff&gt;// Fix the fault message here.&lt;/FONT&gt;
            Console.WriteLine(&lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;"Fixing the fault received from the alien service .."&lt;/FONT&gt;&lt;/SPAN&gt;);
        }

        &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;object&lt;/B&gt;&lt;/FONT&gt; BeforeSendRequest(&lt;FONT color=#804040&gt;&lt;B&gt;ref&lt;/B&gt;&lt;/FONT&gt; Message request, IProxyChannel channel)
        {
            &lt;FONT color=#804040&gt;&lt;B&gt;return&lt;/B&gt;&lt;/FONT&gt; &lt;SPAN&gt;&lt;FONT color=#ff00ff&gt;null&lt;/FONT&gt;&lt;/SPAN&gt;;
        }

&lt;FONT color=#a020f0&gt;        #endregion&lt;/FONT&gt;
    }
}

&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at &lt;A href="http://www.microsoft.com/info/cpyright.htm" target=_blank&gt;http://www.microsoft.com/info/cpyright.htm&lt;/A&gt;. &lt;/I&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=420475" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vipulmodi/archive/tags/Indigo/default.aspx">Indigo</category></item><item><title>Enumerating the Enums</title><link>http://blogs.msdn.com/vipulmodi/archive/2005/04/15/408738.aspx</link><pubDate>Sat, 16 Apr 2005 00:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:408738</guid><dc:creator>vipulm</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/408738.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=408738</wfw:commentRss><description>&lt;P&gt;While writing the code today I needed to enumerate all the values of an enum. I am sure many of you know about this, but I did not and hence here it is. &lt;/P&gt;
&lt;P&gt;Suppose you have enum defined as follows and you want to enumerate all the possible values of Fruit.&lt;/P&gt;&lt;PRE&gt;      &lt;FONT size=4&gt;enum Fruit
    {
        Cherry,
        Apple,
        Orange,
        Banana
    }&lt;/FONT&gt;
&lt;/PRE&gt;
&lt;P&gt;Use the Enum.GetValues(Type T) method to achieve this. Here is the complete program: 
&lt;DIV&gt;&lt;PRE&gt;&lt;FONT size=4&gt;&lt;FONT color=#804040&gt;&lt;B&gt;using&lt;/B&gt;&lt;/FONT&gt; System;

&lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;class&lt;/B&gt;&lt;/FONT&gt; EnumerateEnum
{
    &lt;FONT color=#2e8b57&gt;&lt;B&gt;enum&lt;/B&gt;&lt;/FONT&gt; Fruit
    {
        Cherry,
        Apple,
        Orange,
        Banana
    }

    &lt;FONT color=#2e8b57&gt;&lt;B&gt;public&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;static&lt;/B&gt;&lt;/FONT&gt; &lt;FONT color=#2e8b57&gt;&lt;B&gt;void&lt;/B&gt;&lt;/FONT&gt; Main(&lt;FONT color=#2e8b57&gt;&lt;B&gt;string&lt;/B&gt;&lt;/FONT&gt;[] args)
    {
        &lt;FONT color=#804040&gt;&lt;B&gt;foreach&lt;/B&gt;&lt;/FONT&gt;(Fruit f &lt;FONT color=#804040&gt;&lt;B&gt;in&lt;/B&gt;&lt;/FONT&gt; Enum.GetValues(&lt;FONT color=#804040&gt;&lt;B&gt;typeof&lt;/B&gt;&lt;/FONT&gt;(Fruit)))
        {
            Console.WriteLine(f);
        }
    }
}&lt;/FONT&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=408738" width="1" height="1"&gt;</description></item><item><title>Indigo is hiring smart people like you!</title><link>http://blogs.msdn.com/vipulmodi/archive/2005/03/22/400805.aspx</link><pubDate>Wed, 23 Mar 2005 02:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:400805</guid><dc:creator>vipulm</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/400805.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=400805</wfw:commentRss><description>&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Indigo is hiring:&lt;/font&gt;&lt;/p&gt;&lt;font face="Verdana" size="2"&gt;Do you want to... &lt;/font&gt; &lt;ul&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;Work on the next generation web services platform?&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;Work with the industry experts like Don Box?&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;Work with the creators of SOAP, WSDL and XML Gurus?&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;Contribute to the next generation web services protocol specifications?&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;Do you consider yourself to be smart, talented? Do you have passion for building the distributed computing platforms? &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;The Indigo team is hiring &lt;/font&gt;&lt;a href="http://www.microsoft.com/college/ft_softdesengtest.mspx"&gt;&lt;font face="Verdana" size="2"&gt;Software Design Engineer in Test (SDET)&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana" size="2"&gt;, so send your resume our way. Wait, before you question the “Test” word in the above title, read what people have to say about SDET positions at Microsoft. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;Gretchen's 3 reasons to consider a career as a Microsoft SDET: &lt;/font&gt;&lt;A href="http://blogs.msdn.com/jobsblog/archive/2005/01/19/356412.aspx"&gt;&lt;font face="Verdana" size="2"&gt;http://blogs.msdn.com/jobsblog/archive/2005/01/19/356412.aspx&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;Steve Rowe's 3 reasons to&amp;nbsp;consider being a test developer: &lt;/font&gt;&lt;A href="http://blogs.msdn.com/steverowe/archive/2005/01/19/356361.aspx"&gt;&lt;font face="Verdana" size="2"&gt;http://blogs.msdn.com/steverowe/archive/2005/01/19/356361.aspx&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;The SDET are not only great developers but they are great testers as well, they are creative, they think about using the programs in way the original developer never envisioned, they think about breaking the software, they are the first developers of Indigo. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;For detailed information on the position visit &lt;br /&gt;&lt;/font&gt;&lt;a title="http" href="http://www.microsoft.com/careers/search/details.aspx?jobid=32de915e-346f-40fc-8bee-a180e5782ce3"&gt;&lt;font face="Verdana" size="2"&gt;http://www.microsoft.com/careers/search/details.aspx?jobid=32de915e-346f-40fc-8bee-a180e5782ce3&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana" size="2"&gt; and &lt;br /&gt;&lt;/font&gt;&lt;a title="http" href="http://www.microsoft.com/careers/search/details.aspx?jobid=6286bb1e-b6bc-469c-a300-f04dc8b13ff2"&gt;&lt;font face="Verdana" size="2"&gt;http://www.microsoft.com/careers/search/details.aspx?jobid=6286bb1e-b6bc-469c-a300-f04dc8b13ff2&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;My friend George has nice XML markup of Indigo Jobs. Don't forget to take a look at it. &lt;a href="http://www.jroller.com/page/ssge/20050309#indigo_needs_testers"&gt;http://www.jroller.com/page/ssge/20050309#indigo_needs_testers&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=400805" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vipulmodi/archive/tags/Indigo/default.aspx">Indigo</category></item><item><title>Using Non Data Contract Types in Indigo </title><link>http://blogs.msdn.com/vipulmodi/archive/2005/03/22/400703.aspx</link><pubDate>Tue, 22 Mar 2005 21:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:400703</guid><dc:creator>vipulm</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/400703.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=400703</wfw:commentRss><description> &lt;font face="Verdana" size="2"&gt;The &lt;a href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/indigo_con/html/a56a245e-ac1d-430b-abc9-59f61c83431e.asp?frame=true"&gt; Data Contract&lt;/a&gt; provides the features that were not possible with the earlier serialization technologies, features such as &lt;a href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/indigo_con/html/4a0700cb-5f5f-4137-8705-3a3ecf06461f.asp?frame=true"&gt; Versioning&lt;/a&gt;, Object Identity and &lt;a href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/indigo_con/html/49d5db8a-3fa1-4a10-b27f-713987b34431.asp?frame=true"&gt; Object Graph preservation&lt;/a&gt;. This is a great way to go if you are starting fresh. However there might be situations in which using the Data Contract is either not possible or not practical. &lt;p&gt;For example,&lt;/p&gt; &lt;ol&gt;&lt;li&gt;You are an Indigo service and you want to Interop with existing or down level clients with minimal code changes to the client&lt;/li&gt;&lt;li&gt; You are an Indigo client who want to consume the existing or down level service and hence non Data Contract types&lt;/li&gt;&lt;li&gt; You already have existing types that you do not want to or can not covert to data contract types&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;In all such cases you want to use XmlSerializer to serialize and de-serialize types instead of Indigo XmlFormatter. The ServiceContract attribute has a property called FormatMode, this property instructs the runtime to use either XmlFormatter or XmlSerializer.&lt;/p&gt; &lt;/font&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;[&lt;font color="#000080"&gt;ServiceContract&lt;/font&gt;(FormatMode=ContractFormatMode.XmlSerializer)]&lt;br /&gt; &lt;font color="#0000ff"&gt;public interface&lt;/font&gt; &lt;font color="#000080"&gt;MyInteroperableContract&lt;/font&gt;&lt;br /&gt; {&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;Over the next few posts we will get to the details of achieving Interoperability in the scenarios mentioned above and their implications on wire messages, WSDL and programming model. If you can’t wait, here is the brief description of what you need to do. &lt;br /&gt; &lt;br /&gt;If you are a service and want to Interop with down level client most probably the only thing that you need to do it to set the FormatMode proeprty of ServiceContract to ContractFormatMode.XmlSerializer. If you are trying to Interop with the existing service, use /useXmlSerializer or /uxs option to svcutil. In some cases you may also have to use /typedMessages or /tm option as well. &lt;br /&gt; &amp;nbsp;&lt;/font&gt;&lt;/p&gt; &lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=400703" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vipulmodi/archive/tags/Indigo/default.aspx">Indigo</category></item><item><title>Find The Median Of Infinite Stream Of Numbers</title><link>http://blogs.msdn.com/vipulmodi/archive/2005/03/18/398981.aspx</link><pubDate>Sat, 19 Mar 2005 03:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:398981</guid><dc:creator>vipulm</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/398981.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=398981</wfw:commentRss><description>&lt;font face="Verdana" size="2"&gt;A friend of mine who works in a big&amp;nbsp;Bay Area company&amp;nbsp;recently asked me this question. “There is an infinite stream of numbers and you have to provide a median of those numbers a any given time.” At first it sounds impossible (BTW, do not confuse median with mean or average). When asking further about the problem domain he provided me some more information that helped me solve the problem in couple of minutes. I am not going to give you the answer, but I will provide you the domain information. The infinite stream of numbers is actually the response time of pages served by the web server. At any time you are supposed to find median response time. The obvious limited resource constraint applies.&lt;/font&gt; &lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=398981" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vipulmodi/archive/tags/Brain+Exercise/default.aspx">Brain Exercise</category></item><item><title>The “A”, “B”, “C” of Indigo Services</title><link>http://blogs.msdn.com/vipulmodi/archive/2005/03/18/398976.aspx</link><pubDate>Sat, 19 Mar 2005 02:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:398976</guid><dc:creator>vipulm</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/398976.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=398976</wfw:commentRss><description>&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Verdana" size="2"&gt;An Indigo service is a collection of one or more service endpoints. One of our team member pointed out after the initial design phase that understanding Indigo service endpoint is as simple as A, B, C. The A-Address means “Where”, B-Binding means “How” and C-Contact means “What”. &lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Verdana" size="2"&gt;A-Address defines “where” the service is located, &lt;br /&gt;B-Binding defines “how” to communicate to that service and &lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Verdana" size="2"&gt;C-Contract defines “what” to communicate.&lt;br /&gt;&amp;nbsp;&lt;br /&gt;To learn more about this read the "The Conceptual Overview of Indigo" at &lt;/font&gt;&lt;a href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/indigo_con/html/3e7e0afd-7913-499d-bafb-eac7caacbc7a.asp?frame=true"&gt;&lt;font face="Verdana" size="2"&gt;http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/indigo_con/html/3e7e0afd-7913-499d-bafb-eac7caacbc7a.asp?frame=true&lt;/font&gt;&lt;/a&gt;&amp;nbsp; &lt;br /&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=398976" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vipulmodi/archive/tags/Indigo/default.aspx">Indigo</category></item><item><title>Get Indigo Today</title><link>http://blogs.msdn.com/vipulmodi/archive/2005/03/17/398331.aspx</link><pubDate>Thu, 17 Mar 2005 21:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:398331</guid><dc:creator>vipulm</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/398331.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=398331</wfw:commentRss><description>&lt;p&gt;&lt;font face="Verdana" size="2"&gt;"Indigo" is a set of .NET technologies for building and running connected systems.&amp;nbsp;For more information on Indigo visit the "Longhorn" development center at &lt;a href="http://msdn.microsoft.com/Longhorn/understanding/pillars/Indigo/default.aspx"&gt;http://msdn.microsoft.com/Longhorn/understanding/pillars/Indigo/default.aspx&lt;/a&gt;. We have just released the Community Technology Preview (CTP) version of Indigo as part of WinFX SDK on MSDN subscriber download, at &lt;a href="http://msdn.microsoft.com/subscriptions/"&gt;http://msdn.microsoft.com/subscriptions/&lt;/a&gt;. Look&amp;nbsp;under Tools, SDKs, DDKs | Platform Tools | WinFX SDK. It contains documentation, samples, command-line compilers, and tools designed to help you develop managed-code applications and libraries using WinFX. You can view the documentation at &lt;a href="http://winfx.msdn.microsoft.com/library/"&gt;http://winfx.msdn.microsoft.com/library/&lt;/a&gt;. &lt;br /&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=398331" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vipulmodi/archive/tags/Indigo/default.aspx">Indigo</category></item><item><title>Hi There</title><link>http://blogs.msdn.com/vipulmodi/archive/2005/03/17/398323.aspx</link><pubDate>Thu, 17 Mar 2005 21:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:398323</guid><dc:creator>vipulm</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/vipulmodi/comments/398323.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vipulmodi/commentrss.aspx?PostID=398323</wfw:commentRss><description>&lt;font face="Verdana" size="2"&gt;Yes, I work in Interop team of Indigo making sure that Indigo works with Microsoft web services stack such as ASMX and WSE, as well as the web services stack from other vendors. You will find information related to Indigo interoperability, Indigo in general as well as some random stuff about .Net and life in general on this blog. I look forward for your feedback and comments.&lt;/font&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=398323" width="1" height="1"&gt;</description></item></channel></rss>