<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Scott Klueppel's Blog</title>
  <link rel="alternate" type="text/html" href="http://offroadcoder.com/" />
  <link rel="self" href="http://offroadcoder.com/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2010-01-31T18:50:19.513-08:00</updated>
  <author>
    <name>Scott Klueppel</name>
  </author>
  <subtitle>making the hard line look easy</subtitle>
  <id>http://offroadcoder.com/</id>
  <generator uri="http://dasblog.info/" version="2.1.8102.813">DasBlog</generator>
  <entry>
    <title>Auto-populating ASP.NET MVC “controls” after a post</title>
    <link rel="alternate" type="text/html" href="http://offroadcoder.com/2010/02/01/AutopopulatingASPNETMVCControlsAfterAPost.aspx" />
    <id>http://offroadcoder.com/PermaLink,guid,5d833e28-847b-41a8-905f-549b0f6c1f84.aspx</id>
    <published>2010-01-31T18:50:19.513-08:00</published>
    <updated>2010-01-31T18:50:19.513-08:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="http://offroadcoder.com/CategoryView,category,ASPNET.aspx" />
    <category term="ASP.NET MVC" label="ASP.NET MVC" scheme="http://offroadcoder.com/CategoryView,category,ASPNETMVC.aspx" />
    <category term="C#" label="C#" scheme="http://offroadcoder.com/CategoryView,category,C.aspx" />
    <category term="Javascript" label="Javascript" scheme="http://offroadcoder.com/CategoryView,category,Javascript.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m not sure if what I’m doing is actually the right way to create a “user control”
in ASP.NET MVC, but it’s worth sharing this tidbit either way. Instead of using a <em>MVC
View User Control</em> to create a hidden field, a text box, two anchors, and three
JavaScript functions, I chose to put it all in a <em>HtmlHelper</em> in which I write
out the HTML and JavaScript myself. Everything worked fine except the almost magical
auto-repopulating of the hidden and text fields after a post that didn’t work as expected
as in a typical <em>MVC View Page</em>.
</p>
        <p>
          <strong>The situation:</strong> I have a page that needs to be called as a popup from
many pages in my MVC application. The page allows single or multiple selection of
“items” driven by an XML file. In the event that one day, almost always immediately,
I have two or more of these “controls” on one view page, I need the two fields and
the three JavaScript functions to have unique names so they don’t cross paths and
cause unexpected behavior. I had an <em>ASP.NET User Control</em> to do this in plain
old ASP.NET (POAN) since v1.1, and I can’t live without it. 
</p>
        <p>
          <strong>The confusion:</strong> If I were to place the hidden, textbox, anchors, and
JavaScript functions directly in the calling page, something magical happens after
a post. If the controls had values before the post, they appear to magically retain
there values after the post. It wasn’t until a colleague of mine, Sat, and I dug into
Reflector for a while did we realize what was happening. Html.TextBox, Html.Hidden,
and others all do something similar to auto-magically re-populate their values after
the post. Since I’m writing out my fields as &lt;input type=”hidden”/&gt; and &lt;input
type=”text”/&gt;, the magic doesn’t happen.
</p>
        <p>
          <em>      NOTE: The magic will also not happen if you just
write &lt;input type=”text”/&gt; on the page. It only happens if you use Html.TextBox.</em>
        </p>
        <p>
          <strong>The solution:</strong> I am still new to MVC and still trying to wrap my head
around the “right way” to do things. Reflector showed that the <em>HtmlHelpers</em> all
looked at the ModelState in the ViewData before rendering their HTML. They looked
for their value by key (key being the control/tag name), and, if present, used that
as the control/tag’s value. Bing! Maybe I should do the same thing. So just before
I go to town with TagBuilder to assemble my controls/tags, I look in the ViewData’s
ModelState for my value. If it is there, it must have been posted there by me (my
control).
</p>
        <div style="width: 650px; font-family: consolas; background: #3f3f3f; color: #dcdccc; font-size: 9pt">
          <p style="margin: 0px">
            <span style="color: #85ac8d">   48</span>         <span style="color: #2b91af">UrlHelper</span><span style="color: #dfdfbf">urlHelper</span> = <span style="color: #e1e18a; font-weight: bold">new</span><span style="color: #2b91af">UrlHelper</span>(<span style="color: #dfdfbf">helper</span>.<span style="color: #dfdfbf">ViewContext</span>.<span style="color: #dfdfbf">RequestContext</span>);
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   49</span>         <span style="color: #e1e18a; font-weight: bold">string</span><span style="color: #dfdfbf">textValue</span> = <span style="color: #e1e18a; font-weight: bold">null</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   50</span>         <span style="color: #2b91af">ModelState</span><span style="color: #dfdfbf">state</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   51</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   52</span>         <span style="color: #e1e18a; font-weight: bold">if</span> (<span style="color: #dfdfbf">helper</span>.<span style="color: #dfdfbf">ViewData</span>.<span style="color: #dfdfbf">ModelState</span>.<span style="color: #dfdfbf">TryGetValue</span>(<span style="color: #dfdfbf">textFieldName</span>, <span style="color: #e1e18a; font-weight: bold">out</span><span style="color: #dfdfbf">state</span>))
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   53</span>        
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   54</span>             <span style="color: #dfdfbf">textValue</span> = <span style="color: #dfdfbf">state</span>.<span style="color: #dfdfbf">Value</span>.<span style="color: #dfdfbf">AttemptedValue</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   55</span>        
}
</p>
        </div>
        <br />
        <p>
