<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://codebetter.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>Peter's Gekko </title><link>http://codebetter.com/blogs/peter.van.ooijen/default.aspx</link><description>public Blog MyNotepad : Imho
{
}</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>A simple WCF service with username password authentication: the things they don’t tell you</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2010/03/22/a-simple-wcf-service-with-username-password-authentication-the-things-they-don-t-tell-you.aspx</link><pubDate>Mon, 22 Mar 2010 11:35:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:693944</guid><dc:creator>pvanooijen</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=693944</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2010/03/22/a-simple-wcf-service-with-username-password-authentication-the-things-they-don-t-tell-you.aspx#comments</comments><description>&lt;p&gt;The WCF framework is gigantic. It has such an enormous amount of possibilities that it&amp;rsquo;s pretty easy to get completely lost. For our scenario we needed just a small basic subset. Our application provides a set of services which are consumed by a diversity of clients which have to tell who they are by providing a custom&amp;nbsp; username and password. There are loads and loads of documents and manuals to be found on the web but I didn&amp;rsquo;t find anything which gave me the complete story. Most of them follow all kinds of sidesteps in other parts of the rich WCF framework. Things we didn&amp;rsquo;t need at all, the things we needed to get our stuff to work were either omitted or only mentioned briefly in a comment.&lt;/p&gt;
&lt;p&gt;This post tries to describe the full story. It will try to keep quiet on all noise on other cool, but unneeded, features. This information is assembled from a rich variety of stuff on the web and error messages provided by the WCF framework itself. The latter are often quite to the point and provide a lot of essential information. This post is just a kind of cookbook recipe, I don&amp;rsquo;t claim to understand every detail and would appreciate any comment to further clarify the details.&lt;/p&gt;
&lt;h2&gt;The service&lt;/h2&gt;
&lt;p&gt;The service is an ASP.NET service, hosted by IIS and configured in the system.ServiceModel part of the web.config.&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;services&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;service&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;F&lt;span style="color:blue;"&gt;armService.CustomerDeskOperationsBehavior&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;F&lt;span style="color:blue;"&gt;armService.CustomerDeskOperations&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;endpoint&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;address&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;binding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;wsHttpBinding&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;RequestUserName&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;contract&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;F&lt;span style="color:blue;"&gt;armService.ICustomerDeskOperations&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;endpoint&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;endpoint&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;address&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;mex&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;binding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;mexHttpBinding&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;contract&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;IMetadataExchange&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;service&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;services&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;The endpoint address is the root of the IIS site in which it his hosted. To use username authentication you need to use wsHttpBinding. The services functionality is described in the ICustomerDeskOperations contract.&lt;/p&gt;
&lt;p&gt;In the binding you specify the credential type as username.&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;bindings&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;wsHttpBinding&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;binding&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;RequestUserName&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;security&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Message&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;message&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;clientCredentialType&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;UserName&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;security&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;binding&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;In the servicebehaviour you set up how the username is going to be validated&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;behaviors&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;behavior&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;FarmService.CustomerDeskOperationsBehavior&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;serviceMetadata&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;httpGetEnabled&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;true&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;serviceCredentials&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;userNameAuthentication&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;userNamePasswordValidationMode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Custom&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;customUserNamePasswordValidatorType&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;FarmService.Authentication.DistributorValidator, FarmService&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;serviceCertificate&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;findValue&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Farm&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;storeLocation&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;LocalMachine&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;storeName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;TrustedPeople&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;x509FindType&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;FindBySubjectName&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;serviceCredentials&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;behavior&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;The username is custom validated. This is done by the &lt;em&gt;FarmService.Authentication.DistributorValidator&lt;/em&gt; class in the &lt;em&gt;FarmService&lt;/em&gt; assembly. This class inherits from WCF class &lt;em&gt;UserNamePasswordValidator&lt;/em&gt; and overrides the &lt;em&gt;Validate&lt;/em&gt; method.&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DistributorValidator&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;UserNamePasswordValidator&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{ &lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Validate(&lt;span style="color:blue;"&gt;string&lt;/span&gt; userName, &lt;span style="color:blue;"&gt;string&lt;/span&gt; password)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;if&lt;/span&gt; (&lt;span style="color:blue;"&gt;string&lt;/span&gt;.IsNullOrEmpty(userName) || &lt;span style="color:blue;"&gt;string&lt;/span&gt;.IsNullOrEmpty(password))&lt;/p&gt;
&lt;p style="margin:0px;"&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 style="color:blue;"&gt;throw&lt;/span&gt; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;SecurityTokenException&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;Username and password required&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; repository = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DistributorRepository&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;if&lt;/span&gt; (! repository.IsKnownDistributor(userName, password))&lt;/p&gt;
&lt;p style="margin:0px;"&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 style="color:blue;"&gt;throw&lt;/span&gt; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;FaultException&lt;/span&gt;(&lt;span style="color:blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515;"&gt;&amp;quot;Wrong username ({0}) or password &amp;quot;&lt;/span&gt;, userName));&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;The method validates the incoming username and password in a repository and throws appropriate exceptions when needed. This is really custom code. As long as you don&amp;rsquo;t throw an exception the service invocation will be accepted.&lt;/p&gt;
&lt;p&gt;So far this could have been a copy of many a story on the web. Except for one detail which is absolutely essential. For username password authentication to work your server hosting the service needs an X509 certificate. Else all service invocations will fail. This certificate is specified in the service behavior.&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;serviceCertificate&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;findValue&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Farm&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;storeLocation&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;LocalMachine&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;storeName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;TrustedPeople&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;nbsp; x509FindType&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;FindBySubjectName&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;First you need a certificate. Instead of buying one (which is bound to a specific server address and thereby as good as useless for testing purposes) you can create your own. The .net framework comes with tools to generate these and there are several tutorials how to use these tools. Far more easier is &lt;a href="http://www.pluralsight-training.net/community/blogs/keith/archive/2009/01/22/create-self-signed-x-509-certificates-in-a-flash-with-self-cert.aspx"&gt;selfcert&lt;/a&gt; a &lt;a href="http://www.pluralsight-training.net/microsoft/"&gt;pluralsight&lt;/a&gt; tool which takes care of the whole process in a couple of clicks.&lt;/p&gt;
&lt;p&gt;What they don&amp;rsquo;t tell you here is that you have to run the tool as administrator, else it will crash most ungracefully. What the tool is also unclear about is where to store the generated certificate. By default it is stored in &lt;em&gt;MyStore&lt;/em&gt;. When validating the certificate it&amp;rsquo;s trustworthiness depends on the location it is stored. When the store is not trusted a chain of validation is started. Instead of setting up a chain of certificates you can also directly store your certificate in a trusted store.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/SelfCert_5F00_5810E1BA.png"&gt;&lt;img height="431" width="576" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/SelfCert_5F00_thumb_5F00_133497B9.png" alt="SelfCert" border="0" title="SelfCert" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;With these settings the certificate is stored in a trusted location. The name and location match the settings in the service behavior&lt;/p&gt;
&lt;p&gt;Troubles don&amp;rsquo;t end here. After a while, like logging in the next time, the service host will start complaining it cannot find the private key of the certificate with a &amp;ldquo;Keyset does not exist&amp;rdquo; error message. What happens it that the service no longer has the access right to read the certificate. What helped me was explicitly setting rights on the certificate&amp;rsquo;s private key file.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/SelfCert2_5F00_56ABFD41.png"&gt;&lt;img height="522" width="556" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/SelfCert2_5F00_thumb_5F00_53A672C1.png" alt="SelfCert2" border="0" title="SelfCert2" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here I am using a blunt axe by just allowing everybody read rights on the certificate&amp;rsquo;s private key file. I&amp;rsquo;m no security expert but I am aware this is absolutely not the way to do things. But hey, I only want to build a service, never asked for this certificate stuff and the only thing I want to do here is get that out of the way in the development process.&lt;/p&gt;
&lt;p&gt;Now the service is ready to be consumed by a client&lt;/p&gt;
&lt;h2&gt;The client&lt;/h2&gt;
&lt;p&gt;To consume this service add a service reference in the client. The mexHttpBinding in the service configuration enables to read all metadata form the service without any credentials.&lt;/p&gt;
&lt;p&gt;Setting up a connection to the client requires some fiddling. Again not all of these settings are clear by default. &lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; endPoint = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EndpointAddress&lt;/span&gt;(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;Farm&lt;/span&gt;.FarmUrl), &lt;span style="color:#2b91af;"&gt;EndpointIdentity&lt;/span&gt;.CreateDnsIdentity(&lt;span style="color:#a31515;"&gt;&amp;quot;Farm&amp;quot;&lt;/span&gt;));&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; binding = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;WSHttpBinding&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;binding.Security.Mode = &lt;span style="color:#2b91af;"&gt;SecurityMode&lt;/span&gt;.Message;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;binding.Security.Message.ClientCredentialType = &lt;span style="color:#2b91af;"&gt;MessageCredentialType&lt;/span&gt;.UserName;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; result = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;CustomerDeskOperationsClient&lt;/span&gt;(binding, endPoint);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;result.ClientCredentials.UserName.UserName = &lt;span style="color:#2b91af;"&gt;Farm&lt;/span&gt;.FarmUserName;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;result.ClientCredentials.UserName.Password = &lt;span style="color:#2b91af;"&gt;Farm&lt;/span&gt;.FarmPassword;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;First we need an endpoint. This is assembled from the url in the client&amp;rsquo;s configuration, here a constant &lt;em&gt;Farm.FarmUrl&lt;/em&gt;. For the custom username authentication to work the endpoint also needs an &lt;em&gt;EndpointIndentity&lt;/em&gt;. According to the sparse msdn documentation this is to prevent phishing. The fact that the identity was needed and the parameter had to be the certificate&amp;rsquo;s name was suggested by the WCF error messages.&lt;/p&gt;
&lt;p&gt;The security is set according to the security settings we have seen in the service. Both the username and password are set in &lt;em&gt;UserName&lt;/em&gt; property of the &lt;em&gt;ClientCredentails&lt;/em&gt;.&lt;/p&gt;
&lt;h2&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;This is it. Now our service and clients are talking. But it took far to much effort to find the right settings. The number is not great, but they all were found to be essential. Finding the right was a process of endlessly weeding out all sidesteps. I hope this well help you to get it done a little faster. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=693944" width="1" height="1"&gt;</description></item><item><title>Ubiquitous and unambiguous ?</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2010/03/07/ubiquitous-and-unambiguous.aspx</link><pubDate>Sun, 07 Mar 2010 16:45:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:669389</guid><dc:creator>pvanooijen</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=669389</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2010/03/07/ubiquitous-and-unambiguous.aspx#comments</comments><description>&lt;p&gt;My last &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2010/02/19/ubiquitous-language-leaking-in-the-wrong-direction.aspx"&gt;musings on a observed misuse of ubiquitous language&lt;/a&gt; (UL) led to deeper comments than I had ever realized when writing the story down. &lt;/p&gt;
&lt;p&gt;To many a non native speaker ubiquitous is at first hearing a strange word, as far as I know it is not widely used outside the world of IT. The sounding reminds of (un-)ambiguous, a term often found in the same context. There is a relation between these two words and IMHO that was the heart of the comments and led me to take another dive into the idea of UL.&lt;/p&gt;
&lt;p&gt;The term Ubiquitous Language was brought to the world of software by Eric Evans in his classic &lt;a href="http://books.google.co.uk/books?id=7dlaMs0SECsC&amp;amp;dq=eric+evans+domain+driven+design&amp;amp;printsec=frontcover&amp;amp;source=bn&amp;amp;hl=en&amp;amp;ei=rtWTS5LLBMqD-QbWkOGaBg&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=4&amp;amp;ved=0CBoQ6AEwAw#v=onepage&amp;amp;q=&amp;amp;f=false"&gt;book&lt;/a&gt; &lt;a href="http://domaindrivendesign.org/"&gt;Domain Driven Design&lt;/a&gt; (DDD). Where it is defined as a language based on a model and spoken by both domain experts and developers. It should be &amp;ldquo;more robust than the lowest common denominator&amp;rdquo; (p.25). Domain experts &amp;ldquo;should object to terms or structures that are .. inadequate to domain understanding&amp;rdquo; and developers &amp;ldquo;should watch for ambiguity ..&amp;rdquo; (p.27) So a good UL is a powerful common unambiguous language spoken by all &lt;em&gt;experts&lt;/em&gt;, whatever their background, to communicate on a software system.&lt;/p&gt;
&lt;p&gt;Note the stress on the word expert. Now some people involved are not an expert. Take the old lady in my &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2010/02/19/ubiquitous-language-leaking-in-the-wrong-direction.aspx"&gt;previous story&lt;/a&gt;, the recipient of UL. She might be very good in choosing what to buy and finding her way to the counter but when it comes to the technical rules of dealing with her payment she has all the right in the world to be a nitwit. As a domain expert you can consider her as something outside of the domain. To communicate in a safe way you can use an anti corruption layer (ACL). For the outgoing messages it will translate a lot of the domain specific facts and rules into a subset of commands like &amp;ldquo;Don&amp;rsquo;t do this&amp;rdquo; and &amp;ldquo;Please do that&amp;rdquo;. Which is perhaps not too friendly but at least it is unambiguous. But when it comes to incoming messages things get bad. These messages will be quite ambiguous. Like &amp;ldquo;I don&amp;rsquo;t understand&amp;rdquo;, without the sender even being able to make clear what she does not understand. Here we have a many to one mapping for outgoing messages and a one to many mapping for incoming messages. Where the latter can be quite ambiguous. &amp;ldquo;Would you please be so kind to explain &lt;em&gt;what&lt;/em&gt; it is you don&amp;rsquo;t understand ?&amp;rdquo;. &lt;/p&gt;
&lt;p&gt;The core of this problem is IMHO not an IT issue, it is just that the modern technological world is becoming too complex for more and more people. Be prepared for that yourself to. Just wait for the moment when you are going to give up on the new toolkit or methodology. That moment will come. According to the &lt;a href="http://en.wikipedia.org/wiki/Peter_Principle"&gt;Peter principle&lt;/a&gt; I am almost there myself :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=669389" width="1" height="1"&gt;</description></item><item><title>Ubiquitous language leaking in the wrong direction</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2010/02/19/ubiquitous-language-leaking-in-the-wrong-direction.aspx</link><pubDate>Fri, 19 Feb 2010 15:34:07 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:640917</guid><dc:creator>pvanooijen</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=640917</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2010/02/19/ubiquitous-language-leaking-in-the-wrong-direction.aspx#comments</comments><description>&lt;p&gt;This is a little musing on something I observed in a supermarket the other day. Over here (in the Netherlands) more and more shop payments are handled online. The employee scans the shopping, the counter sums up the amount due and the customer sweeps a card to authorize a payment from her account to the shop’s account. Behind the scenes there is a quite interesting domain with loads and loads of fodder for stories on software design. For the public quite handy and also the older generations, having used cash their entire life, are using it en masse.&lt;/p&gt;  &lt;p&gt;The other day there was an old lady next in my counter line. Proudly she was waving her card, feeling all part of modernity. Until the employee told her “The transaction cannot be started until the first article is scanned”. To me this was a very informative piece of domain specific ubiquitous language. But the old lady felt like an alien living in a world she no longer understood and started looking for her purse.&lt;/p&gt;  &lt;p&gt;At first it only made me realize that an ubiquitous language may be quite informative and precise for people working inside the domain but that that same jargon and strictness scares a lot of (potential) users of the domain being discussed.&lt;/p&gt;  &lt;p&gt;Later on I realized that the employee had made an even bigger mistake. The customer herself is not a part of the domain at all. The shopping’s are a part and her card is a part. But by addressing the customer herself the assumption is made that the shopping’s and the payment are associated with one and the same person. The shop doesn’t care as long as somebody pays. The shopping’s don’t care as long they leave the shop. Who needs a customer ? &lt;/p&gt;  &lt;p&gt;The domain does need a customer to use it. But don’t hassle her with language never intended to leak out of the domain.&lt;/p&gt;  &lt;p&gt;My 2 e-Cents&lt;/p&gt;  &lt;p&gt;&amp;lt;Post scriptum&amp;gt;&lt;/p&gt;  &lt;p&gt;The comments on this make it clear there are two ways you can view the situation. Each with different implications. What the real problem was depends on the position of the lady in the story.&lt;/p&gt;  &lt;p&gt;1. She is not a part of the domain, only an actor providing some input. Like passing in some shopping and passing in a payment. This actor (or these actors, in case somebody else is going to pay) needs some instructions. In a language which she understands. But even when the terms in the language, like transaction, article and scan are replaced with words of her choice it would be only confusing to her to expose the rules of the domain to her. It would be far better to just tell her “Please wait swiping your card until I tell you to do so”. But that doesn’t really map on the UL spoken inside the domain.&lt;/p&gt;  &lt;p&gt;In this scenario there is just no UL which is understood by everybody. It’s just the shop employee uttering impropriate language.&lt;/p&gt;  &lt;p&gt;2. The lady is part of the domain. In this case the interface between shopper and counter is not that good. As it exposes behavior which cannot be granted to be understood. Or at least should be expressed in a better language.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In both views the language is the problem. Speak in a language clearly understood by the receiver. Or just keep quiet.&lt;/p&gt;  &lt;p&gt;&amp;lt;/Post scriptum&amp;gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=640917" width="1" height="1"&gt;</description></item><item><title>From Hyper-V back (?) to Virtual PC</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2010/01/31/from-hyper-v-back-to-virtual-pc.aspx</link><pubDate>Sun, 31 Jan 2010 13:56:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:612423</guid><dc:creator>pvanooijen</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=612423</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2010/01/31/from-hyper-v-back-to-virtual-pc.aspx#comments</comments><description>&lt;p&gt;For over a year I have been &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2008/09/15/nice-laptop-for-a-developer-running-windows-workstation-2008.aspx"&gt;using Server 2008, 64 bits, as OS for my laptop&lt;/a&gt;. The main reason for this platform was Hyper-V. Almost every other project I&amp;rsquo;ve been working on needs another virtual server.&amp;nbsp; And each location I am working has a different network. With Hyper-V both switching servers and &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2009/11/12/switching-virtual-networks-the-easy-way.aspx"&gt;switching networks&lt;/a&gt; works fast and good. The downside of using Hyper &amp;ndash;V is that it knocks out all possibilities of hibernating or putting my laptop to sleep. &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2009/09/22/windows-workstation-2008-r2-an-even-better-os-for-a-laptop.aspx"&gt;Server 2008 R2 boots a lot faster&lt;/a&gt;, but still. Another downside is that to use Hyper-V you have to run the 64 bit versions, R2 only comes 64 bits. Visual studio is a 32 bit app, runs OK on 64 bits but it is still not the most stable piece of software I know.&lt;/p&gt;
&lt;p&gt;Due to &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2009/12/29/new-year-new-address.aspx"&gt;circumstances&lt;/a&gt; I had to use my laptop more and more in typical mobile situations. Also the way my colleague presses the power button, is back where he was, does his thing, closes the lid and just walks away made me a little jealous. Perhaps I should move on to Windows 7 and try Virtual PC 2009. I had &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2009/05/20/a-first-glimpse-of-virtualization-in-windows-7.aspx"&gt;played with that combination&lt;/a&gt; and it looked promising.&lt;/p&gt;
&lt;p&gt;To see if this was a good idea I set up some some tests &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Is it possible to migrate the hyper-V virtual machines to Windows 7 virtual PC ?&lt;/li&gt;
&lt;li&gt;Can you switch networks in a virtual machine without the need of a reboot ?&lt;/li&gt;
&lt;li&gt;How does a running virtual machine survive a sleeping machine ?&lt;/li&gt;
&lt;li&gt;How does a running virtual machine survive hibernation ?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;All version of hyper-V and virtual PC share the same virtual hard disk (vhd) format. They differ on the integration features, some piece of host specific software installed on the virtual machine to facilitate all communication with virtual machine. Both Hyper-V and Virtual PC have &amp;ldquo;Install integration features&amp;rdquo; as menu option.&lt;/p&gt;
&lt;p&gt;As a test candidate I took a virtual machine with quite a history. It started its life in Virtual PC 200x as a Windows server 2003 machine with several monsters of sql 8 databases, sql reporting services and some COM custom app. Over the years it had been upgraded tot server 2008 and been living under several versions of Virtual server and Hyper &amp;ndash;V. Not something to rebuild from scratch, just getting that version of reporting service to work is a piece of science on itself. In short: a typical real world machine. Under the several host OS-es it had seen several completely different versions of integration services. These were pretty screwed up. Every attempt to install the newest integration services resulted in messages complaining about previous versions. But the machine still worked.&lt;/p&gt;
&lt;h3&gt;Migrating&lt;/h3&gt;
&lt;p&gt;The official recipe to migrate a virtual machine is to uninstall integration services, move the machine and reinstall the integration services of the new host. But you will not find integration services under the installed programs. All attempts to uninstall form the command prompt (/Uninstall) only resulted in the same messages about previous versions.&lt;/p&gt;
&lt;p&gt;What worked is changing the HAL (Hardware Abstraction Layer) of the virtual machine:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Start MSconfig&lt;/li&gt;
&lt;li&gt;Boot Tab&lt;/li&gt;
&lt;li&gt;Advanced Options&lt;/li&gt;
&lt;li&gt;Check the &amp;ldquo;detect HAL&amp;rdquo; box&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After that I just shut down the machine, copied the hard disk and created a new virtual machine in W7 Virtual PC using the copied vhd file as hard disk.&lt;/p&gt;
&lt;p&gt;The machine booted and complained about requiring new drivers. It also required renewed activation. I installed the W7 Virtual PC integration services and allowed the renewed activation (which is never a problem with MSDN OS licenses). And after that the machine just worked fine. All integration was smooth, all software had perfectly survived the migration.&lt;/p&gt;
&lt;h3&gt;Switching networks&lt;/h3&gt;
&lt;p&gt;I can be short on this. This works &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2009/11/12/switching-virtual-networks-the-easy-way.aspx"&gt;just as smooth as in Hyper-V&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AA1_5F00_60D48EF4.png"&gt;&lt;img height="492" width="479" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AA1_5F00_thumb_5F00_047D90C2.png" alt="AA1" border="0" title="AA1" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Changing the adapter in the settings is instantaneously reflected in the status of the virtual machines adapter. The good thing is that everything works just as well with an adapter with a dynamic IP address as with one with a static address.&lt;/p&gt;
&lt;h3&gt;Sleep and Hibernate&lt;/h3&gt;
&lt;p&gt;The difference between sleep and hibernate is that in sleep mode the RAM of the PC is still powered, so actually the machine is still alive. In hibernate mode all RAM is saved to and restored from disk. &lt;/p&gt;
&lt;p&gt;In Hyper-V the virtual machines are running on the machine level. In virtual PC you start a virtual machine as a logged in user. When logging off the virtual machines are shut down (or hibernated). Instead of logging of I tried both sleep and hibernate with the virtual machine still running. Again all news is good. All functionality completely survives both scenarios. Virtual PC is not ignorant of my actions. When hibernating it will (automatically) disable the integration services. When awakening it restores them.&lt;/p&gt;
&lt;h3&gt;To conclude&lt;/h3&gt;
&lt;p&gt;The only hurdle I had to take was the HAL setting when migrating the machine. All the rest just worked. So I repaved my laptop with Windows 7 and virtual PC 2009. (Just skip the virtual XP step unless you need a virtual XP machine). I was quite satisfied with Server 2008 (except the required full boot) but do like Windows 7 even better. VS worked well and now even works better. But that could be the result of a fresh install (there is no upgrade possible from 2008 to 7).&lt;/p&gt;
&lt;p&gt;And now I can also close the lid of my laptop and leave the building.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=612423" width="1" height="1"&gt;</description></item><item><title>Why choose between Ajax or MVC ? Together they KISS so sweet…</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2010/01/18/why-choose-between-ajax-or-mvc-together-they-kiss-so-sweet.aspx</link><pubDate>Mon, 18 Jan 2010 10:38:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:594217</guid><dc:creator>pvanooijen</dc:creator><slash:comments>9</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=594217</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2010/01/18/why-choose-between-ajax-or-mvc-together-they-kiss-so-sweet.aspx#comments</comments><description>&lt;p&gt;Technology comes in waves. Over the years we have been drowned by several waves of web development technologies from MS. ASP, ASP.NET, ASP.NET Ajax and now there is ASP.MVC. A new wave does bring nice new things but also has the tendency to wash away the things brought by the one before. Also for the users of the software we create. Thanks to partial postbacks ASP.NET Ajax brought the user a far more pleasant view in the browser. Not every click resulted in a full screen refresh with its disturbing flickering. And the possibilities of javascript gave more room for screen candy. ASP.MVC, the next wave, still does care a lot about the possibilities of script but partial rendering has moved somewhat to the background of attention. Most MVC documentation and examples describe a full rebuild of the page. Bringing the user back to the well known restless browser screens.&lt;/p&gt;  &lt;p&gt;But ASP.MVC is full of Ajax possibilities. It is even easier to build ajax style apps than in ASP.NET ajax. In this post I will first present the basics and give some hints to create a popup screen. Not one in a new window but one which can easily communicate with the document which created it.&lt;/p&gt;  &lt;h5&gt;Partial views&lt;/h5&gt;  &lt;p&gt;In MVC the basics for a partial screen update are present&amp;#160; in the form of partial views. They are regular ascx usercontrols.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AkM1_5F00_4D4E802B.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="AkM1" border="0" alt="AkM1" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AkM1_5F00_thumb_5F00_565B0BAC.png" width="393" height="421" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Inside straightforward MVC scaffolded markup, including the possibility to use a strong typed model&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:#a31515;"&gt;Control&lt;/span&gt; &lt;span style="color:red;"&gt;Language&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Inherits&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;System.Web.Mvc.ViewUserControl&amp;lt;MyModel&amp;gt;&amp;quot;&lt;/span&gt; &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:#a31515;"&gt;Import&lt;/span&gt; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;AjaxKissesMVC.Models&amp;quot;&lt;/span&gt;&lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt; &lt;span style="color:blue;"&gt;=&lt;/span&gt;Model.MyProperty &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; foreach (var item in Model.MyList)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; { &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; =Ajax.ActionLink(item, &amp;quot;Partial&amp;quot;, new {routeValue = item}, new AjaxOptions {}) &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:red;"&gt;&amp;amp;nbsp;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;More on the ActionLink later on. This is My Model&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MyModel&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;{&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; MyModel()&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyProperty = &lt;span style="color:#a31515;"&gt;&amp;quot;This is my model&amp;quot;&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;gt; myList = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;gt;() {&lt;span style="color:#a31515;"&gt;&amp;quot;One&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;Two&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;Three&amp;quot;&lt;/span&gt;};&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; MyProperty { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;gt; MyList&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;get&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;return&lt;/span&gt; myList;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;}&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;You assemble a page from usercontrols using the renderpartial method of the html extension class&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Content&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;indexContent&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;ContentPlaceHolderID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;MainContent&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;server&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;h2&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt; Html.Encode(ViewData[&lt;span style="color:#a31515;"&gt;&amp;quot;Message&amp;quot;&lt;/span&gt;]) &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;h2&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;p&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt; Html.RenderPartial(&lt;span style="color:#a31515;"&gt;&amp;quot;MyPartialView&amp;quot;&lt;/span&gt;, &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MyModel&lt;/span&gt;()); &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;p&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Content&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;The ajax stuff needs extra script libraries. Include these in your masterfile&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;html&lt;/span&gt; &lt;span style="color:red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;head&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;server&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;title&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ContentPlaceHolder&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;TitleContent&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color:blue;"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;title&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;link&lt;/span&gt; &lt;span style="color:red;"&gt;href&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;../../Content/Site.css&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;rel&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;text/css&amp;quot;&lt;/span&gt; &lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script&lt;/span&gt; &lt;span style="color:red;"&gt;src&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;/Scripts/MicrosoftAjax.debug.js&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script&lt;/span&gt; &lt;span style="color:red;"&gt;src&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;/Scripts/MicrosoftMvcAjax.debug.js&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;head&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;h5&gt;Async postbacks&lt;/h5&gt;  &lt;p&gt;The code so far produces this result.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AkM2_5F00_00E6C6BD.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="AkM2" border="0" alt="AkM2" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AkM2_5F00_thumb_5F00_189DFE23.png" width="566" height="383" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Three hyperlinks, as dictated by my model. As they are created by the ajax-, and not the html-, extension class they will do an async partial postback. &lt;/p&gt;  &lt;p&gt;These requests are also caught by the home controller.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HomeController&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;Controller&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;{&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ActionResult&lt;/span&gt; Partial(&lt;span style="color:blue;"&gt;string&lt;/span&gt; routeValue)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;return null&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;What the action returns does not matter yet, for now I just return null. The reason it does not matter yet is because the actionlink has not defined a target to receive the result of the action.&lt;/p&gt;  &lt;p&gt;An ajax actionlink has as obligatory parameter an AjaxOptions object. So far I had created an empty object. A list of the properties of the AjaxOptions class is shown by Intellisense&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AkM3_5F00_369C0C17.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="AkM3" border="0" alt="AkM3" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AkM3_5F00_thumb_5F00_42515349.png" width="613" height="360" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The updatetargetId is the id of any DOM element. Like an ordinary div. On the main page I will add an empty div as placeholder for the result of the async postback&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Content&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;indexContent&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;ContentPlaceHolderID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;MainContent&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;server&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;h2&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt; Html.Encode(ViewData[&lt;span style="color:#a31515;"&gt;&amp;quot;Message&amp;quot;&lt;/span&gt;]) &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;h2&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;p&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt; Html.RenderPartial(&lt;span style="color:#a31515;"&gt;&amp;quot;MyPartialView&amp;quot;&lt;/span&gt;, &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MyModel&lt;/span&gt;()); &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;p&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt; &lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;yourselection&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Content&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;(It would be tempting to code the div as &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt; &lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;yourselection&amp;quot;/&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;, &lt;/span&gt;but that will spoil the trick.)&lt;/p&gt;  &lt;p&gt;This div is going to be the updatetarget for the ajax action link&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;=Ajax.ActionLink(item, &amp;quot;Partial&amp;quot;, new {routeValue = item}, new AjaxOptions {UpdateTargetId = &amp;quot;yourselection&amp;quot;}) &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Now the controller has a target for its result. I create another simple partial view to return&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:#a31515;"&gt;Control&lt;/span&gt; &lt;span style="color:red;"&gt;Language&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Inherits&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;System.Web.Mvc.ViewUserControl&amp;lt;MySelection&amp;gt;&amp;quot;&lt;/span&gt; &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:#a31515;"&gt;Import&lt;/span&gt; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;AjaxKissesMVC.Models&amp;quot;&lt;/span&gt;&lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;On &lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;Model.SelectedTime &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt; you selected &lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;Model.SelectedValue &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;This view uses another simple model&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MySelection&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;{&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; MySelection(&lt;span style="color:blue;"&gt;string&lt;/span&gt; selectedValue)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SelectedValue = selectedValue;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SelectedTime = &lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt;.Now.ToLongTimeString();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; SelectedValue { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; SelectedTime { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;set&lt;/span&gt;;}&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;}&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;The model is passed to this partial view and this partial view will be the result of the action&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HomeController&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;Controller&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;{&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ActionResult&lt;/span&gt; Partial(&lt;span style="color:blue;"&gt;string&lt;/span&gt; routeValue)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;return&lt;/span&gt; View(&lt;span style="color:#a31515;"&gt;&amp;quot;Selected&amp;quot;&lt;/span&gt;,&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MySelection&lt;/span&gt;(routeValue));&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;The result of the partial postback is now that the div will be filled by the contents of the usercontrol.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AkM4_5F00_18FA0B4B.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="AkM4" border="0" alt="AkM4" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AkM4_5F00_thumb_5F00_6FA2C34C.png" width="686" height="430" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;That is all there is to the basics to create aync postbacks and do partial rendering. All pretty straightforward. And with loads of possibilities to enrichen behavior.&lt;/p&gt;  &lt;h5&gt;Creating a pop up&lt;/h5&gt;  &lt;p&gt;As a small example I will now present the basics of a (not the) way to do a popup screen. Creating a popup in a new browser window has quite a few drawbacks. Your application loses control of the window and communicating between the two DOM’s in the separate windows is no fun either. It is so much easier to have your popup and its contents in the same document.&lt;/p&gt;  &lt;p&gt;Plain old HTML (POH ?) has the possibility to render itself in layers. Each layer has it’s own z-index. I will now add the target of the async postback as a new layer to the master page&lt;/p&gt;  &lt;p&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;body&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt; &lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;yourselection&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;style&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:red;"&gt;z-index&lt;/span&gt;:&lt;span style="color:blue;"&gt;2&lt;/span&gt;; &lt;span style="color:red;"&gt;position&lt;/span&gt;:&lt;span style="color:blue;"&gt;absolute&lt;/span&gt;;&lt;span style="color:blue;"&gt;&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt; &lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;page&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt; &lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;header&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt; &lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;title&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;h1&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;My MVC Application&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;h1&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;The z-index attribute makes it a new layer. A new layer in the same document. The position:absolute attribute ensures independent positioning from the underlying layer. To see the effect the resulting partial view of the async postback is decorated with a style. &lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;&lt;span style="color:#a31515;"&gt;     &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;       &lt;p style="margin:0px;"&gt;&lt;span style="color:#a31515;"&gt;.popup&lt;/span&gt;&lt;/p&gt;        &lt;p style="margin:0px;"&gt;{&lt;/p&gt;        &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:red;"&gt;background-color&lt;/span&gt;:&lt;span style="color:blue;"&gt;Transparent&lt;/span&gt;;&lt;/p&gt;        &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:red;"&gt;border-style&lt;/span&gt;: &lt;span style="color:blue;"&gt;double&lt;/span&gt;;&lt;/p&gt;        &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:red;"&gt;border-width&lt;/span&gt;: &lt;span style="color:blue;"&gt;thick&lt;/span&gt;;&lt;/p&gt;        &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:red;"&gt;border-color&lt;/span&gt;:&lt;span style="color:blue;"&gt;Red&lt;/span&gt;;&lt;/p&gt;        &lt;p style="margin:0px;"&gt;} &lt;/p&gt;     &lt;/div&gt; &lt;/span&gt;&lt;/div&gt;  &lt;p&gt;Also a button is added to the popup. Clicking the button fires a script statement to close the popup. It does that by clearing the innerHTML of the target div&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:#a31515;"&gt;Control&lt;/span&gt; &lt;span style="color:red;"&gt;Language&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Inherits&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;System.Web.Mvc.ViewUserControl&amp;lt;MySelection&amp;gt;&amp;quot;&lt;/span&gt; &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:#a31515;"&gt;Import&lt;/span&gt; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;AjaxKissesMVC.Models&amp;quot;&lt;/span&gt;&lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt; &lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;popup&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; On &lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;Model.SelectedTime &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt; you selected &lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;Model.SelectedValue &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;input&lt;/span&gt; &lt;span style="color:red;"&gt;type&lt;/span&gt; &lt;span style="color:blue;"&gt;=&amp;quot;button&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;value&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Close&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;onclick&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;$get(&amp;#39;yourselection&amp;#39;).innerHTML=&amp;#39;&amp;#39;;&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;This results in a transparent popup which lies on top of the originating page and can be closed by clicking the button.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AkM5_5F00_6D19918E.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="AkM5" border="0" alt="AkM5" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/AkM5_5F00_thumb_5F00_32BE1BAD.png" width="417" height="345" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;span style="color:#ff0000;font-size:medium;"&gt;&lt;span style="color:#ff0000;font-size:medium;"&gt;&lt;/span&gt;      &lt;p&gt;&amp;#160;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;By far not complete but the basics are there. I will leave it up to you (or better your html artist, I’m not good at it either…) for the further visual candy.&lt;/p&gt;  &lt;p&gt;What I hope to have demonstrated is how easy and straightforward it is to add ajax functionality to an mvc application. Do your end users a favor and use it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=594217" width="1" height="1"&gt;</description></item><item><title>New year, new address</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/12/29/new-year-new-address.aspx</link><pubDate>Tue, 29 Dec 2009 14:10:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:561595</guid><dc:creator>pvanooijen</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=561595</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/12/29/new-year-new-address.aspx#comments</comments><description>&lt;p&gt;Warning: this post has no technical content. But is a little explanation why I have cranked out so little of that lately.&lt;/p&gt;
&lt;p&gt;Due to not to happy circumstances I have moved. My new address is:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:small;"&gt;Gekko Software
&lt;p&gt;Peter van Ooijen&lt;/p&gt;
&lt;p&gt;Viermat 7&lt;/p&gt;
&lt;font size="3"&gt;
&lt;p&gt;9753 KW Haren&lt;/p&gt;
&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Moving does provide lots and lots of fodder for rants. Some small ones&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Trying to move an internet connection is sheer hell. I thought I had the best provider in the Netherlands, at least they say the public considers them such. The enormous hassle it took to move makes me wander how bad the others are. As a result my ex-wife had only one day without internet and I still have two wait two more weeks. &lt;/li&gt;
&lt;li&gt;Mobile internet dongles are great. But don&amp;rsquo;t trust them to work always, especially not in an everyday scenario. So far I only got it to work on my Server 2008 R2 laptop. Not on my W7 desktop, neither on an XP laptop. &lt;/li&gt;
&lt;li&gt;Watch out for W7&lt;strong&gt;N&lt;/strong&gt;, the explorer-less W7 version created to please &amp;ldquo;that woman&amp;rdquo; Neelie Kroes. I overlooked the N installed the W7 ultimate N on our mediacenter and now my kids have tp watch a DVD on a laptop. W7N has nothing usefull for a family PC. No explorere and no Media player, you can play nothing on it. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So far the bad news. 2010 is going to be great and I&amp;rsquo;ll be back to normal posting.&lt;/p&gt;
&lt;p&gt;Happy new year everybody&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=561595" width="1" height="1"&gt;</description></item><item><title>Switching virtual networks the easy way</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/11/12/switching-virtual-networks-the-easy-way.aspx</link><pubDate>Thu, 12 Nov 2009 10:40:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:423979</guid><dc:creator>pvanooijen</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=423979</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/11/12/switching-virtual-networks-the-easy-way.aspx#comments</comments><description>&lt;p&gt;For my laptop I am using server 2008 as OS. The main reason is Hyper V, for every different project I can fire up one or more appropriate virtual servers. For the details on setting up such an environment see &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2008/09/15/nice-laptop-for-a-developer-running-windows-workstation-2008.aspx"&gt;this post&lt;/a&gt;. On the advantages of using Server 2008 &lt;strong&gt;R2 &lt;/strong&gt;see &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2009/09/22/windows-workstation-2008-r2-an-even-better-os-for-a-laptop.aspx"&gt;this post&lt;/a&gt;. Traveling around the laptop meets a lot of different networks, from the Office domain of which it is a member to some kind of wireless in the wild open. Sometimes I want my virtual servers to see and be seen by the outer world, sometimes I don&amp;rsquo;t. &lt;/p&gt;
&lt;p&gt;You can do a lot of network configuration in Hyper-V, in &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2008/10/28/hyper-v-virtual-networks-and-a-handy-usb-ethernet-gadget.aspx"&gt;this post&lt;/a&gt; I described a rather baroque configuration where all kinds of network connectivity can be switched on and off. Which worked well but is far more complicated than needed. By now I have found out that switching networks in Hyper &amp;ndash;V can be as simple as this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a virtual network for every adapter on the laptop. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Virtualnetworkmanager_5F00_2A3D2884.png"&gt;&lt;img height="653" width="693" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Virtualnetworkmanager_5F00_thumb_5F00_35F26FB6.png" alt="Virtual network manager" border="0" title="Virtual network manager" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;My laptop has an internal (fixed IP address) adapter and an &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2008/10/28/hyper-v-virtual-networks-and-a-handy-usb-ethernet-gadget.aspx"&gt;external USB adapter&lt;/a&gt; (depending on DHCP). The Hyper-V virtual network manager does not allow you (yet ?) to pick Wireless or dial-up adapters for a virtual network. &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Assign each virtual machine just one network adapter.&lt;/li&gt;
&lt;li&gt;Select the active adapter as needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Virtualmachinemanager_5F00_369B25E0.png"&gt;&lt;img height="663" width="705" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Virtualmachinemanager_5F00_thumb_5F00_21C92D60.png" alt="Virtual machine manager" border="0" title="Virtual machine manager" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The good thing is that this can be done while the virtual machine is running. Changing the network is instantaneous. Just like pulling the cable and inserting another one. So much simpler than all the &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2008/10/28/hyper-v-virtual-networks-and-a-handy-usb-ethernet-gadget.aspx"&gt;previous multi network fiddling&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=423979" width="1" height="1"&gt;</description></item><item><title>Something you can (not) do with your (old) MSDN disks</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/10/26/something-you-can-not-do-with-your-old-msdn-disks.aspx</link><pubDate>Mon, 26 Oct 2009 12:52:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:398019</guid><dc:creator>pvanooijen</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=398019</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/10/26/something-you-can-not-do-with-your-old-msdn-disks.aspx#comments</comments><description>&lt;p&gt;Time to renew my MSDN subscription. I don&amp;rsquo;t know about you but I&amp;rsquo;m still very pleased with the MSDN program.&lt;/p&gt;
&lt;p&gt;In the old pre DVD days it used to be quite a problem what to do with the enormous piles of disks you received over and over again. Especially those things you never use. Anyone interested in a Finish version of Exchange server ? A Greek version of Windows 98 ? Since DVD times the piles has gotten a little smaller, but still. Googling around what to do with all these disks pops up an &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2004/05/31/14832.aspx"&gt;old rant of mine&lt;/a&gt; on this.&lt;/p&gt;
&lt;p&gt;Being a biologist with a huge interest in aquarium fish (see my &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2009/05/20/a-first-glimpse-of-virtualization-in-windows-7.aspx"&gt;W7 betta rant&lt;/a&gt;) and an &amp;ldquo;old goat-wool-socks&amp;rdquo; environmental concern I thought I had a good use. Digital disk are very reflective, using them as a reflector for the light in my aquarium would give the disks a new life and would increase the effectiveness of fish tank lighting. So I tried.&lt;/p&gt;
&lt;p&gt;This is what the result looked like in less than a year.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/OldMSDNdisks_5F00_7F8CB94B.jpg"&gt;&lt;img height="476" width="754" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/OldMSDNdisks_5F00_thumb_5F00_2F675B0D.jpg" alt="Old MSDN disks" border="0" title="Old MSDN disks" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Moist has crept between the reflective (aluminum) layer and the (polycarbonate) disk itself and completely oxidized the metal. Resulting in a surface which reflects far less than the ground surface itself. Lesson learned: this does not work.&lt;/p&gt;
&lt;p&gt;What you can do today with your disks is what I already asked for in &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2004/05/31/14832.aspx"&gt;my original rant&lt;/a&gt;: don&amp;rsquo;t get them. MSDN subscriptions now offer a download only option. You are free to download what you need (and what&amp;rsquo;s in your license). For many a product this was what I did already, downloading got me the product long before the disk finally arrived by mail. So if you want to stop wasting resources too: do switch to this subscription type. The only wish I have left is to save a little on money. Not producing and distributing the disks saves MS in the costs. I would like a small share of that in the form of a reduction on my MSDN fee. Fair deal ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=398019" width="1" height="1"&gt;</description></item><item><title>Map control confusion</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/10/22/map-control-confusion.aspx</link><pubDate>Thu, 22 Oct 2009 15:30:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:392558</guid><dc:creator>pvanooijen</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=392558</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/10/22/map-control-confusion.aspx#comments</comments><description>&lt;p&gt;When it comes to including geographical information in your web-application you have to make two main decisions. The first one is which API you are going to use, the second one is who is going to provide the geographical data. These two are not always completely independent. &lt;/p&gt;
&lt;p&gt;A lot of websites use google maps. The geographical information is supplied by google and the only way to get to that information is by using the &lt;a href="http://code.google.com/apis/maps/index.html"&gt;Google Javascript API&lt;/a&gt;. When it comes to performance Javascript is far from ideal, more sophisticated applications which try to add a lot of information to a map are quite likely to hit a script timeout. The other downside of this approach is the (lack of) smoothness of the display. Panning or zooming a map results in a lot of&amp;nbsp; image blur.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Blurredmap_5F00_383981DA.png"&gt;&lt;img height="494" width="772" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Blurredmap_5F00_thumb_5F00_44B70929.png" alt="Blurredmap" border="0" title="Blurredmap" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Both downsides can be overcome by using Silverlight. The &lt;a href="http://www.codeplex.com/deepearth"&gt;DeepEarth&lt;/a&gt; project was the first to use &lt;a href="http://silverlight.net/learn/quickstarts/deepzoom/"&gt;deepzoom&lt;/a&gt; which results in a smooth display when scanning or zooming. The strong typed compiled C# Silverlight code working with the map has not only a speed advantage over Javascript, it&amp;rsquo;s running async resulting in an app which not only has a smooth look but also a smooth feel.&lt;/p&gt;
&lt;p&gt;You can build amazing apps with that. This is a part of the &lt;a href="http://www.soulsolutions.com.au/silverlight/mvpsummit09/"&gt;MVP map&lt;/a&gt; created by DeepEarth evangelist &lt;a href="http://www.soulsolutions.com.au/"&gt;SoulSolutions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/mvpMAP_5F00_77D2F6F8.png"&gt;&lt;img height="593" width="771" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/mvpMAP_5F00_thumb_5F00_1C4438E3.png" alt="mvpMAP" border="0" title="mvpMAP" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;When it comes to where and how to get the geographical data, which can be satellite images, road maps or routing information, confusion starts. The DeepEarth project offered a choice of map providers. Ranging from &lt;a href="http://www.openstreetmap.org/"&gt;OpenStreetmap&lt;/a&gt; to Yahoo maps and Microsoft Live Earth. Google maps were not included, the reason is the one I mentioned. Nobody so far has managed to create a hack to get Google Map data without leaving JS.&lt;/p&gt;
&lt;p&gt;But the most confusing data-provider was and is Microsoft. The first versions of DeepEarth offered plain Live maps. In later versions you were supposed to use LiveMaps webservices. The usage of these services was by far free. There was a free developer test account available which resulted in map images all decorated with the word &amp;ldquo;staging&amp;rdquo;. For production you had to buy a license. To get a proper deal for that always got stuck somewhere in the pipeline. At the same time the old versions using plain Live maps kept working. At the moment I&amp;rsquo;m writing this seems to be history already.&lt;/p&gt;
&lt;p&gt;LiveMaps have become Bing maps. At the same time Microsoft started developing their own &lt;a href="https://connect.microsoft.com/silverlightmapcontrolctp?wa=wsignin1.0"&gt;Silverlight map control&lt;/a&gt;. The good thing is that it is a marvel to work with. The performance is even better than DeepEarth. The API just shines, a lot of functionality is present straight out of the box. All &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2008/12/11/wpf-code-markup-custom-pushpins-for-deepearth.aspx"&gt;the extra work I had to do&lt;/a&gt; to get my app running in Deep Earth could be replaced by just hooking into some events. The architecture is great as well. It is by no means just limited to using Bing Maps data, you can even bypass that completely using the control as a blank working surface with a Latitude-Longitude coordinate system. A part of the architecture is a clear and easy way to use any map provider you can imagine, or build yourself. There are a lot of good stories on the web on working with the control.&lt;/p&gt;
&lt;p&gt;But, as announced, there is still confusion. First there is the name. It is Microsoft Virtual Earth Silverlight Map Control. I have no problem with that, do you like &lt;em&gt;Bing&lt;/em&gt; ? I can&amp;rsquo;t get used to that. More serious is the source of map data. The control, now in CTP, displays full MS map data without any need to apply for a (test-) license. No staging, no problem. The control itself has a &lt;strong&gt;Token&lt;/strong&gt; property, according to the documentation:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Gets or sets the token to use for service requests. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It contains an empty string. How and when to use it is not clear at all. When it comes to production will it be needed to use the control? Or will it only be needed to get actual MS map data? Which data ? Just routing information ? Maps? Satellite images ? I just cannot find out. In case anybody can shed some light on this, I would appreciate that very much. Building software using the control is great, but what are price and conditions my customer will have to deal with?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=392558" width="1" height="1"&gt;</description></item><item><title>ScottGu, DotNed, loads of new stuff and intellisense</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/09/28/scottgu-dotned-loads-of-new-stuff-and-intellisense.aspx</link><pubDate>Mon, 28 Sep 2009 12:41:40 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:367552</guid><dc:creator>pvanooijen</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=367552</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/09/28/scottgu-dotned-loads-of-new-stuff-and-intellisense.aspx#comments</comments><description>&lt;p&gt;Last Friday Scott Guthrie started his promo tour for VS 2010 and .NET 4.00 in the Netherlands. Dutch user group &lt;a href="http://www.dotned.nl/"&gt;DotNed&lt;/a&gt; had to honor to host his performance.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/20090926021_5F00_54C4D90D.jpg"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="20090926 021" border="0" alt="20090926 021" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/20090926021_5F00_thumb_5F00_0C2AEA3C.jpg" width="760" height="460" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;For us it was Friday late afternoon. For him it was somewhere early in the morning (watch the clock on his laptop). Nevertheless he did two really long talks, over two hours each. Such an energy. One on VS 2010 and one completely dedicated to MVC. &lt;/p&gt;  &lt;p&gt;I’m not going into the content, it will all be on the &lt;a href="http://weblogs.asp.net/scottgu/"&gt;ScottGu blog&lt;/a&gt;. Needless to say the talks were entertaining, good and promising. Nice to see R# (code navigation and refactoring) and the alt.net (EF) influence shining through.&lt;/p&gt;  &lt;p&gt;There is one little snippet which was really amazing. It’s about Javascript Intelisense. We made it really hard on the fly&lt;/p&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/20090926027_5F00_79EF211D.jpg"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="20090926 027" border="0" alt="20090926 027" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/20090926027_5F00_thumb_5F00_52D461DB.jpg" width="738" height="782" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;It requires some explanation. In the for loop five dynamic variables are introduced, MyVar0 tot MyVar4. In the same loop five message-boxes will pop in the users face and five exceptions are thrown. Nevertheless the intellisense sees all these five variables on the fly. Without any disturbance. Well, that is really amazing.&lt;/p&gt;  &lt;p&gt;If you get the chance to go to his talk in the coming weeks or months: do go. I am updated &lt;em&gt;and&lt;/em&gt; really enjoyed it.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/20090926009_5F00_1B3EA0ED.jpg"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="20090926 009" border="0" alt="20090926 009" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/20090926009_5F00_thumb_5F00_600AC521.jpg" width="620" height="953" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=367552" width="1" height="1"&gt;</description><category domain="http://codebetter.com/blogs/peter.van.ooijen/archive/tags/User+groups+and+meetings/default.aspx">User groups and meetings</category></item><item><title>Windows Workstation 2008 R2: An even better OS for a laptop</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/09/22/windows-workstation-2008-r2-an-even-better-os-for-a-laptop.aspx</link><pubDate>Tue, 22 Sep 2009 11:52:52 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:358098</guid><dc:creator>pvanooijen</dc:creator><slash:comments>17</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=358098</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/09/22/windows-workstation-2008-r2-an-even-better-os-for-a-laptop.aspx#comments</comments><description>&lt;p&gt;Some time ago I repaved my laptop with Windows 2008, 64 bit. The main reason was Hyper V providing such a good support for virtual machines. I dedicated &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2008/09/15/nice-laptop-for-a-developer-running-windows-workstation-2008.aspx"&gt;quite a post&lt;/a&gt; on all the details of setting up that system. The machine has served it’s purpose quite well being a very powerful mobile workstation with a crisp response including any virtual server I need for the particular project. The only downsides were it’s relatively long booting time and the lack of power management options like hibernating to compensate for that.&lt;/p&gt;  &lt;p&gt;Having heard such good things about Server 2008 R2 (only available in 64 bits version) I decided to upgrade. The process itself is very simple&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Shut down all virtual machines &lt;/li&gt;    &lt;li&gt;Uninstall Hyper V &lt;/li&gt;    &lt;li&gt;Run setup and upgrade &lt;/li&gt;    &lt;li&gt;Switch on the Hyper V role &lt;/li&gt;    &lt;li&gt;Recreate the virtual networks and machines, using the existing virtual hard disks. Those are (by default) found in the public documents folder. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The last step may seem like a lot of work but it’s just another no brainer.&lt;/p&gt;  &lt;p&gt;The result is a machine&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Which boots a lot faster &lt;/li&gt;    &lt;li&gt;Operates even smoother. Graphics are really better, using the default Windows driver &lt;/li&gt;    &lt;li&gt;Has the Windows 7 UI, with nice docking and the Aero shake &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/2008R2_5F00_729AA07D.jpg"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="2008R2" border="0" alt="2008R2" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/2008R2_5F00_thumb_5F00_7E4FE7AF.jpg" width="640" height="402" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Makes me feel happy. In case you’re running Workstation 2008 as well I can only advice you to upgrade this very moment.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=358098" width="1" height="1"&gt;</description></item><item><title>Giveaway: antique and nostalgic PC</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/08/28/giveaway-antique-and-nostalgic-pc.aspx</link><pubDate>Fri, 28 Aug 2009 07:34:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:326534</guid><dc:creator>pvanooijen</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=326534</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/08/28/giveaway-antique-and-nostalgic-pc.aspx#comments</comments><description>&lt;p&gt;As said before, &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2009/08/27/predicting-the-future-and-getting-rid-of-the-past.aspx"&gt;I am getting rid of my past&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For year and years I&amp;rsquo;ve kept my first PC, as a kind of monument. But now it&amp;rsquo;s time to say goodbye to that too. As the machine is quite a milestone in the history of computing I guess (hope) there is somebody out there who can give her a place. I&amp;rsquo;ve tried something likewise &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2006/12/04/Sign-of-the-times-giveaway.aspx"&gt;before&lt;/a&gt;. Perhaps I&amp;rsquo;m to sentimental about this, but at least it should make a good story.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/DSC_5F00_3072_5F00_6BE31F80.jpg"&gt;&lt;img height="547" width="443" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/DSC_5F00_3072_5F00_thumb_5F00_2990073D.jpg" alt="DSC_3072" border="0" title="DSC_3072" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The machine is an Olivetti M24 (known in the US as the AT&amp;amp;T 6300). Almost as old as the first IBM PC, but with some interesting differences.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/DSC_5F00_2997_5F00_1C497E2A.jpg"&gt;&lt;img height="351" width="443" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/DSC_5F00_2997_5F00_thumb_5F00_26BA2C7D.jpg" alt="DSC_2997" border="0" title="DSC_2997" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The original IBM PC had a 8088 processor. Internal 16 bits but with an 8 bits bus. The main reason was the unavailability of 16 bits support chips. These were available on time for the Olivetti; it is powered by the full 16-bits 8086 processor. Running at a whopping 8 Mhz (instead of the 4.77 in the IBM) with a separate 8087 numerical co-processor.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/DSC_5F00_2993_5F00_1D7DF13C.jpg"&gt;&lt;img height="497" width="435" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/DSC_5F00_2993_5F00_thumb_5F00_1A888C89.jpg" alt="DSC_2993" border="0" title="DSC_2993" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The is motherboard is mainly covered with RAM chips. A whopping 640K&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/DSC_5F00_2989_5F00_0954AEE6.jpg"&gt;&lt;img height="215" width="444" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/DSC_5F00_2989_5F00_thumb_5F00_3FE25A2A.jpg" alt="DSC_2989" border="0" title="DSC_2989" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;To mount expansion cards a so called &amp;ldquo;bus converter&amp;rdquo; board is fitted. Note the fat power cables. On this board an AST &amp;ldquo;six-shooter&amp;rdquo; is mounted which offers things like a second a second parallel and serial port. This machine has it&amp;rsquo;s own parallel serial and serial connectors. In those days this wasn&amp;rsquo;t always the case for a PC. Imagine to have to buy a complete expansion board just to attach a printer&amp;hellip;&lt;/p&gt;
&lt;p&gt;The original IBM PC required a separate Color Graphics Adapter which would give you a 320*200 image. The Olivetti has on board 640*400 proprietary graphics. The popularity of the machine resulted in many software packages like Lotus 123 and later the Borland Turbo Graphix Toolbox providing a driver.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/DSC_5F00_2991_5F00_5DE0681E.jpg"&gt;&lt;img height="316" width="450" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/DSC_5F00_2991_5F00_thumb_5F00_295F95D6.jpg" alt="DSC_2991" border="0" title="DSC_2991" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;In the early PC days a hard disk (Winchester Drive) was not a standard option. I added one later on, no less than 10 MB. Note the handwritten sector notes on the sticker. I&amp;rsquo;m not quite sure about this disk still functioning. In case you want to get it spinning smoothly I&amp;rsquo;d advise a bicycle mechanic to check the bearings. No kidding, it did the trick last time.&lt;/p&gt;
&lt;p&gt;In case you are bored stiff with this story, sorry about that. Nostalgic mood. In case you are really interested: she&amp;rsquo;s all yours. Shipping is not included, and she is on a strict 220V diet.&lt;/p&gt;
&lt;p&gt;&amp;lt;Update&amp;gt;She has found a new home&amp;lt;/update&amp;gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=326534" width="1" height="1"&gt;</description></item><item><title>Predicting the future and getting rid of the past</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/08/27/predicting-the-future-and-getting-rid-of-the-past.aspx</link><pubDate>Thu, 27 Aug 2009 08:27:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:325742</guid><dc:creator>pvanooijen</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=325742</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/08/27/predicting-the-future-and-getting-rid-of-the-past.aspx#comments</comments><description>&lt;p&gt;I spent the end of the summer holiday to tidy up my office. The amount of stuff I had collected over the years was so overwhelming that some serious action had to be taken. Here I would like to share some of my musings on the ancient stuff I have excavated.&lt;/p&gt;
&lt;p&gt;Predicting the future is hard but always a nice inspiration. In my youth we were all big fans of a the television series the &lt;a href="http://en.wikipedia.org/wiki/Thunderbirds_(TV_series)"&gt;Thunderbirds&lt;/a&gt;. An SF animation staged one century later, that would be around 2066. Which is still more than half a century from now, but 25 years ago it was already clear how wrong the view on future technology was. Energy was abundant and of unlimited power. Far different from the oil-crisis and down-sized cars of today. IT played almost no part at all. In one episode there was a thing named a &amp;ldquo;computer&amp;rdquo; which more or less resembled a brain damaged Aibo. And the capabilities of the main communication space station (Thunderbird 5) would be surpassed by today&amp;rsquo;s average cell-phone.&lt;/p&gt;
&lt;p&gt;A more serious look into the future of IT were the pile of &lt;a href="http://en.wikipedia.org/wiki/Byte_(magazine)"&gt;Byte magazine&lt;/a&gt;s I dug up. I had kept them as historical material, a documentation of the emerging world of small sized IT. Running through some of the issues was startling. Byte always was a good source: well informed, well written, well documented. But reading through articles on future developments was quite disappointing. As an example I&amp;rsquo;ll briefly discuss an article on a typical Codebetter subject in the December 1995 issue. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Byte_5F00_7FFABE6C.jpg"&gt;&lt;img height="715" width="519" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Byte_5F00_thumb_5F00_44C6E2A1.jpg" alt="Byte" border="0" title="Byte" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;When carefully reading through the article there are some interesting quotes by people in the field like &amp;ldquo;&lt;em&gt;As you&amp;rsquo;re writing code, you should be creating tests&lt;/em&gt;&amp;rdquo;, &amp;ldquo;&lt;em&gt;establish a testing strategy that builds the interpreter every night and runs it on several&lt;/em&gt;&amp;rdquo; and &amp;ldquo;&lt;em&gt;uses a variant of the spiral-development life-cycle&lt;/em&gt;&amp;rdquo;. But these were just isolated quotes. The conclusions of the article are, seen through today&amp;rsquo;s eyes, somewhat toe-curling. The major recommendation is &amp;ldquo;&lt;em&gt;Fight for a stable design&lt;/em&gt;&amp;rdquo; and a whole page is spent on ways to formalize the development process. Which states : &amp;ldquo;&lt;em&gt;This means, among other things, that development and testing occur separately&lt;/em&gt;&amp;rdquo;. &lt;/p&gt;
&lt;p&gt;Enough said. For me the morale of the story is not that Byte was a bad magazine. It just describes the impossibility to predict the future. In the story are some glimpses of what will happen in later years. Looking back some things, like the quotes I mentioned are now today&amp;rsquo;s insight. But a lot, if not most, of the other things were just wrong. IMHO this is just another example how change in technology very much resembles that of evolutionary changes of life. The major trend will become extinct and some of the details will become the major trend. But don&amp;rsquo;t ask which. &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2008/02/18/r-evolutionary-changes.aspx"&gt;I blogged on that before&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Having learned this all these Byte magazines have become a thing of the past. How to get rid of the past ? I&amp;rsquo;ve brought them away to recycle the paper. New ideas can be printed on that.&lt;/p&gt;
&lt;p&gt;There is more past I want to get rid of. But I&amp;rsquo;ll spend a separate post on that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=325742" width="1" height="1"&gt;</description></item><item><title>Domain driven reports: adding custom code</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/07/08/domain-driven-reports-adding-custom-code.aspx</link><pubDate>Wed, 08 Jul 2009 13:21:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:249841</guid><dc:creator>pvanooijen</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=249841</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/07/08/domain-driven-reports-adding-custom-code.aspx#comments</comments><description>&lt;p&gt;In my last post I described how to create &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2009/07/01/reporting-against-a-domain-model.aspx"&gt;reports based on a domain model&lt;/a&gt;. Which led to many an interesting reaction. In this post I will explore some of my further explorations based on those comments as well on my personal requirements. In this post I will sketch a way to give reports a distinct place in the overall architecture of an application, how to separate the report from its presentation on a winform or a webform and how to add custom, domain based, code to a report.&lt;/p&gt;
&lt;h3&gt;&lt;/h3&gt;
&lt;h3&gt;Reporting is a service&lt;/h3&gt;
&lt;p&gt;In an application reporting is one of the services. As an implementation I have added a reporting class library to the solution. This class library contains the embedded report, the code to use the report in a report viewer and the report&amp;rsquo;s custom code.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Arep1_5F00_12208270.png"&gt;&lt;img height="521" width="278" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Arep1_5F00_thumb_5F00_3ADBE7B9.png" alt="Arep1" border="0" title="Arep1" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;This project has a reference to the domain model and contains many of the pieces of my &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2009/07/01/reporting-against-a-domain-model.aspx"&gt;first reporting story&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The DataSources based on the domain entities &lt;em&gt;Invoice&lt;/em&gt; and &lt;em&gt;InvoiceLine&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;An interface &lt;em&gt;IReport&lt;/em&gt; describing how the report will be exposed to a report viewer&lt;/li&gt;
&lt;li&gt;A base class &lt;em&gt;ReportBase&lt;/em&gt; implementing shared code&lt;/li&gt;
&lt;li&gt;The report definition &lt;em&gt;Invoice.rdlc&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;A class &lt;em&gt;Invoicing&lt;/em&gt; which implements &lt;em&gt;IReport&lt;/em&gt; as well as some custom code.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The IReport interface describes what a report should expose&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;interface&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;IReport&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ReportDataSourceName { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;Stream&lt;/span&gt; ReportDefinition { &lt;span style="color:blue;"&gt;get&lt;/span&gt;;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;gt; ReportAssemblyNames { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;It contains &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The name of the datasource we met in the previous post.&amp;nbsp; &lt;/li&gt;
&lt;li&gt;The report definition as a stream. In the previous post the report was embedded in the same assembly as the report viewer, in this scenario the report is embedded in another assembly and can be streamed from there&lt;/li&gt;
&lt;li&gt;A list of assembly names. These are needed by the viewer when we are going to add custom code to the report&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The ReportBase class provides a base implementation&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;abstract&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ReportBase&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;IReport&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;gt; _reportAssemblyNames&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;gt; {&lt;span style="color:#2b91af;"&gt;Assembly&lt;/span&gt;.GetExecutingAssembly().GetName().ToString() };&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;gt; ReportAssemblyNames&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;get&lt;/span&gt; { &lt;span style="color:blue;"&gt;return&lt;/span&gt; _reportAssemblyNames; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Stream&lt;/span&gt; ReportDefinition&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;get&lt;/span&gt; { &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Assembly&lt;/span&gt;.GetExecutingAssembly().GetManifestResourceStream(ReportName); }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;abstract&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ReportName {&lt;span style="color:blue;"&gt;get&lt;/span&gt;;}&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;abstract&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ReportDataSourceName { &lt;span style="color:blue;"&gt;get&lt;/span&gt;;}&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;It provides&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The base list of assemblynames, already containing the full name of the &lt;em&gt;Reporting &lt;/em&gt;assembly&lt;/li&gt;
&lt;li&gt;A stream providing the report definition&lt;/li&gt;
&lt;li&gt;Stubs for the report and datasource name&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Building the invoicing report&lt;/h3&gt;
&lt;p&gt;On the &lt;em&gt;ReportBase&lt;/em&gt; class the &lt;em&gt;Invoicing&lt;/em&gt; class is based.&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; Gekko.Administratie.DomainModel;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; Gekko.Administratie.Services.Reporting.Base;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; Gekko.Administratie.Services.Reporting&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Invoicing&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;ReportBase&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; Invoicing()&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _reportAssemblyNames.Add(&lt;span style="color:#a31515;"&gt;&amp;quot;DomainModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7610f12aa6ca9a54&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _reportAssemblyNames.Add(&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#a31515;"&gt;&amp;quot;nHibernateHelpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ac06ce2921f125f7&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ReportName&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&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 style="color:blue;"&gt;get&lt;/span&gt; { &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:#a31515;"&gt;&amp;quot;Gekko.Administratie.Services.Reporting.Invoice.rdlc&amp;quot;&lt;/span&gt;; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; ReportDataSourceName&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&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 style="color:blue;"&gt;get&lt;/span&gt; { &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:#a31515;"&gt;&amp;quot;Gekko_Administratie_DomainModel_Invoice&amp;quot;&lt;/span&gt;; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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;string&lt;/span&gt; SayBoe()&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&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 style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:#a31515;"&gt;&amp;quot;Just say boo...&amp;quot;&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;decimal&lt;/span&gt; RunningTotal;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;decimal&lt;/span&gt; MyLineTotal(&lt;span style="color:blue;"&gt;object&lt;/span&gt; lines)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&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 style="color:blue;"&gt;var&lt;/span&gt; theLines = lines &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;InvoiceLine&lt;/span&gt;&amp;gt;;&lt;/p&gt;
&lt;p style="margin:0px;"&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 style="color:blue;"&gt;decimal&lt;/span&gt; result = 0;&lt;/p&gt;
&lt;p style="margin:0px;"&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 style="color:blue;"&gt;if&lt;/span&gt; (theLines != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color:blue;"&gt;var&lt;/span&gt; line &lt;span style="color:blue;"&gt;in&lt;/span&gt; theLines)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result += line.LineTotal;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RunningTotal += result;&lt;/p&gt;
&lt;p style="margin:0px;"&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 style="color:blue;"&gt;return&lt;/span&gt; result;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Notice that the class is using the domain model. In the constructor is adds the names of assemblies used to the list and provides the name of the report and it&amp;rsquo;s datasource.&lt;/p&gt;
&lt;p&gt;It has two kind of custom members. There is the static &lt;em&gt;SayBoe&lt;/em&gt; method, which just return a string. The instance member &lt;em&gt;MyLineTotal&lt;/em&gt; is far more interesting. As a parameter is expects an IList of &lt;em&gt;InvoiceLines. In which t&lt;/em&gt;he &lt;em&gt;LineTotal&lt;/em&gt; property is calculated in the domainmodel. The running total of all lines is summed in &lt;em&gt;RunningTotal&lt;/em&gt;, another exposed member. It would be really nice to use these custom members in our report.&lt;/p&gt;
&lt;p&gt;To use the custom code in the report requires some fiddling. All assemblies used should be added to the reference list of the report. To be trusted the assemblies should be signed. Notice the PublicKeyToken.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Arep2_5F00_29C79409.png"&gt;&lt;img height="449" width="622" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Arep2_5F00_thumb_5F00_318F86AB.png" alt="Arep2" border="0" title="Arep2" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;By adding the Invoicing class to the classes list the report will create an instance of that class when rendering the report. The instance will be available as &lt;em&gt;MyInvoices&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Now the members of the invoicing class are avaliable in the report. The static members are referenced through the class name, this is now a valid reporting expression:&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;=Gekko.Administratie.Services.Reporting.&lt;span style="color:#2b91af;"&gt;Invoicing&lt;/span&gt;.SayBoe()&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;The fully qualified class name with the static method.&lt;/p&gt;
&lt;p&gt;The instance members are reached through the Code prefix&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;=Code.MyInvoices.MyLineTotal(Fields!Lines.Value)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Note that the &lt;em&gt;MyLineTotal &lt;/em&gt;method is passed the value of the Lines field. This is a list of InvoiceLines. In the report itself this property is not usable. In the method the parameter is typed as object, the report does not know how to handle an IList&amp;lt;InvoiceLine&amp;gt; and would throw an exception when meeting one. But in the method&amp;rsquo;s implementation the passed in Lines can be cast to a typed IList and be used as intended.&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;&lt;span style="color:blue;"&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;decimal&lt;/span&gt; MyLineTotal(&lt;span style="color:blue;"&gt;object&lt;/span&gt; lines)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; theLines = (&lt;span style="color:#2b91af;"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;InvoiceLine&lt;/span&gt;&amp;gt;)lines;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;decimal&lt;/span&gt; result = 0;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color:blue;"&gt;var&lt;/span&gt; line &lt;span style="color:blue;"&gt;in&lt;/span&gt; theLines)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result += line.LineTotal;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RunningTotal += result;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt; result;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;Now that is really nice, I do have full domain specific functionality inside my report.&lt;/p&gt;
&lt;p&gt;The runningtotal is accessible through a straightforward reporting expression&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;=Code.MyInvoices.RunningTotal&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Just like any normal property.&lt;/p&gt;
&lt;h3&gt;Displaying the report&lt;/h3&gt;
&lt;p&gt;With the report designed it&amp;rsquo;s time to display it. The .NET framework has two report viewers, one for winforms and one for asp.net. These reportviewers can work with server-side (SQL Reporting Services) reports and with clientside reports. The programming models for the winform and the webform viewer&amp;nbsp; look identical but share, as far as I have discovered, no usable root. I will repeat the code for both variations&lt;/p&gt;
&lt;h4&gt;On a windows form. &lt;/h4&gt;
&lt;p&gt;The project references the reporting project. The form contains a report viewer of which no properties are set.&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Form1_Load(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; repo = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;InvoiceRepository&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; invoices = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Invoicing&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MakeReport(reportViewer1.LocalReport, invoices, repo.ListPrintableInvoices());&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; reportViewer1.RefreshReport();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;The repoistory is opened, an invoicing object is created, the MakeReport helper method ties everything together after which the report can be displayed.&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; MakeReport(&lt;span style="color:#2b91af;"&gt;LocalReport&lt;/span&gt; report, &lt;span style="color:#2b91af;"&gt;IReport&lt;/span&gt; reportSettings, &lt;span style="color:blue;"&gt;object&lt;/span&gt; data)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; report.ExecuteReportInCurrentAppDomain(&lt;span style="color:#2b91af;"&gt;Assembly&lt;/span&gt;.GetExecutingAssembly().Evidence);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color:blue;"&gt;var&lt;/span&gt; assemblyName &lt;span style="color:blue;"&gt;in&lt;/span&gt; reportSettings.ReportAssemblyNames)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; report.AddTrustedCodeModuleInCurrentAppDomain(assemblyName);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; report.LoadReportDefinition(reportSettings.ReportDefinition);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; report.DataSources.Add(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ReportDataSource&lt;/span&gt;(reportSettings.ReportDataSourceName, data));&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;A report is just some running .net code. The first line sets the context. In case you omit this the reportviewer will not load the expression evaluator and the report will be blank. The second line explicitly sets a list of assemblies which the report is allowed to load. Note again that these assemblies have to be signed, else they will not be trusted. The third line loads the report definition in the viewer. And the last one binds the data to the report.&lt;/p&gt;
&lt;h4&gt;On a web form&lt;/h4&gt;
&lt;p&gt;The asp.net reportviewer only works in a classical asp.net application as it requires the viewstate. In case you are working in an mvc application it is no real problem to add a webform to the (otherwise) mvc web-app.&lt;/p&gt;
&lt;p&gt;The markup for the reportviewer is simple&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:#a31515;"&gt;Page&lt;/span&gt; &lt;span style="color:red;"&gt;Language&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;AutoEventWireup&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;CodeBehind&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Faktuur.aspx.cs&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Inherits&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;GekkoAdministratie.Faktuur&amp;quot;&lt;/span&gt; &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:#a31515;"&gt;Register&lt;/span&gt; &lt;span style="color:red;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;Microsoft.Reporting.WebForms&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;TagPrefix&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;rsweb&amp;quot;&lt;/span&gt; &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DOCTYPE&lt;/span&gt; &lt;span style="color:red;"&gt;html&lt;/span&gt; &lt;span style="color:red;"&gt;PUBLIC&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot;&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;html&lt;/span&gt; &lt;span style="color:red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&lt;/span&gt; &lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;head&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;server&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;title&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;title&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;head&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;body&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;form&lt;/span&gt; &lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;form1&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;server&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;rsweb&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ReportViewer&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;ReportViewer1&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Width&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;100%&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Height&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;600px&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;rsweb&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ReportViewer&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;form&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;body&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;html&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;(Yes drag and drop works fastest :)&lt;/p&gt;
&lt;p&gt;The code to set up the report looks completely the same as for the windows form&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; repo = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;InvoiceRepository&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; invoices = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Invoicing&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MakeReport(ReportViewer1.LocalReport, invoices, repo.ListPrintableInvoices());&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; MakeReport(&lt;span style="color:#2b91af;"&gt;LocalReport&lt;/span&gt; report, &lt;span style="color:#2b91af;"&gt;IReport&lt;/span&gt; reportSettings, &lt;span style="color:blue;"&gt;object&lt;/span&gt; data)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; report.ExecuteReportInCurrentAppDomain(&lt;span style="color:#2b91af;"&gt;Assembly&lt;/span&gt;.GetExecutingAssembly().Evidence);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color:blue;"&gt;var&lt;/span&gt; assemblyName &lt;span style="color:blue;"&gt;in&lt;/span&gt; reportSettings.ReportAssemblyNames)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; report.AddTrustedCodeModuleInCurrentAppDomain(assemblyName);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; report.LoadReportDefinition(reportSettings.ReportDefinition);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; report.DataSources.Add(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ReportDataSource&lt;/span&gt;(reportSettings.ReportDataSourceName, data));&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;The only difference is that this LocalReport type is from another namespace as the LocalReport type in winforms. &lt;/p&gt;
&lt;p&gt;You don&amp;rsquo;t have to (and can not) issue a RefreshReport, having set up the report it will be rendered to the viewer just fine.&lt;/p&gt;
&lt;h3&gt;&lt;/h3&gt;
&lt;h3&gt;Wrapping up&lt;/h3&gt;
&lt;p&gt;This is more or less it. It&amp;rsquo;s still a sketch but it does display the idea. Some things to watch:&lt;/p&gt;
&lt;p&gt;Loading an assembly in a report can give you a hard time in Visual Studio. When building the assembly all expressions in the report are compiled to. After adding custom members, you need a successful build before you can use those custom members in report expressions. And when things really stop working you need an occasional restart of Visual Studio. Quite essential were the tips I found in &lt;a href="http://jachman.wordpress.com/2007/12/19/how-to-use-custom-assemblies-with-reports/"&gt;this great post&lt;/a&gt; by, &lt;a href="http://jachman.wordpress.com/"&gt;all about nothing&lt;/a&gt;, Gerhard Stephan. Without the post-build event described there nothing will even build. &lt;/p&gt;
&lt;p&gt;In my scenario I am doing something somewhat strange (and perhaps even silly). The assembly I am loading in the report is the same assembly in which the report is embedded. My main intent was to keep all parts of the report, from the content to the viewer related stuff, together. I&amp;rsquo;m open for any other view on this.&lt;/p&gt;
&lt;p&gt;But for now I&amp;rsquo;m going to pack our tent and let everything sink deeper in on the camping site. France here we come.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=249841" width="1" height="1"&gt;</description><category domain="http://codebetter.com/blogs/peter.van.ooijen/archive/tags/Data/default.aspx">Data</category></item><item><title>Reporting against a domain model</title><link>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/07/01/reporting-against-a-domain-model.aspx</link><pubDate>Wed, 01 Jul 2009 08:44:00 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:249499</guid><dc:creator>pvanooijen</dc:creator><slash:comments>20</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://codebetter.com/blogs/peter.van.ooijen/rsscomments.aspx?PostID=249499</wfw:commentRss><comments>http://codebetter.com/blogs/peter.van.ooijen/archive/2009/07/01/reporting-against-a-domain-model.aspx#comments</comments><description>&lt;p&gt;I have a love it /hate it relationship with reports. In many an application the reports are the main output. They are the prints which get filed or the invoices which have to ensure the ROI of the application. A good looking output rich with information does increase customer satisfaction. The downside is that fine tuning a report is tedious and requires quite different skills than coding. Building a system with a lot of reports can be pretty boring. So the tools better be good. &lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2005/07/21/129605.aspx"&gt;Switching from Crystal Reports to sql server&amp;nbsp; reporting services&lt;/a&gt; (RS) was quite a relief. &lt;/p&gt;
&lt;p&gt;But&amp;nbsp; RS still has two drawbacks. First is that it accesses data using plain sql. My application is built around a domain model using nHibernate to hide all db details. The domain model includes calculated properties which are to be included in the report. The calculations are done in the domain object. It would be repetitive and prone to error to repeat them in sql or reporting expressions. It would be quite a relief to report straight from the domain model itself. &lt;/p&gt;
&lt;p&gt;The other drawback is that RS requires an ms sql server instance with installed reporting services. The actual data is just a sqlexpress instance and I don&amp;rsquo;t want to set up a full blown reporting services server.&lt;/p&gt;
&lt;p&gt;New in Visual Studio 2005 were client side reports (rdlc&amp;rsquo;s). They are very much like RS reports (rdl&amp;rsquo;s) but can work with any data source and don&amp;rsquo;t require a sql reporting server instance. To include these reports in an app two client side report viewers are include in the .NET framework, one for WinForms and one for asp.net. This looked like the best of both worlds so I decided to give the winforms version a try. &lt;/p&gt;
&lt;p&gt;For a good overview on the reports check the &lt;a href="http://www.gotreportviewer.com/"&gt;got reportviewer&lt;/a&gt; site. In name it supports VS 2008, but (some of ?) the samples are based on VS 2005. Moving to 2008 there has been a change in the namespace for the classes, after fixing the reference the samples run in VS 2008. How to work with a non sql datasource is covered but not that clear. Here I will describe my minimalistic approach to work with a domain model fed by nHibernate.&lt;/p&gt;
&lt;h3&gt;The domain model&lt;/h3&gt;
&lt;p&gt;The intent of the application is to print invoices. This class diagram describes the model&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep1_5F00_709A0A5B.png"&gt;&lt;img height="575" width="490" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep1_5F00_thumb_5F00_0E981850.png" alt="Rep1" border="0" title="Rep1" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;An invoice is for a contact, has a number of lines and an enumerated property. That is a number of values which contain a tax rate and have a clear name describing this value. Which gives the model additional value, something which would get lost when viewing the data as raw db data. An invoice has a reference to a contact and many Invoice lines. The (&lt;a href="http://wiki.fluentnhibernate.org/show/HomePage"&gt;fluent&lt;/a&gt;) nHibernate mappings express this.&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;InvoiceMap&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;ClassMap&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Invoice&lt;/span&gt;&amp;gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; InvoiceMap()&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WithTable(&lt;span style="color:#a31515;"&gt;&amp;quot;Factuur&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Id(x =&amp;gt; x.Id);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map(x =&amp;gt; x.Number).ColumnName(&lt;span style="color:#a31515;"&gt;&amp;quot;Nummer&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map(x =&amp;gt; x.OnDate).ColumnName(&lt;span style="color:#a31515;"&gt;&amp;quot;Dedato&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map(x =&amp;gt; x.BtwPercentage).CustomTypeIs&amp;lt;&lt;span style="color:#2b91af;"&gt;BtwPercentage&lt;/span&gt;&amp;gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map(x =&amp;gt; x.Description).ColumnName(&lt;span style="color:#a31515;"&gt;&amp;quot;Inleiding&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HasMany(x =&amp;gt; x.Lines).KeyColumnNames.Add(&lt;span style="color:#a31515;"&gt;&amp;quot;idFactuur&amp;quot;&lt;/span&gt;).Cascade.All();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; References(x =&amp;gt; x.ForContact).ColumnName(&lt;span style="color:#a31515;"&gt;&amp;quot;idRelatie&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map(x =&amp;gt; x.PrintIt).ColumnName(&lt;span style="color:#a31515;"&gt;&amp;quot;Printen&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;So we have a &lt;em&gt;customtype&lt;/em&gt;, a &lt;em&gt;hasmany &lt;/em&gt;and a &lt;em&gt;references&lt;/em&gt;. Let&amp;rsquo;s see how these are used in the report.&lt;/p&gt;
&lt;h3&gt;The report&lt;/h3&gt;
&lt;p&gt;There are several ways to include a report in an application. The default when adding&amp;nbsp; a new report (Add &amp;ndash;&amp;gt; New Item &amp;ndash;&amp;gt; Reporting &amp;ndash;&amp;gt; report) is embedded. Which is clear and easy in deployment. When you need more flexibility you can switch to rdlc file or (back to) server side report.&lt;/p&gt;
&lt;p&gt;The report needs a datasource. It will accept any datasource including an object datasource. &lt;/p&gt;
&lt;p&gt;Add a new object datasource to the project and pick the Invoice domain object. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep2_5F00_320496E8.png"&gt;&lt;img height="355" width="462" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep2_5F00_thumb_5F00_285C28B2.png" alt="Rep2" border="0" title="Rep2" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Just pick your POCO domain class. There is no need to set up any methods to get data, it is enough to have a model of the data.&lt;/p&gt;
&lt;p&gt;This object data source is the datasource for your report. Having done so the domain invoice is available in the report designer. (To be precise the datasource has to be attached to a List, see the &lt;a href="http://www.gotreportviewer.com/lists/index.html"&gt;reportviewer docs&lt;/a&gt; for more information on that.)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep3_5F00_3B30AC5C.png"&gt;&lt;img height="290" width="478" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep3_5F00_thumb_5F00_58565466.png" alt="Rep3" border="0" title="Rep3" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A report is built from VB-like expressions. A simple one looks&amp;nbsp; like this:&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;=Fields!Description.Value&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Which displays the plain content of a property. But expressions can be more complicated. The report designer has a good expression builder which even includes intellisense. The next expression uses both the meaningful name and the value of my tax enumeration property in a string&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;=&lt;span style="color:#a31515;"&gt;&amp;quot;BTW &amp;quot;&lt;/span&gt; &amp;amp; Fields!BtwPercentage.Value.ToString &amp;amp; &lt;span style="color:#a31515;"&gt;&amp;quot; &amp;quot;&lt;/span&gt;&amp;nbsp; &amp;amp; Fields!BtwPercentage.Value &amp;amp; &lt;span style="color:#a31515;"&gt;&amp;quot;%&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The result is a string like &amp;ldquo;&lt;em&gt;BTW Hoog 19%&amp;rdquo;.&lt;/em&gt; &lt;/p&gt;
&lt;p&gt;Things get really interesting when displaying the contact information. In the domain model this expressed as&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;invoice.ForContact.AddressLine1&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;In the report the expression is quite similar&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;=Fields!ForContact.Value.AddressLine1&lt;/p&gt;
&lt;/div&gt;

&lt;h3&gt;The subreport&lt;/h3&gt;
&lt;p&gt;The lines in the invoice are a one to many relation. The invoice datasource has a &lt;em&gt;lines&lt;/em&gt; property but this property is not usable in the report. To display the lines I need a subreport. The subreport is based on invoice lines. After adding the &lt;em&gt;InvoiceLine&lt;/em&gt; class as a datasource the subreport is drawn. It is a simple table displaying the lines.&lt;/p&gt;
&lt;p&gt;A subreport is linked to its parent report using parameters. In my case an invoice and its lines are linked through a parameter named &lt;em&gt;FactuurNummer&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep4_5F00_4F1A1925.png"&gt;&lt;img height="400" width="520" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep4_5F00_thumb_5F00_33951722.png" alt="Rep4" border="0" title="Rep4" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;All of this works just as in &amp;ldquo;traditional&amp;rdquo; reports. In the main invoice report this parameter is assigned the value of the invoice number&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep5_5F00_2AC50ED6.png"&gt;&lt;img height="362" width="513" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep5_5F00_thumb_5F00_694A5C7C.png" alt="Rep5" border="0" title="Rep5" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Check the &lt;a href="http://www.gotreportviewer.com/masterdetail/index.html"&gt;gotreportviewer&lt;/a&gt; site for further information.&lt;/p&gt;
&lt;h3&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;/h3&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;Binding the data to the report&lt;/h3&gt;
&lt;p&gt;Now the reports are ready. The next step is to get some real life data into them. &lt;/p&gt;
&lt;p&gt;It takes code to bind real data to a report and display the result in the viewer. Also the subreport has to be fed with data. To wrap things up I have built a helper class which takes a reportviewer component and a list of invoices and wires them up.&lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;&lt;span style="color:blue;"&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;internal&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;InvoiceReporter&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;internal&lt;/span&gt; InvoiceReporter(&lt;span style="color:#2b91af;"&gt;ReportViewer&lt;/span&gt; viewer, &lt;span style="color:#2b91af;"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Invoice&lt;/span&gt;&amp;gt; reportData)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _reportData = reportData;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _viewer = viewer;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Invoice&lt;/span&gt;&amp;gt; _reportData;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ReportViewer&lt;/span&gt; _viewer;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;internal&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; ShowReport()&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _viewer.LocalReport.ReportEmbeddedResource = &lt;span style="color:#a31515;"&gt;&amp;quot;Gekko.Administratie.FactuurPrinten.Invoice.rdlc&amp;quot;&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _viewer.LocalReport.DataSources.Add(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ReportDataSource&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;Gekko_Administratie_DomainModel_Invoice&amp;quot;&lt;/span&gt;, _reportData));&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _viewer.LocalReport.SubreportProcessing += SubreportProcessing;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _viewer.RefreshReport();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; SubreportProcessing(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;SubreportProcessingEventArgs&lt;/span&gt; e)&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; invoiceNumber = e.Parameters[&lt;span style="color:#a31515;"&gt;&amp;quot;FactuurNummer&amp;quot;&lt;/span&gt;].Values[0];&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; invoice = _reportData.First(fakt =&amp;gt; fakt.Number == invoiceNumber);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.DataSources.Add(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ReportDataSource&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;Gekko_Administratie_DomainModel_InvoiceLine&amp;quot;&lt;/span&gt;, invoice.Lines));&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;The code requires some explanation. The constructor should be clear, it receives viewer and data.&lt;/p&gt;
&lt;p&gt;The ShowReport method does the real work. The first line loads the report in the viewer. The second line loads the report data. This line is tricky. The name of the &lt;em&gt;ReportDataSource&lt;/em&gt; &lt;strong&gt;has&lt;/strong&gt; to match exactly the name of the datasource class used as model. The Invoice class name is &lt;em&gt;Gekko.Administratie.DomainModel.Invoice&lt;/em&gt; which gets formatted as &lt;em&gt;Gekko_Administratie_DomainModel_Invoice&lt;/em&gt;. This required magic string is not clear from any documentation, it took me quite some time to find out how essential it was. &lt;/p&gt;
&lt;p&gt;All these datasource properties in the report definition are confusing. The model of the data is saved in the report definition. Changing the datasource&amp;nbsp; to another &amp;ldquo;dataset&amp;rdquo; will also lead to errors at run time. The report will complain about the former datasources. To get rid of the error messages you have to check the report defintion by hand. The report definition file (.rdlc) is plain xml. The last part contains dataset definitions. What helps is just deleting the unused nodes by hand.&lt;/p&gt;
&lt;p&gt;Upon rendering a subreport an event is fired. In the third line of &lt;em&gt;ShowReport&lt;/em&gt; a handler is attached. This &lt;em&gt;SubReportProcessing&lt;/em&gt; method feeds the subreport with data. From the parameters the number of the invoice is read. Which is used to find the corresponding invoice. The datasource for the subreport is set just like the datasource of the main report. Again spelling the name of the reportdatasource right is essential. The data is the Lines property. Which is an IList of InvoiceLines.&lt;/p&gt;
&lt;h3&gt;&lt;/h3&gt;
&lt;h3&gt;Putting it all together&lt;/h3&gt;
&lt;p&gt;With all pieces in place it&amp;rsquo;s time to get some results. I have a windows form with a reportviewer on it. &lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; repo = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;InvoiceRepository&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; reporter = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;InvoiceReporter&lt;/span&gt;(reportViewer1, repo.ListPrintableInvoices());&lt;/p&gt;
&lt;p style="margin:0px;"&gt;reporter.ShowReport();&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;This reads the invoices from the repository and sends them with the reportviewer to the helper class.&lt;/p&gt;
&lt;p&gt;There is one more thing to watch. The repository is an nHibernate repository. By default nHibernate lazy loads related objects, like the &lt;em&gt;Contact&lt;/em&gt; and the &lt;em&gt;Lines&lt;/em&gt; of the &lt;em&gt;Invoice&lt;/em&gt;. The contact and the invoicelines will not be read from the database until they are actually used. This default setting has some serious drawbacks. &lt;/p&gt;
&lt;p&gt;In the first place the reportviewer&amp;lsquo;s datareader does not operate very well (at all ?) with nHibernate&amp;rsquo;s proxies. In the report all the contact fields will contain error messages. The subreport on the&amp;nbsp; lines will work. But still the lines are not read from the database until rendering the sub-report. So for this lazy loading to work the report has to be run against a dataset with an open dataconnection. That&amp;rsquo;s bad, I try do do as little as possible, and most likely not presenting a report, with an open connection. A far better scenario would be to fetch all data in one go, close the connection to the database and render the report after that. This can be done by eagerly loading the Contact and Lines properties and disposing of the session before returning the data.&lt;/p&gt;
&lt;p&gt;In the nHibernate API the fetch mode can be set on a property level. The code in the repository takes care of fetching all data in one big snapshot. &lt;/p&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;&lt;span style="color:blue;"&gt;
&lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Invoice&lt;/span&gt;&amp;gt; ListPrintableInvoices()&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;using&lt;/span&gt; (&lt;span style="color:blue;"&gt;var&lt;/span&gt; session = &lt;span style="color:#2b91af;"&gt;SessionFactory&lt;/span&gt;.GetFactory.OpenSession())&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;var&lt;/span&gt; query = session.CreateCriteria(&lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;Invoice&lt;/span&gt;));&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.AddOrder(&lt;span style="color:#2b91af;"&gt;Order&lt;/span&gt;.Asc(&lt;span style="color:#a31515;"&gt;&amp;quot;Number&amp;quot;&lt;/span&gt;));&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.Add(&lt;span style="color:#2b91af;"&gt;Restrictions&lt;/span&gt;.Eq(&lt;span style="color:#a31515;"&gt;&amp;quot;PrintIt&amp;quot;&lt;/span&gt;, &lt;span style="color:blue;"&gt;true&lt;/span&gt;));&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.SetFetchMode(&lt;span style="color:#a31515;"&gt;&amp;quot;Lines&amp;quot;&lt;/span&gt;, &lt;span style="color:#2b91af;"&gt;FetchMode&lt;/span&gt;.Eager);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.SetFetchMode(&lt;span style="color:#a31515;"&gt;&amp;quot;ForContact&amp;quot;&lt;/span&gt;, &lt;span style="color:#2b91af;"&gt;FetchMode&lt;/span&gt;.Eager);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt; query.List&amp;lt;&lt;span style="color:#2b91af;"&gt;Invoice&lt;/span&gt;&amp;gt;();&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;
&lt;p style="margin:0px;"&gt;&lt;/p&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;The repository reads all data from the database and closes the connection. After that the collected data are input to the reportviewer. Which now works completely as hoped for. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep6_5F00_405F4773.png"&gt;&lt;img height="531" width="408" src="http://codebetter.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peter.van.ooijen/Rep6_5F00_thumb_5F00_3384F155.png" alt="Rep6" border="0" title="Rep6" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have my report complete with printing and export functionality and am still working with my beloved domain objects.&lt;/p&gt;
&lt;p&gt;This way reporting can almost be pure fun.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://codebetter.com/aggbug.aspx?PostID=249499" width="1" height="1"&gt;</description><category domain="http://codebetter.com/blogs/peter.van.ooijen/archive/tags/Data/default.aspx">Data</category></item></channel></rss>