<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Hoop Somuah</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/hoop/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/hoop/feed.xml</link>
    <description>Distributed Systems and other Random Thoughts</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:10:25 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>My new team</title>
      <link>https://docs.microsoft.com/archive/blogs/hoop/my-new-team</link>
      <pubDate>Thu, 30 Oct 2008 15:38:00 GMT</pubDate>
      <dc:creator><![CDATA[Hoop]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hoop/2008/10/30/my-new-team/</guid>
      <description><![CDATA[Three and a half months ago I switched teams. I'm now part of the "Oslo" Modeling Languages...]]></description>
      <content:encoded><![CDATA[<P>Three and a half months ago I switched teams. I'm now part of the "Oslo" Modeling Languages team.</P>
<P>If you want to know more, check out these 2 new blogs that we launched:</P>
<UL>
<LI><A href="http://blogs.msdn.com/intellipad" mce_href="http://blogs.msdn.com/intellipad">Intellipad Team Blog</A></LI>
<LI><A href="http://blogs.msdn.com/intellipad" mce_href="http://blogs.msdn.com/intellipad">MLanguage Team blog</A><BR></LI></UL>]]></content:encoded>
    </item>
    <item>
      <title>Justin's got one</title>
      <link>https://docs.microsoft.com/archive/blogs/hoop/justins-got-one</link>
      <pubDate>Mon, 28 May 2007 17:38:00 GMT</pubDate>
      <dc:creator><![CDATA[Hoop]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hoop/2007/05/28/justins-got-one/</guid>
      <description><![CDATA[Justin Ng has started an MSDN blog. Justin and I work together on the Zune Services team.]]></description>
      <content:encoded><![CDATA[Justin Ng has started an <A class="" href="http://blogs.msdn.com/thesocial/" mce_href="http://blogs.msdn.com/thesocial/">MSDN blog</A>. Justin and I work together on the Zune Services team.]]></content:encoded>
    </item>
    <item>
      <title>Test Post</title>
      <link>https://docs.microsoft.com/archive/blogs/hoop/test-post</link>
      <pubDate>Fri, 30 Mar 2007 19:43:50 GMT</pubDate>
      <dc:creator><![CDATA[Hoop]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hoop/2007/03/30/test-post/</guid>
      <description><![CDATA[Testing a custom moniker link in community server 2.0]]></description>
      <content:encoded><![CDATA[<p>Testing a custom moniker <a href="zune:cgBvAG4AIABzAGUAeABzAG0AaQB0AGgA.">link</a> in community server 2.0</p>]]></content:encoded>
    </item>
    <item>
      <title>Making svcutil.exe and VisualBasic.Net play nice</title>
      <link>https://docs.microsoft.com/archive/blogs/hoop/making-svcutil-exe-and-visualbasic-net-play-nice</link>
      <pubDate>Wed, 24 Jan 2007 21:18:00 GMT</pubDate>
      <dc:creator><![CDATA[Hoop]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hoop/2007/01/24/making-svcutil-exe-and-visualbasic-net-play-nice/</guid>
      <description><![CDATA[Ali Pasha has an interesting post about some issues you can run into when you use Visual Basic and...]]></description>
      <content:encoded><![CDATA[<P>Ali Pasha has an interesting <A class="" title=post href="http://blogs.msdn.com/a_pasha/archive/2006/12/21/types-are-unitialized-if-using-visual-basic-wcf.aspx" target=_blank mce_href="http://blogs.msdn.com/a_pasha/archive/2006/12/21/types-are-unitialized-if-using-visual-basic-wcf.aspx">post</A> about some issues you can run into when you use Visual Basic and svcutil.exe and I thought I'd write a post to shed some more light on the issue.</P>
<P>DataContract types are uniquely identified using a namespace qualified name (namespace uri and a name). This namespace uri is used as the targetNamespace in XSD schemas created for that DataContract.</P>
<P>If a namespace uri is not specified when a DataContract is created, one is automatically created based on the CLR namespace of the type and&nbsp;using the prefix "<EM>http://schemas.datacontract.org/2004/07/"</EM>. (If you do not place your types in a CLR namespace then just the prefix is used).</P>
<P>To keep generated code as&nbsp;clean as possible, the client code generator doesn't generate an explicit namespace declaration if it doesn't have to. The problem with this approach is that VB.NET projects can affect the namespace of types using a root namespace. In the abscence of an explicit namespace uri declaration, changing a types namespace will also change it's schema which will affect it's wire representation.</P>
<P>As Ali pointed out, using the /namespace option with svcutil will fix the issue because the types namespace no longer maps directly to the auto-generated namespace and the code generator will have to explicitly define the namespace uri. Another way to make sure this doesn't happen is to define a namespace uri explicitly on the server. This should also cause the client to generate an explicit namespace uri definition.</P>
<P>You can also work around this by not not using a root namespace in your poject.</P>
<P>Note: This issue does not apply to service contracts because the default namespace does not affect wire communications.</P>]]></content:encoded>
    </item>
    <item>
      <title>How to restore the native Zip file integration in Windows</title>
      <link>https://docs.microsoft.com/archive/blogs/hoop/how-to-restore-the-native-zip-file-integration-in-windows</link>
      <pubDate>Wed, 03 Jan 2007 15:38:00 GMT</pubDate>
      <dc:creator><![CDATA[Hoop]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hoop/2007/01/03/how-to-restore-the-native-zip-file-integration-in-windows/</guid>
      <description><![CDATA[I got a copy of WinZip last week for my x64 box because I needed to unzip a gzip file. I later...]]></description>
      <content:encoded><![CDATA[<P>I got a copy of WinZip last week for my x64 box because I needed to unzip a gzip file. I later realized that since I'm running a 64-bit version of vista, the handy WinZip context menu shell extenstions won't work (unless I run a 32-instance of explorer.exe). This was a bummer because I like being able to right click on an archive and extract it. I know Windows has had built in support for this since XP but it requires me to click one more time than winzip does so it's not as quick. In any case, not having the optio nto use WinZip, I wanted to go back to using the built in windows handler for zip files since it works fine (except for that one extra click I have to do).</P>
<P>How do you restore the default .zip file association in Windowx XP or Vista? It wasn't as simple as right clicking and selecting "Open with.." which is what I tried for about 5 minutes. turns out you can restore it this way though:</P>
<P mce_keep="true"><STRONG>cmd /c assoc .zip=CompressedFolder</STRONG></P>
<P>Thanks goes to <A class="" title="Ramesh Srinivasan" href="http://windowsxp.mvps.org/index.html" target=_blank mce_href="http://windowsxp.mvps.org/index.html">Ramesh Srinivasan</A> for&nbsp;pointing out how to do this:&nbsp;<A href="http://windowsxp.mvps.org/zipfldr.htm">http://windowsxp.mvps.org/zipfldr.htm</A></P>]]></content:encoded>
    </item>
    <item>
      <title>XBox Live Video Market place</title>
      <link>https://docs.microsoft.com/archive/blogs/hoop/xbox-live-video-market-place</link>
      <pubDate>Wed, 22 Nov 2006 20:19:00 GMT</pubDate>
      <dc:creator><![CDATA[Hoop]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hoop/2006/11/22/xbox-live-video-market-place/</guid>
      <description><![CDATA["To celebrate its first birthday on November 22, Xbox 360™ becomes the first and only gaming console...]]></description>
      <content:encoded><![CDATA[<P>"To celebrate its first birthday on November 22, Xbox 360™ becomes the first and only gaming console to provide HD <EM>and</EM> standard-definition TV shows and movies direct to you."</P>
<P><A href="http://www.xbox.com/en-US/live/marketplace/moviestv/default.htm" mce_href="http://www.xbox.com/en-US/live/marketplace/moviestv/default.htm">http://www.xbox.com/en-US/live/marketplace/moviestv/default.htm</A></P>
<P>Renting movies from Blockbuster was nice.<BR>Renting movies from Netflix was even better for my lazy but.<BR>Renting movies without ever having to leave the couch is priceless...</P>]]></content:encoded>
    </item>
    <item>
      <title>.Net Framework 3.0 has Shipped!</title>
      <link>https://docs.microsoft.com/archive/blogs/hoop/net-framework-3-0-has-shipped</link>
      <pubDate>Wed, 22 Nov 2006 20:18:00 GMT</pubDate>
      <dc:creator><![CDATA[Hoop]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hoop/2006/11/22/net-framework-3-0-has-shipped/</guid>
      <description><![CDATA[The first product I worked on here at Microsoft has shipped....]]></description>
      <content:encoded><![CDATA[<P>The first product I worked on here at Microsoft has shipped. </P>
<P><A href="http://www.netfx3.com/blogs/news_and_announcements/archive/2006/11/06/.NET-Framework-3.0-has-been-released_2100_.aspx" mce_href="http://www.netfx3.com/blogs/news_and_announcements/archive/2006/11/06/.NET-Framework-3.0-has-been-released_2100_.aspx">http://www.netfx3.com/blogs/news_and_announcements/archive/2006/11/06/.NET-Framework-3.0-has-been-released_2100_.aspx</A></P>
<P>It's a great feeling.</P>]]></content:encoded>
    </item>
    <item>
      <title>PLinq</title>
      <link>https://docs.microsoft.com/archive/blogs/hoop/plinq</link>
      <pubDate>Tue, 29 Aug 2006 20:36:19 GMT</pubDate>
      <dc:creator><![CDATA[Hoop]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hoop/2006/08/29/plinq/</guid>
      <description><![CDATA[More LINQ goodness here. I love it!]]></description>
      <content:encoded><![CDATA[<p>More LINQ goodness <a href="http://www.eweek.com/article2/0%2c1895%2c2009167%2c00.asp">here</a>. I love it!</p>]]></content:encoded>
    </item>
    <item>
      <title>svcutil /reference and /excludeType</title>
      <link>https://docs.microsoft.com/archive/blogs/hoop/svcutil-reference-and-excludetype</link>
      <pubDate>Mon, 28 Aug 2006 21:27:36 GMT</pubDate>
      <dc:creator><![CDATA[Hoop]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hoop/2006/08/28/svcutil-reference-and-excludetype/</guid>
      <description><![CDATA[I get a lot of internal feedback that the svcutil options are confusing. svcutil.exe originally...]]></description>
      <content:encoded><![CDATA[<p>I get a lot of internal feedback that the svcutil options are confusing. svcutil.exe originally started out as a fairly simple tool and over the years working towards shipping it's evolved into a Swiss army knife. I figure even though I don't work on WCF anymore I should post a few brain dumps here to try and help folks out there understand things better.</p> <p>/reference can have&nbsp;multiple meanings/behaviors depending on the what you're trying to do. A lot of thought was given to changing the parameter to make things clearer but adding yet another flag to svcutil seemed like it would be just as confusing.</p> <p>In&nbsp;almost all&nbsp;modes, the /reference option can be used to help svcutil.exe locate assemblies that it might need to load. When passed an executable assembly, svcutil may also load the config file associated with that assembly (if one exists). If there are types referenced from config that are not in the GAC and svcutil needs to load and svcutil needs to load them, the assemblies may need to be provided via the /reference option.These types could be extensions, service behaviors, or service implementations in library dlls. I think of this /reference behavior as being similar to the csc.exe /lib option.</p> <p>During client code generation, the /reference option can be used to avoid generating types that already exist on the client machine. svcutil will examine the assemblies passed to it for contract types (DataContract and ServiceContract but not MessageContract in v1). Whenever it encounters a type in metadata that it thinks is the same as an existing type it found it will reference the existing type instead of creating a new one. This can be useful if multiple services share the same DataContracts or implement the same ServiceContract. In this mode it's actually acting to provide svcutil with a list of existing contract types. I think of this /reference behavior as being somewhat similar to the csc.exe /reference option.</p> <p>The /excludeType option complements the /reference&nbsp;option by allowing individual types to be excluded from&nbsp; the collection svcutil loads. consider the following command line:</p> <blockquote> <p>svcutil myServiceHost.exe /serviceName:myServiceName</p></blockquote> <p>Since the serviceName attribute is referring to the configuration name of the service, It's completely valid to have 2 services with the same configuration name (using the ConfigurationName property on the ServiceBehavior attribute. If this were the case, the excludeType option could be used to indicate which type should not be loaded thereby clearing up the ambiguity. Similarly, when reflecting over an assembly to generate a list of existing types, there could be 2 CLR types that represent (or seem to represent) the exact same DataContract. Again to resolve the ambiguity we can use the /excludeType option to prevent one of the types from being loaded.</p> <p>/excludeType has one more use. Even without the /reference flag, the /exclude type can be used to prevent Service Contract types from being loaded. When exporting service contracts from an assembly like this:</p> <blockquote> <p>svcutil myAssembly.dll</p></blockquote> <p>Ordinarily the command-line above would export all contracts in the service but the use of the /excludeType option can be used to limit the set of contracts that are exported.</p> <p>I hope this explanation clears up the /reference flag a little bit. If there are any other svcutil pain points you want to me to blog about let me know.</p>]]></content:encoded>
    </item>
    <item>
      <title>UseSynchronizationContext=false</title>
      <link>https://docs.microsoft.com/archive/blogs/hoop/usesynchronizationcontextfalse</link>
      <pubDate>Mon, 28 Aug 2006 20:29:00 GMT</pubDate>
      <dc:creator><![CDATA[Hoop]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hoop/2006/08/28/usesynchronizationcontextfalse/</guid>
      <description><![CDATA[I ran into an issue this summer while helping some interns port Terrarium to use .Net 3.0...]]></description>
      <content:encoded><![CDATA[<p>I ran into an issue this summer while helping some interns port <a href="http://www.windowsforms.net/Terrarium" target="_blank">Terrarium</a> to use .Net 3.0 and&nbsp;since I haven't seen many posts about it I thought I'd write one in hopes of helping anyone else who runs into this. I'll also nudge&nbsp;<a href="http://blogs.msdn.com/mjm">Michael Marucheck</a> to&nbsp;write a bit more when he has time since he knows a whole lot more about this than I do.</p> <p>When using Duplex Channels it's often the case that you want to receive callbacks on a separate thread. For example, If you're waiting on some notification message from the server and would like to use a ManualResetEvent to block on receiving this message you'll find that in the default configuration your callback method never gets called. Over simplified versions of the 2 contracts in question are shown below:</p> <blockquote><pre>[<span style="color: #009999">ServiceContract</span>(<span style="color: #009999">CallbackContract</span> = <span style="color: #000099">typeof</span>(<span style="color: #009999">CallbackContract</span>))]
<span style="color: #000099">public interface</span> <span style="color: #009999">ServiceContract</span>
{
    [<span style="color: #009999">OperationContract</span>(IsOneWay=<span style="color: #000099">true</span>)]
    <span style="color: #000099">void</span> Register();
}
<span style="color: #000099">public interface</span> <span style="color: #009999">CallbackContract</span>
{
    [<span style="color: #009999">OperationContract</span>(IsOneWay=<span style="color: #000099">true</span>)]
    <span style="color: #000099">void</span> Notification();
}
</pre></blockquote>
<p>Assuming the following server implementation of the Register method</p>
<blockquote><pre><span style="color: #000099">public void</span> Register()
{
    <span style="color: #009999">OperationContext</span>.Current.GetCallbackChannel&lt;<span style="color: #000099">ICallbackContract</span>&gt;().Notify();
}
</pre></blockquote>
<p>Given these 2 contracts one might expect to be able to write a button click event-handler in a WinForms client like this:</p>
<blockquote><pre><span style="color: #000099">public partial class</span> Client : <span style="color: #009999">Form</span>, <span style="color: #009999">ICallbackContract</span>
{
    <span style="color: #000099">static</span> ManualResetEvent mre = <span style="color: #000099">new</span> ManualResetEvent(<span style="color: #009999">false</span>);

    <span style="color: #000099">public </span>Client(<span style="color: #000099">string</span>[] args)
    {
        InitializeComponent();
    } 

    <span style="color: #000099">private void</span> button1_Click(<span style="color: #000099">object</span> sender, <span style="color: #009999">EventArgs</span> e)
    {
        <span style="color: #009999">IServiceContract</span> service = <span style="color: #009999">DuplexChannelFactory</span>&lt;<span style="color: #009999">IServiceContract</span>&gt;.CreateChannel(this, <span style="color: #990000">"callback"</span>);

        service.Register();

        <span style="color: #009900">/*
         *
         * Do some other stuff here
         *
         */</span>

        mre.WaitOne();

        <span style="color: #009900">/*
         *
         * Work that cannot be done until we receive a 
         * notification from the server.
         *
         */</span>
    }

    <span style="color: #000099">void</span> <span style="color: #009999">ICallbackContract</span>.Notification()
    {
        <span style="color: #009999">Client</span>.mre.Set();
    }
}</pre></blockquote>
<p>Unfortunately, the code in the Notification method above will never get called on the client side. This is because the default threading behavior of WCF causes callbacks to all run in the same SynchronizationContext. Since there is another thread in that synchronization context blocked waiting for notification to get called you effectively have deadlock. </p>
<p>Solution: Disable the use of synchronization contexts on your callback by applying a CallbackBehavior attribute to your callback implementation.</p>
<blockquote><pre>[<span style="color: #009999">CallbackBehavior</span>(<span style="color: #009999">UseSynchronizationContext</span> = <span style="color: #000099">false</span>)]</pre></blockquote>
<p>Applying the attribute above to the class implementing your callback will allow you to receive callbacks while in a wait or while some other thread is executing in the WinForms SynchronizationContext.&nbsp; 
<p>An alternative&nbsp;is to use the Background worker when making calls to the service. This will run outside the WinForms Synchronization context and allow incoming calls to run without blocking. Either way, you will need to be careful about calling Winforms methods from your callback methods since they won't run on the&nbsp;&nbsp;UI thread. I like the first approach a little better especially if you set things up in the Form's Load method. 
<p>I don't know a whole lot about the SynchronizationContext class. I&nbsp;learned a bit from <a href="http://blogs.msdn.com/mattdotson/archive/2006/02/13/531315.aspx">a post</a> on <a href="http://blogs.msdn.com/mattdotson/">Matt Dotson's blog</a>&nbsp;and Stephen Toub <a href="http://msdn.microsoft.com/msdnmag/issues/06/06/NETMatters/">talks about it</a> a bit in a .Net Matters article. Hopefully someone on the WCF team will blog about this in a bit more detail.</p>
<p><strong></strong>&nbsp;</p>
<p><strong>Update: </strong>When I *nudged* <a href="http://blogs.msdn.com/mjm/">Michael</a>, he pointed out that I should just put the code I needed running after the postback all in the callback method. for a lot of cases this is indeed&nbsp;a better option. If you don't absolutely have to (and you rarely do) don't put a Wait in the UI thread. It's ugly and results i na bad user experience. </p>
<p>In our particular case we should have popped up a progress dialog with a spinning icon or other whiz-bang thing-ama-jig and used the background thread to wait. that way we could add a cancel dialog as well. However this was a port of exisitng code and refactoring the application wasn't an option.</p>]]></content:encoded>
    </item>
  </channel>
</rss>