Works like a charm! Now my hidden, textbox, two anchors, and three JavaScript functions
are bundled nicely inside of an <em>HtmlHelper</em> class that looks and feels like
I’m using a built-in ASP.NET MVC <em>HtmlHelper</em> class. Most importantly, I have
the pleasure of typing only this on all my consuming pages.
</p>
        <div style="width: 650px; font-family: consolas; background: #3f3f3f; color: #dcdccc; font-size: 9pt">
          <p style="margin: 0px">
            <span style="color: #85ac8d">   40</span>     <span style="background: #ffee62; color: #000">&lt;%</span><span style="color: #efef8f">=</span><span style="color: #dfdfbf">Html</span>.<span style="color: #dfdfbf">MySelector</span>(<span style="color: #c89191">"selectedIDs"</span>, <span style="color: #c89191">"selectedNames"</span>, <span style="color: #c89191">"State"</span>)<span style="background: #ffee62; color: #000">%&gt;</span></p>
        </div>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=5d833e28-847b-41a8-905f-549b0f6c1f84" />
      </div>
    </content>
  </entry>
  <entry>
    <title>WIF FTW</title>
    <link rel="alternate" type="text/html" href="http://offroadcoder.com/2009/11/27/WIFFTW.aspx" />
    <id>http://offroadcoder.com/PermaLink,guid,3331f559-3440-430f-a4c0-f18f5e90346f.aspx</id>
    <published>2009-11-26T20:44:24.239875-08:00</published>
    <updated>2009-11-26T20:44:24.239875-08:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://offroadcoder.com/CategoryView,category,NETFramework.aspx" />
    <category term="AJAX" label="AJAX" scheme="http://offroadcoder.com/CategoryView,category,AJAX.aspx" />
    <category term="ASP.NET" label="ASP.NET" scheme="http://offroadcoder.com/CategoryView,category,ASPNET.aspx" />
    <category term="C#" label="C#" scheme="http://offroadcoder.com/CategoryView,category,C.aspx" />
    <category term="WCF" label="WCF" scheme="http://offroadcoder.com/CategoryView,category,WCF.aspx" />
    <category term="WIF" label="WIF" scheme="http://offroadcoder.com/CategoryView,category,WIF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve been talking about Geneva for a long time. I got the basics down earlier in the
year. I tried to come up with my own set of sample apps, but failed to get anywhere.
With the official release, and renaming to <em>Windows Identity Foundation (WIF)</em>,
I have renewed inspiration.
</p>
        <p>
I read Michele Leroux Bustamante’s MSDN magazine article, <a href="http://msdn.microsoft.com/en-us/magazine/ee335707.aspx" target="_blank">Claim-Based
Authorization with WIF</a>, last night. After reading the article, I was confident
that I could get a claims-aware WCF service stood up with a custom STS in a matter
of hours. Today I downloaded and installed WIF. I also installed the WIF SDK and all
of the prerequisite hotfixes. I perused the readme files and looked through some of
the samples code. Everything is layed out sensibly, the samples are commented sufficiently,
and the samples include setup and cleanup batch scripts when necessary.
</p>
        <p>
The samples include:
</p>
        <blockquote>
          <p>
Quick Start
</p>
          <ol>
            <li>
Simple Claims Aware Web Application 
</li>
            <li>
Simple Claims Aware Web Service 
</li>
            <li>
Simple Web Application With Information Card SignIn 
</li>
            <li>
Simple Web Application With Managed STS 
</li>
            <li>
Claims Aware Web Application in a Web Farm 
</li>
            <li>
Using Claims In IsInRole 
</li>
          </ol>
          <p>
End-to-end Scenario
</p>
          <ol>
            <li>
Authentication Assurance 
</li>
            <li>
Federation For Web Services 
</li>
            <li>
Federation For Web Applications 
</li>
            <li>
Identity Delegation 
</li>
            <li>
Web Application With Multiple SignIn Methods 
</li>
            <li>
Federation Metadata</li>
          </ol>
          <p>
Extensibility
</p>
          <ol>
            <li>
Claims Aware AJAX Application 
</li>
            <li>
Convert Claims To NT Token 
</li>
            <li>
Customizing Request Security Token 
</li>
            <li>
Customizing Token 
</li>
            <li>
WSTrustChannel 
</li>
            <li>
Claims-based Authorization</li>
          </ol>
        </blockquote>
        <p>
All of the samples I’ve run through so far are great. The only thing that I’m not
in love with is all the XML required to wire this stuff up. Maybe some Juval-style
extensions would make it less painful.
</p>
        <p>
One more thing… it looks like all of the XP users will finally have to upgrade. WIF
only works with Vista, Win7, and Win2008. I heard that Win2003 compatibility will
arrive in December.
</p>
        <p>
          <a href="http://msdn.microsoft.com/en-us/evalcenter/dd440951.aspx" target="_blank">Download
Windows Identity Foundation</a>
        </p>
        <p>
          <a href="http://www.microsoft.com/downloads/info.aspx?na=47&amp;p=1&amp;SrcDisplayLang=en&amp;SrcCategoryId=&amp;SrcFamilyId=eb9c345f-e830-40b8-a5fe-ae7a864c4d76&amp;u=details.aspx%3ffamilyid%3dC148B2DF-C7AF-46BB-9162-2C9422208504%26displaylang%3den" target="_blank">Download
Windows Identity Foundation SDK</a>
        </p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=3331f559-3440-430f-a4c0-f18f5e90346f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>NetTcpBinding and SecurityNegotiationException "A call to SSPI failed"</title>
    <link rel="alternate" type="text/html" href="http://offroadcoder.com/2009/10/29/NetTcpBindingAndSecurityNegotiationExceptionACallToSSPIFailed.aspx" />
    <id>http://offroadcoder.com/PermaLink,guid,ee03112d-9150-43fa-81a5-a9ad49b49640.aspx</id>
    <published>2009-10-28T18:30:22.6-07:00</published>
    <updated>2009-10-28T18:32:14.1945-07:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://offroadcoder.com/CategoryView,category,NETFramework.aspx" />
    <category term="C#" label="C#" scheme="http://offroadcoder.com/CategoryView,category,C.aspx" />
    <category term="Dev Tools" label="Dev Tools" scheme="http://offroadcoder.com/CategoryView,category,DevTools.aspx" />
    <category term="WCF" label="WCF" scheme="http://offroadcoder.com/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Using the NetTcpBinding on a WCF service is secure by default. Unless you override
the default settings, you will enjoy Transport Security using Windows authentication
and the EncrpytAndSign protection level. When you create a new WCF service library,
Visual Studio creates a config file with the following <em>identity</em> block:
</p>
        <div style="font-size: 9pt; background: #3f3f3f; width: 400px; color: #dcdccc; font-family: consolas">
          <p style="margin: 0px">
            <span style="color: #85ac8d">   24</span> <span style="color: #efef8f">         
&lt;</span><span style="color: #e3c66a">identity</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   25</span> <span style="color: #efef8f">           
&lt;</span><span style="color: #e3c66a">dns</span><span style="color: #efef8f"></span><span style="color: white">value</span><span style="color: #efef8f">="</span><span style="color: #cc9393">localhost</span><span style="color: #efef8f">"/&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   26</span> <span style="color: #efef8f">         
&lt;/</span><span style="color: #e3c66a">identity</span><span style="color: #efef8f">&gt;</span></p>
        </div>
        <p>
 
</p>
        <p>
If you wipe this config file clean like me to write a much cleaner and shorter config
file, this <em>identity</em> block is the first thing to go. Sadly, most people also
add a binding configuration with &lt;security mode=”None”/&gt;. I have done this too
in an Intranet environment. The samples and book examples out there don’t show how
to write an actual production environment service that cares for different machines
in the same domain. While the default settings work when testing on your local machine,
they don’t work in a simple Intranet environment.
</p>
        <p>
Most of the difficulty I experienced when starting to work with WCF was getting security
to work with the TCP binding. Everything worked so easily during development, but
everything broke down once deployed to the development server. It didn’t help that
the only errors I saw were timeout exceptions. If I had known about the Service Trace
Viewer, I could have easily determine the cause and Googled (Bing wasn’t around then)
for a solution. Instead, I chose the easier (and much less secure) way out… rely on
my firewall and turn security off.
</p>
        <p>
As mentioned before, the NetTcpBinding is secure by default with transport security
using Windows authentication. The problem most experience when moving the service
to a different machine is caused by NT authentication failing. If you use svcutil
to generate your client config file and your host doesn’t have the <em>identity </em>block
mentioned above, svcutil will not add a key piece of information to the client config
file. The missing element is, you guessed it, the <em>identity</em> block. Without
it, you will likely get an exception and see a stack trace similar to this:
</p>
        <p>
[System.ServiceModel.Security.SecurityNegotiationException: A call to SSPI failed,
see inner exception.]<br />
...<br />
[System.Security.Authentication.AuthenticationException: A call to SSPI failed, see
inner exception.]<br />
...<br />
[System.ComponentModel.Win32Exception: The target principal name is incorrect.]<br />
...
</p>
        <p>
If you add tracing to your client, you will see that without specifying an <em>identity</em> block
WCF will make the call with a DNS identity set to the name of the host. Notice the
blue arrows.
</p>
        <p>
          <a href="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image.png">
            <img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="171" alt="image" src="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_thumb.png" width="330" border="0" />
          </a>
        </p>
        <p>
You can see that the EndpointReference does not have an &lt;Identity&gt; block. Without
that <em>identity</em> block, WCF cannot create a valid ServicePrincipalName. You
can find this in Reflector, following this path:
</p>
        <ul>
          <li>
System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider+WindowsStreamSecurityUpgradeInitiator.OnInitiateUpgrade()
– This is where the SecurityNegociationException is being thrown. 
</li>
          <li>
System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider+WindowsStreamSecurityUpgradeInitiator.InitiateUpgradePrepare()
– This method populates an EndpointIdentity and ServicePrincipalName to be used immediately
after for NT authentication.</li>
        </ul>
        <p>
          <a href="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_3.png">
            <img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="144" alt="image" src="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_thumb_3.png" width="538" border="0" />
          </a>
        </p>
        <p>
When the identity is not specified, it falls back to trying to create an SPN from
the host address. I have seen this work on a machine that has two DNS names, using
the DNS name that does not match the NETBIOS or AD name for the machine. I’m not exactly
sure why that works.
</p>
        <p>
Having any of the following <em>identity</em> blocks in your client config file will
cause WCF to take the first path that successfully creates an SPN needed to perform
NT authentication in the AuthenticateAsClient method called from OnInitiateUpgrade():
</p>
        <ul>
          <li>
&lt;dns value=”serviceHostName”/&gt; 
</li>
          <li>
&lt;dns/&gt; 
</li>
          <li>
&lt;servicePrincipalName value=”domain\hostServiceUserAccount”/&gt; 
</li>
          <li>
&lt;servicePrincipalName/&gt;</li>
        </ul>
        <p>
        </p>
        <p>
        </p>
        <p>
Having these &lt;Identity&gt; settings in your client config file adds the appropriate
&lt;Identity&gt; settings in the &lt;EndpointReference&gt; used when opening the channel.
</p>
        <p>
          <a href="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_4.png">
            <img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="197" alt="image" src="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_thumb_4.png" width="333" border="0" />
          </a>
        </p>
        <p>
Security seems more mysterious when going rogue and writing your own config files.
If you go rogue, make sure you use the appropriate &lt;Identity&gt; blocks. With this
mystery solved, &lt;security mode=”None”/&gt; is a thing of the past. Now we can keep
our services secure in an Intranet environment.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=ee03112d-9150-43fa-81a5-a9ad49b49640" />
      </div>
    </content>
  </entry>
  <entry>
    <title>The WCF Master Class</title>
    <link rel="alternate" type="text/html" href="http://offroadcoder.com/2009/10/14/TheWCFMasterClass.aspx" />
    <id>http://offroadcoder.com/PermaLink,guid,6e3243b2-3b8a-44e0-b080-00cab2d08587.aspx</id>
    <published>2009-10-13T18:59:33.16725-07:00</published>
    <updated>2009-10-13T19:00:37.495375-07:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://offroadcoder.com/CategoryView,category,NETFramework.aspx" />
    <category term="C#" label="C#" scheme="http://offroadcoder.com/CategoryView,category,C.aspx" />
    <category term="Cloud" label="Cloud" scheme="http://offroadcoder.com/CategoryView,category,Cloud.aspx" />
    <category term="Dev Tools" label="Dev Tools" scheme="http://offroadcoder.com/CategoryView,category,DevTools.aspx" />
    <category term="Futures" label="Futures" scheme="http://offroadcoder.com/CategoryView,category,Futures.aspx" />
    <category term="WCF" label="WCF" scheme="http://offroadcoder.com/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://offroadcoder.com/content/binary/TheWCFMasterClass_1346E/iceberg2.jpg">
            <img title="Web services are just the tip of the iceberg in WCF" style="border-right: 0px; border-top: 0px; display: inline; margin: 0px 10px 0px 0px; border-left: 0px; border-bottom: 0px" height="247" alt="Web services are just the tip of the iceberg in WCF" src="http://offroadcoder.com/content/binary/TheWCFMasterClass_1346E/iceberg2_thumb.jpg" width="371" align="left" border="0" />
          </a>I
was privileged to attend the IDesign WCF Master Class last week. It only comes to
the USA one time each year, and is presented by the one and only Juval Lowy. The class
is held at the training center on the Microsoft Silicon Valley campus in Mountain
View, CA. Five very intense days of WCF covering all aspects of WCF from essentials
like the ABCs to the most intricate details about advanced topics like concurrency,
security, transactions, and the service bus.
</p>
        <p>
What we’ve been <strike>told</strike> sold about WCF from Microsoft is truly just
the tip of the iceberg. Juval presents countless examples that prove WCF is not just
about web services. WCF is the evolution of .NET, providing world-class features that
no class should ever be without. 
</p>
        <p>
Demos, samples, and labs are presented using .NET 3.5 and 4.0 with an emphasis on
the new features and functionality in 4.0. Discovery and announcements are the most
underrated and unknown new features of WCF 4.0. After seeing Juval’s demos on discovery
and announcement, I can’t imagine creating services without them.
</p>
        <p>
More than all of the WCF content, the class gives you a lot to think about regarding
architecture, the framework, and engineering principles. Juval’s mastery of .NET is
evident in his ServiceModelEx library that extends almost all aspects of WCF and the
service bus. His “one line of code” motto makes it possible for all of us to configure
our WCF services with ease. The ServiceModelEx library is a good example for all developers
to know and understand how to “do .NET” the right way. It exemplifies the best of
what .NET and WCF have to offer.
</p>
        <p>
Check out the <a href="http://www.idesign.net" target="_blank">IDesign website</a> to
get the WCF Resource CD (containing many of the examples and demos from the class).
Also note the next class dates and sign up for the IDesign newsletter.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=6e3243b2-3b8a-44e0-b080-00cab2d08587" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Enable WS-AT on 64-bit Vista or Windows 7</title>
    <link rel="alternate" type="text/html" href="http://offroadcoder.com/2009/10/08/EnableWSATOn64bitVistaOrWindows7.aspx" />
    <id>http://offroadcoder.com/PermaLink,guid,6828fc29-242f-440e-b9b7-07396459410e.aspx</id>
    <published>2009-10-07T22:51:21.031-07:00</published>
    <updated>2009-10-07T22:53:54.266-07:00</updated>
    <category term="MSDTC" label="MSDTC" scheme="http://offroadcoder.com/CategoryView,category,MSDTC.aspx" />
    <category term="Transactions" label="Transactions" scheme="http://offroadcoder.com/CategoryView,category,Transactions.aspx" />
    <category term="WCF" label="WCF" scheme="http://offroadcoder.com/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Thank you, Mikael Sand (and Bing)!
</p>
        <p>
          <a href="http://blogical.se/blogs/mikael_sand/archive/2009/08/28/configuring-ws-atomic-transaction-support-in-windows-7-64-bit.aspx">http://blogical.se/blogs/mikael_sand/archive/2009/08/28/configuring-ws-atomic-transaction-support-in-windows-7-64-bit.aspx</a>
        </p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=6828fc29-242f-440e-b9b7-07396459410e" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Code Camp Session Files</title>
    <link rel="alternate" type="text/html" href="http://offroadcoder.com/2009/09/03/CodeCampSessionFiles.aspx" />
    <id>http://offroadcoder.com/PermaLink,guid,c6b29bd9-3388-43b7-b52b-4944aee7e848.aspx</id>
    <published>2009-09-02T20:34:34.753-07:00</published>
    <updated>2009-09-11T17:23:47.3475-07:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://offroadcoder.com/CategoryView,category,NETFramework.aspx" />
    <category term="C#" label="C#" scheme="http://offroadcoder.com/CategoryView,category,C.aspx" />
    <category term="Dev Community" label="Dev Community" scheme="http://offroadcoder.com/CategoryView,category,DevCommunity.aspx" />
    <category term="Dev Tools" label="Dev Tools" scheme="http://offroadcoder.com/CategoryView,category,DevTools.aspx" />
    <category term="MSDTC" label="MSDTC" scheme="http://offroadcoder.com/CategoryView,category,MSDTC.aspx" />
    <category term="Transactions" label="Transactions" scheme="http://offroadcoder.com/CategoryView,category,Transactions.aspx" />
    <category term="WCF" label="WCF" scheme="http://offroadcoder.com/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">The <a href="http://www.jaxcodecamp.com">2009
Jacksonville Code Camp</a> was a great success. Many thanks to Bayer, Brandy, and
everyone else that made it happen. The bar has been set really high for future Jacksonville
code camps, and for the rest of Florida too. 
<br /><br />
My session on Transactional WCF Services went well. Many great questions and compliments
after the session. If you attended and have any unanswered questions, please email
me. 
<br /><br />
You can download the session files below. It contains staged versions of all of the
transaction modes we discussed. It also contains a tracing solution and tracing result
files to view the client and host tracing files in Client/Service mode. Also see my
previous post on using the <a href="http://offroadcoder.com/2008/06/19/ServiceTraceViewer.aspx">Service
Trace Viewer</a>. It also contains a few demo projects that we didn't get to in the
one-hour session. 
<br /><br />
Files/Solutions included in Session Archive: 
<ul><li>
PowerPoint slides 
</li><li>
Transaction Promotion Code Snippet 
</li><li>
Testing database backup 
</li><li>
Testing SQL script (query and cleanup between tests) 
</li><li>
IDesign ServiceModelEx Project (used by all included Solutions) 
</li><li>
Code Demo Solutions</li></ul><p>
Code Demos include:
</p><table border="0" cellspacing="0" cellpadding="3"><tbody><tr><td valign="top" width="20">
1.</td><td valign="top">
TransactionScope - Shows how single/multiple resource managers affect which Transaction
Manager is chosen to handle the scoped transaction. Also gives first look at transaction
promotion detection. 
</td></tr><tr><td valign="top" width="20">
2a.</td><td valign="top">
Mode None - WCF transaction mode with which no transactions are created or flowed
from the calling client. 
</td></tr><tr><td valign="top" width="20">
2b.</td><td valign="top">
Mode Service - WCF transaction mode with which no transactions are flowed from the
calling client, but a transaction is created for your service operation. 
</td></tr><tr><td valign="top" width="20">
2c.</td><td valign="top">
Mode Client - WCF transaction mode with which a transaction is required to be flowed,
and the service will only use the client transaction.</td></tr><tr><td valign="top" width="20">
2d.</td><td valign="top">
Mode Client/Service - WCF transaction mode with which a client transaction will be
flowed and used by the service, if available. If no client transaction is flowed,
a transaction will be provided automatically for the service operation.</td></tr><tr><td valign="top" width="20">
3.</td><td valign="top">
Explicit Voting - Shows how explicit voting with a session-mode service is performed
using OperationContext.Current.SetTransactionComplete(). 
</td></tr><tr><td valign="top" width="20">
4a.</td><td valign="top">
Testing Various Resource Managers - Shows how a client can use a single TransactionScope
to call several services (some transactional, some non-transactional), a database
stored procedure, and an IDesign volatile resource manager Transactional&lt;int&gt;<int>
.
</int></td></tr><tr><td valign="top" width="20">
4b.</td><td valign="top">
Testing Services - Provides a host project for a transactional service and a non-transactional
service used in 4a. 
</td></tr><tr><td valign="top" width="20">
5a.</td><td valign="top">
Tracing - Same as 2d. modified with the additional app.config settings in the client
and host projects to allow for service tracing to .svclog files. 
</td></tr><tr><td valign="top" width="20">
5b.</td><td valign="top">
Tracing Results - Stored results from executing 5a. in case you don't want to load
the database and actually run the projects. The .stvproj file can be opened directly
in the Service Trace Viewer. On the "Activity" table, click on the activity "Process
action 'http://services/gotjeep.net/GpsTrackServiceContract/SubmitTrack'" then click
on the "Graph" tab. You will see that the client and host activities where the arrow
moves from client to host (send and receive message, respectively) show the OleTxTransaction
in "Headers." The next activity in the host reads "The transaction '5bd25b08-848c-409d-9163-6303b9138382:1'
was flowed to operation 'SubmitTrack'."</td></tr></tbody></table><p>
 
</p><p>
Download the session files: 
<br /><a href="content/binary/TransactionalWCF.zip">TransactionalWCF.zip (854 KB)</a></p><img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=c6b29bd9-3388-43b7-b52b-4944aee7e848" /></div>
    </content>
  </entry>
  <entry>
    <title>Jacksonville Code Camp 2009</title>
    <link rel="alternate" type="text/html" href="http://offroadcoder.com/2009/07/15/JacksonvilleCodeCamp2009.aspx" />
    <id>http://offroadcoder.com/PermaLink,guid,e5c6ec12-8927-48de-8831-7850f3db3e4d.aspx</id>
    <published>2009-07-14T21:06:22.6505-07:00</published>
    <updated>2009-07-14T21:06:22.6505-07:00</updated>
    <category term="Dev Community" label="Dev Community" scheme="http://offroadcoder.com/CategoryView,category,DevCommunity.aspx" />
    <category term="General" label="General" scheme="http://offroadcoder.com/CategoryView,category,General.aspx" />
    <category term="WCF" label="WCF" scheme="http://offroadcoder.com/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.jaxdug.com" target="_blank">JaxDug</a> is doing something different
this year having all sponsorship proceeds benefiting <a href="http://www.wolfsonchildrens.org/" target="_blank">Wolfson’s
Children Hospital</a>. In addition to the sponsorship surplus going to Wolfson’s,
there will also be a silent auction at the after-party at Sneaker’s Sports Grille.
</p>
        <p>
There is a great session lineup with eight tracks having five hour-long sessions in
each track. I’ll be presenting one session on Transactional WCF Services. It’s guaranteed
to be a good geeky time, and I hope it will have record attendance this year.
</p>
        <p>
 <a href="http://www.jaxcodecamp.com/" target="_blank">Register now!</a></p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=e5c6ec12-8927-48de-8831-7850f3db3e4d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>I love a good manifesto</title>
    <link rel="alternate" type="text/html" href="http://offroadcoder.com/2009/04/14/ILoveAGoodManifesto.aspx" />
    <id>http://offroadcoder.com/PermaLink,guid,256d431c-d207-4226-8208-fd03303cb87f.aspx</id>
    <published>2009-04-14T16:03:48.889625-07:00</published>
    <updated>2009-04-14T20:02:57.639625-07:00</updated>
    <category term="Cloud" label="Cloud" scheme="http://offroadcoder.com/CategoryView,category,Cloud.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I really like the manifesto’s web site! In the following post, MLB comments on the
Open Cloud Manifesto. 
</p>
        <p>
          <a href="http://www.dasblonde.net/2009/03/31/TheOpenCloudManifestoWhatIThink.aspx" target="_blank">http://www.dasblonde.net/2009/03/31/TheOpenCloudManifestoWhatIThink.aspx</a>
        </p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=256d431c-d207-4226-8208-fd03303cb87f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Developers - Get ready for the future!</title>
    <link rel="alternate" type="text/html" href="http://offroadcoder.com/2009/04/11/DevelopersGetReadyForTheFuture.aspx" />
    <id>http://offroadcoder.com/PermaLink,guid,9f705cfe-f476-48fb-9f4d-a938846d003d.aspx</id>
    <published>2009-04-11T05:51:30.451125-07:00</published>
    <updated>2009-04-11T05:51:30.451125-07:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://offroadcoder.com/CategoryView,category,NETFramework.aspx" />
    <category term="Futures" label="Futures" scheme="http://offroadcoder.com/CategoryView,category,Futures.aspx" />
    <category term="Mobile" label="Mobile" scheme="http://offroadcoder.com/CategoryView,category,Mobile.aspx" />
    <category term="WCF" label="WCF" scheme="http://offroadcoder.com/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Important, proven, and universally-useful technologies like WCF and Mobile are still
not well-known in the development community. Many believe there is another boom, similar
to the 1992 Internet boom, on the horizon that will require skilled and knowledgeable
developers to engineer the framework and associated connecting systems. Staying tech-current
and adapting to our new world is an absolute necessity. Don’t become the COBOL programmer
of the future. Knowing these great system-connecting technologies (WCF, Mobile, Cloud,
etc.) will quickly become a requirement to compete in the software industry.
</p>
        <p>
Check out the following interview with Richard Campbell (DotNetRocks, RunAs Radio)
and Juval Lowy (IDesign) talking about the EnergyNet at the DevConnections conference.
The growing hype about alternative energy and the EnergyNet is stunning. Technology
has progressed far enough where we can start to tie together disparate systems to
benefit producers and consumers alike. 
</p>
        <p>
          <a href="http://video.google.com/videoplay?docid=4831440850220717845" target="_blank">http://video.google.com/videoplay?docid=4831440850220717845</a>
        </p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=9f705cfe-f476-48fb-9f4d-a938846d003d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>The flowed transaction could not be unmarshaled.</title>
    <link rel="alternate" type="text/html" href="http://offroadcoder.com/2009/01/29/TheFlowedTransactionCouldNotBeUnmarshaled.aspx" />
    <id>http://offroadcoder.com/PermaLink,guid,08cef9e9-c8f3-49a5-bd38-dcb303bb9c52.aspx</id>
    <published>2009-01-28T18:39:52.1173488-08:00</published>
    <updated>2009-01-29T17:18:21.986-08:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://offroadcoder.com/CategoryView,category,NETFramework.aspx" />
    <category term="MSDTC" label="MSDTC" scheme="http://offroadcoder.com/CategoryView,category,MSDTC.aspx" />
    <category term="Quotes" label="Quotes" scheme="http://offroadcoder.com/CategoryView,category,Quotes.aspx" />
    <category term="Transactions" label="Transactions" scheme="http://offroadcoder.com/CategoryView,category,Transactions.aspx" />
    <category term="WCF" label="WCF" scheme="http://offroadcoder.com/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <div style="width: 550px">
          <p>
“Do not anticipate trouble, or worry about what may never happen. Keep in the sunlight.” 
</p>
          <p>
  
</p>
          <p align="right">
- Benjamin Franklin
</p>
        </div>
        <p>
  
</p>
        <p>
It’s obvious that Mr. Franklin didn’t have to deal with bad data, bad code, or even
the occasional hiccup. In the real world, there is “trouble” and we need to not only
anticipate that trouble, but also worry about what may never happen. Simply “keeping
in the sunlight” won’t maintain data or application state integrity. In the real world
we need transactions! 
</p>
        <p>
  
</p>
        <p>
Since .NET 2.0, we’ve had the privilege of using <em>System.Transactions.TransactionScope</em> to
manage our transactions with very few headaches. One of the headaches that almost
everyone experiences is MSDTC. One of the oldest and most elusive topics on the web.
There are tons of blog and forum posts directing our fellow developers to check their
firewall settings for every MSDTC problem. The latest MSDTC hiccup I have seen comes
in the beautifully packaged error message: 
</p>
        <blockquote>
          <p>
            <strong>The flowed transaction could not be unmarshaled. The following exception occurred:
Communication with the underlying transaction manager has failed.</strong>
          </p>
        </blockquote>
        <p>
The what could not be what? You can read some <a href="http://msdn.microsoft.com/en-us/library/cc229833(PROT.10).aspx " target="_blank">MSDN
documentation on the topic</a> which will probably cause you more pain. If you are
seeing this error message, there’s only a few things that may be wrong. 
</p>
        <ol>
          <li>
MSDTC Settings 
<ul><li>
Check the MSDTC settings on the machine that is initiating the transaction. If “Allow
Outbound” is not checked, then it won’t allow the transaction in progress to be flowed
to the next machine in the transaction chain. Check the box and restart MSDTC… it
should work.</li></ul></li>
          <li>
Un-Trusted Domains 
<ul><li>
I have seen this error when you are trying to flow transactions between machines that
are in un-trusted domains. Machines in different domains that do not trust each other
block the antiquated, yet necessary, WINS resolution between the two machines. MSDTC
relies on WINS resolution. I have fixed this problem before by adding host file entries
on both machines pointing to the other machine. I can’t guarantee that this will work
in all cases. Both of those machines are no longer under my control.</li></ul></li>
          <li>
Imaged Servers 
<ul><li>
The most recent, and most blogged about problem is surprisingly caused by two machines
created from the same image. Cloning or imaging servers is quite common. Building
a server from scratch is not a fun activity, so we build one, create an image, and
put that image on every server we want to build after that. Once again, MSDTC is standing
in our way because of the way it detects the sending and receiving application’s unique
identifier. Each machine has a GUID in the registry that identifies it uniquely as
a participant in an MSDTC transaction. Imaged machines have the same GUID. I’ll talk
about the detection and resolution of this for the remainder of this post.</li></ul></li>
        </ol>
        <p>
Running DtcPing.exe between the two machines will actually tell you that the machines
are using the same GUID. Output window text from DtcPing shown below.
</p>
        <blockquote>
          <p>
            <font face="Consolas" size="2">DTCping log file: C:\DTC Ping\THRESHER4160.log<br />
Firewall Port Settings:<br />
Port:5150-5250<br />
RPC server is ready<br />
Please Start Partner DTCping before pinging<br /><font color="#ff0000"><strong>WARNING:the CID values for both test machines are the
same</strong><br /></font>Please send following LOG to Microsoft for analysis:<br />
Partner LOG: SCORPION6128.log<br />
My LOG: THRESHER4160.log</font>
          </p>
        </blockquote>
        <p>
Tucked away in the last step of a Microsoft Knowledge Base article titled <a href="http://support.microsoft.com/kb/306843" target="_blank">"How
to troubleshoot MS DTC firewall issues"</a> is a reference to this problem. Use regedit.exe
to look at the registry on both machines. Locate the HKEY_CLASSES_ROOT\CID key in
the registry. 
</p>
        <p>
          <a href="http://scott.klueppel.net/content/binary/Theflowedtransactioncouldnotbeunmarshal_124C3/CID.png">
            <img title="Find your MSDTC CID in the registry" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="371" alt="Find your MSDTC CID in the registry" src="http://scott.klueppel.net/content/binary/Theflowedtransactioncouldnotbeunmarshal_124C3/CID_thumb.png" width="771" border="0" />
          </a>
        </p>
        <p>
Find the CID key that has a description value of “MSDTC”. If they are the same, the
transaction cannot flow. 
</p>
        <p>
          <strong>WARNING:</strong> Back up your registry before making any changes!
</p>
        <p>
          <strong>Solution 1 - Replace the offending CID keys/values on one of the machines: </strong>In
this case, you will need to find all keys/values with GUID 28b81f1c-2afb-4ee2-ad85-5bc62dad1647
in your registry and replace it with a new GUID (using GuidGen). There is likely to
be 3 places this GUID appears. It is also important to note that the offending GUID
appears in the DtcPing log file generated during the ping test.
</p>
        <p>
          <strong>Solution 2 – Use msdtc command line tool to re-install MSDTC: </strong>The
commands are simply:
</p>
        <blockquote>
          <p>
            <font face="consol" size="2">msdtc -uninstall<br />
msdtc -install</font>
          </p>
        </blockquote>
        <p>
After making the registry changes or running the msdtc command line tool, you must
restart your server for the changes to take effect.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=08cef9e9-c8f3-49a5-bd38-dcb303bb9c52" />
      </div>
    </content>
  </entry>
</feed>