<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Weblog Jan V</title><link>http://www.jan-v.nl:80/</link><description>Weblog Jan V</description><item><title>Developing a new Orchard content part and widget</title><link>http://www.jan-v.nl:80/developing-a-new-orchard-content-part-and-widget</link><description>&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Going through my blogpost draftfolder I noticed this post which I wrote about a year ago. Seeing a lot of time has gone into it I decided to post it anyway. It’s based on Orchard version 1.2, so things might have changed, but the basics are probably the same. Now for the real post. &lt;br&gt;&lt;/p&gt; &lt;p&gt;I’ve got a new job where I was needed to create a new CMS website and add some client specific features on it. As Orchard is my preferred choice at the moment, it didn’t take me long to choose which CMS I was going to use.&lt;/p&gt; &lt;p&gt;To create some new, custom, features to the website I had to create new Modules and wanted to let them act as a Widget. A Widget in Orchard is much like a SharePoint webpart or an old-fashioned ASP.NET usercontrol.&lt;/p&gt; &lt;p&gt;Lucky for me the Orchard team has documented their work quite good, so I could use a lot of code from the ‘&lt;a href="http://www.orchardproject.net/docs/Writing-a-content-part.ashx"&gt;Writing a Content Part&lt;/a&gt;’ and ‘&lt;a href="http://www.orchardproject.net/docs/Writing-a-widget.ashx"&gt;Writing a Widget&lt;/a&gt;’ tutorials.&lt;/p&gt; &lt;p&gt;One of the things I was asked to create is a widget which implements the &lt;a href="http://slideshowpro.net/"&gt;SlideShowPro&lt;/a&gt; viewer. This widget is what I’ll use in this blogpost as an example.&lt;/p&gt; &lt;p&gt;First thing you need to do, if you want to create a Widget, is to create a new Content Part. A Content Part can be implemented as a new module in your Orchard website. You can use the code generation module for this, but if you prefer to do this manual, that’s also possible. If you choose to do this manually you need to create a lot of folders and files yourself as you need to start off with a new ASP.NET MVC 3 Web Application.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Developing-a-new-Orchard-content-part-an_11FA6/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Developing-a-new-Orchard-content-part-an_11FA6/image_thumb.png" width="479" height="61"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Easiest way to create a module is by starting up the orchard command prompt (hides in the bin directory of the Orchard project) and run the following command:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;codegen module NewModule /IncludeInSolution:true&lt;/font&gt;&lt;/p&gt; &lt;p&gt;The parameter &lt;font face="Courier New"&gt;IncludeInSolution&lt;/font&gt; makes sure the new project is added to the Orchard solution, however, it doesn’t work on my machine, so I added it manually to the Modules folder in the solution.&lt;/p&gt; &lt;p&gt;Inside the newly added module you’ll see some files added by default. One of them is the Module.txt file. This file contains some information about the module, like the name, description and author. I first made a mistake by typing some of the properties in lowercase, this resulted in a non-deployable module. Of course, that could also be because of some non-functional code. My final Module text file looks like this:&lt;/p&gt;&lt;pre class="brush: bash"&gt;Name: Vinit.SlideShowPro
AntiForgery: enabled
Author: Vinit
Website: http://vinit.nl
Version: 1.0
OrchardVersion: 1.0
Description: Adds a SlideShow Pro module to the site so slides can be shown.
Features:
    Vinit.SlideShowPro:
        Description: Adds a SlideShow Pro module to the site so slides can be shown.
		Category: Vinit
&lt;/pre&gt;
&lt;p&gt;After setting this up I had to figure out what the model should look like. All content will get uploaded to the site, so I need to specify an URL. This will result in a rather simple and small model with only 1 property, but it’ll do the work.&lt;br&gt;Just add a new class in the Models folder with a proper name and specify the properties you need. If you read the tutorial about writing a content part already, you know you need to add some stuff in the model. &lt;/p&gt;
&lt;p&gt;For each model you want to use you need to have a class which inherits from the &lt;font face="Courier New"&gt;ContentPart&amp;lt;T&amp;gt;&lt;/font&gt; class and one which inherits from the &lt;font face="Courier New"&gt;ContentPartRecord&lt;/font&gt; class. The class which inherits from the &lt;font face="Courier New"&gt;ContentPartRecord&lt;/font&gt; is somewhat a representation of the table where the information will get stored, sort of a model. The class which inherits the &lt;font face="Courier New"&gt;ContentPart&amp;lt;T&amp;gt;&lt;/font&gt; class will be used in the views and throughout the code, something like a viewmodel.&lt;br&gt;My model class resulted in looking like this:&lt;/p&gt;&lt;pre class='brush:csharp'&gt;public class SlideShowProRecord : ContentPartRecord
{
	public virtual string SlideShowUrl { get; set; }
}
public class SlideShowProPart : ContentPart&lt;slideshowprorecord&gt;
{
	public string SlideUrl
	{
		get { return Record.SlideShowUrl; }
		set { Record.SlideShowUrl = value; }
	}
}
&lt;/pre&gt;
&lt;p&gt;As you can see I’ll only store 1 string, &lt;font face="Courier New"&gt;SlideShowUrl&lt;/font&gt;, in the database. This property will have to correspond to the column in the database. In the &lt;font face="Courier New"&gt;SlideShowProPart&lt;/font&gt; class I’ve defined the &lt;font face="Courier New"&gt;SlideUrl&lt;/font&gt; to be &lt;font face="Courier New"&gt;Required &lt;/font&gt;so I know it will be available when requested. The &lt;font face="Courier New"&gt;SlideUrl&lt;/font&gt; retrieves and sets the property of the record which we have specified in the &lt;font face="Courier New"&gt;&amp;lt;T&amp;gt;&lt;/font&gt;.&lt;/p&gt;
&lt;p&gt;Now we need to add some stuff which makes Orchard use our code and modify the database. First off, a &lt;font face="Courier New"&gt;Migration.cs&lt;/font&gt; file. You can do this by adding it via de Orchard prompt by typing:&lt;/p&gt;&lt;pre class="brush:bash"&gt;codegen datamigration NewModule&lt;/pre&gt;
&lt;p&gt;Or you can just add a new class and call it Migration. I prefer this as you don’t need the extra context switch and it’s faster.&lt;/p&gt;
&lt;p&gt;The Migration class makes sure the Orchard database is updated after an install or update of a new module. In here you can specify what needs to be created, altered or deleted. First off we need to tell Orchard it has to create a new table with a column named &lt;font face="Courier New"&gt;SlideShowUrl&lt;/font&gt; and tell it we can attach the content part to any content type.&lt;br&gt;This is the necessary code for those steps:&lt;/p&gt;&lt;pre class="brush:csharp"&gt;
public int Create()
{
	SchemaBuilder.CreateTable("SlideShowProRecord", table =&amp;gt; table
																.ContentPartRecord()
																.Column("SlideShowUrl", DbType.String));

	ContentDefinitionManager.AlterPartDefinition(typeof(SlideShowProPart).Name, cfg =&amp;gt; cfg.Attachable());

	return 1;
}
&lt;/pre&gt;
&lt;p&gt;As you can see, an int value needs to be returned. This return value acts as a ‘version’ of your module. If you add a new method which returns a higher number, Orchard will automatically see there’s an update for the module and tell the administrator in the dashboard. Once the module is updated, it stores the new ‘version’ number and knows the module is up-to-date. Can’t really tell if this is a best-practice, but hey, it works!&lt;/p&gt;
&lt;p&gt;After having created the Migration class we also need to add a Handler to the project. The handler handles events of the content part or is able to manipulate the data model, before rendering the content part. Just as the example in the Orchard tutorial, I don’t need advanced stuff happening here, so I didn’t change the code here.&lt;/p&gt;&lt;pre class="brush: csharp"&gt;public SlideShowProHandler(IRepository&lt;slideshowprorecord&gt; repository)
{
    Filters.Add(StorageFilter.For(repository));
}
&lt;/pre&gt;
&lt;p&gt;Next up are the views of the content part. Specifying the views is done in something called a Driver. In this driver you can specify which view will be shown for display, edit, summary, etc. All very nice, once you know how this works.&lt;br&gt;A fairly default implementation is this one:&lt;/p&gt;&lt;pre class="brush: csharp"&gt;
public class Drivers : ContentPartDriver&lt;slideshowpropart&gt;
{
    protected override DriverResult Display(SlideShowProPart part, string displayType, dynamic shapeHelper)
    {
        return ContentShape("Parts_SlideShowPro", () =&amp;gt; shapeHelper.Parts_SlideShowPro(SlideUrl: part.SlideUrl));
    }

    //GET
    protected override DriverResult Editor(SlideShowProPart part, dynamic shapeHelper)
    {
        return ContentShape("Parts_SlideShowPro_Edit",
                            () =&amp;gt;
                            shapeHelper.EditorTemplate(TemplateName: "Parts/SlideShowPro",
                                                        Model: part,
                                                        Prefix: Prefix));
    }

    //POST
    protected override DriverResult Editor(SlideShowProPart part, Orchard.ContentManagement.IUpdateModel updater, dynamic shapeHelper)
    {
        updater.TryUpdateModel(part, Prefix, null, null);
        return Editor(part, shapeHelper);
    }
}
&lt;/pre&gt;
&lt;p&gt;The Display and Editor methods are overridden with some new functionality. The &lt;font face="Courier New"&gt;shapeHelper&lt;/font&gt; parameter is a dynamic type, which means you don’t get IntelliSense from it. I don’t know how the properties are defined on the project, but they work. Maybe I’ll check it out when I’ve got some extra spare time (read: never!).&lt;br&gt;In here you define where the views are located of the content part, “Parts/SlideShowPro” and which model will be used.&lt;/p&gt;
&lt;p&gt;Fixing the views is rather easy, just add a new view with the name SlideShowPro.cshtml in Views/Parts and in Views/EditorTemplates/Parts and you are done. If you’ve created a MVC site already, you are probably familiar on how to create the views. The Orchard tutorial has a nice example and this is a small snippet of my EditorPart:&lt;/p&gt;&lt;pre class="brush: html"&gt;
@model Vinit.SlideShowPro.Models.SlideShowProPart
&amp;lt;fieldset&amp;gt;
    &amp;lt;legend&amp;gt;SlideShowPro Fields&amp;lt;/legend&amp;gt;
    &amp;lt;div class="editor-field"&amp;gt;
        @Html.TextBoxFor(model =&amp;gt; model.SlideUrl)
        @*Html.ValidationMessageFor(model =&amp;gt; model.SlideUrl)*@
    &amp;lt;/div&amp;gt;
&amp;lt;/fieldset&amp;gt;
&lt;/pre&gt;
&lt;p&gt;And the DisplayPart: &lt;/p&gt;&lt;pre class="brush: html"&gt;
@if ( Model.SlideUrl != null &amp;amp;&amp;amp; !string.IsNullOrWhiteSpace(Model.SlideUrl) &amp;amp;&amp;amp; Model.SlideUrl.Length &amp;gt; 3) { 
&amp;lt;script type="text/javascript" src="@String.Format("{0}js/slideshowpro.js", Model.SlideUrl)"&amp;gt;&amp;lt;/script&amp;gt; 

&amp;lt;div id="slideshow"&amp;gt;&amp;lt;/div&amp;gt;

&lt;/pre&gt;
&lt;p&gt;The last step for successfully creating a content part is adding the placement.info file at the root of the project. This file contains some information on where to locate the views in a larger view.&lt;/p&gt;&lt;pre class="brush: xml"&gt;&amp;lt;Placement&amp;gt;
    &amp;lt;Place Parts_SlideShowPro="Content:2"/&amp;gt;
    &amp;lt;Place Parts_SlideShowPro_Edit="Content:7"/&amp;gt;
&amp;lt;/Placement&amp;gt;
&lt;/pre&gt;
&lt;p&gt;The above example specifies I want the views in the Content block at the 10th position, or in the editor modus at the 7th position.&lt;/p&gt;
&lt;p&gt;Now, build, deploy, activate and check out of the content part is working.&lt;/p&gt;
&lt;p&gt;Once you’ve enabled the new module, you can add the content part to a random content type to check if everything is working.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Developing-a-new-Orchard-content-part-an_11FA6/image_4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Developing-a-new-Orchard-content-part-an_11FA6/image_thumb_1.png" width="233" height="90"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Navigate to the Content Types list and edit one of them, maybe Page.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Developing-a-new-Orchard-content-part-an_11FA6/image_6.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Developing-a-new-Orchard-content-part-an_11FA6/image_thumb_2.png" width="203" height="368"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Check the Slide Show Pro box in the list and click Save. &lt;br&gt;When creating a new page you should see a new block on the screen, the same block as you have specified in the editor view of your module. When viewing the new page you should see the display view on the page.&lt;/p&gt;
&lt;p&gt;So far for the hard part. Once you’ve got a working content part, creating a Widget from this is a piece of cake.&lt;/p&gt;
&lt;p&gt;Just add the following code to the Migration class, deploy and you’re happy to go. &lt;/p&gt;&lt;pre class="brush: csharp"&gt;public int UpdateFrom1()
{
	// Create a new widget content type with our map
	ContentDefinitionManager.AlterTypeDefinition("SlideShowProWidget", cfg =&amp;gt; cfg
		.WithPart("SlideShowProPart")
		.WithPart("WidgetPart")
		.WithPart("CommonPart")
		.WithSetting("Stereotype", "Widget"));

	return 2;
}
&lt;/pre&gt;
&lt;p&gt;In this piece of code you tell Orchard you want to create a SlideShowProWidget which consists of the SlideShowProPart, WidgetPart and CommonPart.&lt;br&gt;Deploy and update the module! If everything is installed correct you should also see a notification in the Dashboard.&lt;/p&gt;
&lt;p&gt;After that you can add the widget to a content block:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Developing-a-new-Orchard-content-part-an_11FA6/image_8.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Developing-a-new-Orchard-content-part-an_11FA6/image_thumb_3.png" width="395" height="103"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;So far for my small tutorial on how to add a new widget to Orchard. Lucky for me most of the stuff was already explained in the Orchard tutorials. I added some comments here which I had to find out myself or didn’t quite get from the original. &lt;br&gt;And as always, it’s always good to try things by yourself. That way you’ll get more experience on the matter.&lt;/p&gt;</description><pubDate>Wed, 02 May 2012 18:30:51 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/developing-a-new-orchard-content-part-and-widget</guid></item><item><title>Running OSX Lion on Windows with VMWare Workstation</title><link>http://www.jan-v.nl:80/running-osx-lion-on-windows-with-vmware-workstation</link><description>&lt;p&gt;I finally succeeded in setting up a VM with OSX Lion installed. Setting up an OSX environment in any VM tool has always been hard, but since Apple has decided to build for the x86 platform it has gotten a lot easier. &lt;/p&gt; &lt;p&gt;In the past couple of years I’ve tried to set up an Apple VM, but never really succeeded in it. Today I decided to try again. Apparently there are a lot of torrents out there containing OSX VM’s, so I’ve downloaded one of them to try out the OS.&lt;/p&gt; &lt;p&gt;After setting up the VM in VMWare Workstation and booting up I received an error telling me this guest OS couldn’t run with software virtualization and I had to enable hardware virtualization. My development machine has the VT-x option (Intel Virtualization Technology) in the BIOS, so enabling that fixed this issue.&lt;/p&gt; &lt;p&gt;&lt;img src="http://img832.imageshack.us/img832/6870/93204885.jpg"&gt;&lt;/p&gt; &lt;p&gt;Now, booting the guest OS again gave another error. VMWare Workstation told me the guest OS wasn’t Mac OS X Server. Changing this option to ‘Other 64-bit’ didn’t help either. &lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Running-OSX-Lion-on-Windows-with-VMWare-_13C9B/image_4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Running-OSX-Lion-on-Windows-with-VMWare-_13C9B/image_thumb_1.png" width="244" height="63"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The virtual processors kept failing when booting up.&lt;/p&gt; &lt;p&gt;Lucky for me, the guys at &lt;a href="http://www.sysprobs.com/working-method-install-mac-107-lion-vmware-windows-7-intel-pc"&gt;SysProbs had already created a fix for this problem&lt;/a&gt;. Running the &lt;a href="http://www.jan-v.nl/media/downloads/macosx_guest_in%20_vmware-7.zip"&gt;windows.bat file which is nested in the tar&lt;/a&gt; file of their download added a new option to the VMWare Workstation software&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Running-OSX-Lion-on-Windows-with-VMWare-_13C9B/image_6.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Running-OSX-Lion-on-Windows-with-VMWare-_13C9B/image_thumb_2.png" width="244" height="197"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Now you’ve got the option to select Apple Mac OS X from the Guest operating system list and select a proper version.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Running-OSX-Lion-on-Windows-with-VMWare-_13C9B/image_8.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Running-OSX-Lion-on-Windows-with-VMWare-_13C9B/image_thumb_3.png" width="207" height="244"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;I decided to go for the highest 64-bit version in the list and see if it works.&lt;/p&gt; &lt;p&gt;This has worked out quite nicely, booting up the machine works quite nicely.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Running-OSX-Lion-on-Windows-with-VMWare-_13C9B/image_10.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Running-OSX-Lion-on-Windows-with-VMWare-_13C9B/image_thumb_4.png" width="452" height="342"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Also, after installing the VMWare Tools, which are supplied in the &lt;a href="http://jan-v.nl/media/downloads/darwin.zip"&gt;darwin.iso&lt;/a&gt;, I was able to set the resolution to a normal setting also.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Running-OSX-Lion-on-Windows-with-VMWare-_13C9B/image_12.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Running-OSX-Lion-on-Windows-with-VMWare-_13C9B/image_thumb_5.png" width="634" height="364"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Even the App store appears to be working just fine. &lt;/p&gt; &lt;p&gt;If I can just try to get Unity to work it’ll be perfect. Having Windows AND OS X in 1 environment sounds great to me! Otherwise I’ll just have to sacrifice 1 of my monitors for OS X and the rest for Windows.&lt;/p&gt; &lt;p&gt;I heard Ruby development is quite nice in OS X, so I guess I’ll have to check it out some time soon now!&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The referenced binaries can be found on SysProbs also, just added them here for future reference in case the links go down.&lt;/p&gt;</description><pubDate>Thu, 26 Apr 2012 09:39:12 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/running-osx-lion-on-windows-with-vmware-workstation</guid></item><item><title>Upgrade Orchard 1.3 to 1.4</title><link>http://www.jan-v.nl:80/upgrade-orchard-1.3-to-1.4</link><description>&lt;p&gt;As I’m busy designing and developing my new weblog I noticed a minor Orchard version was released. Because I’m in the starting phase of the development cycle, I decided to upgrade to the latest version. &lt;/p&gt; &lt;p&gt;This is rather easy, as you can just download the &lt;a href="http://orchard.codeplex.com/"&gt;latest sources from CodePlex&lt;/a&gt;, extract and copy them over the old codebase (well, I deleted the original 1.3 files and copied the 1.4 files to a ‘clean’ folder).&lt;/p&gt; &lt;p&gt;Upgrading the Orchard sources broke several of my new modules, so I had to fix the broken code. After resolving those issues I pressed [Ctrl]+[F5] to see if everything was still working. It wasn’t…&lt;/p&gt; &lt;p&gt;Starting the site, I received a 404 error, because the pages couldn’t be found. Logs weren’t very helpful, aside from telling me some queries couldn’t run correctly. Deleting the &lt;em&gt;/Sites/&lt;/em&gt;-folder in the &lt;em&gt;App_Data&lt;/em&gt; did help me a bit, because now it showed me the normal ‘&lt;em&gt;Orchard set up new site&lt;/em&gt;’ form. &lt;br&gt;Because I was starting to get a bit frustrated I decided to create a new website and have the connectionstring map to my old Orchard weblog database. This didn’t work either. Now there was an error the Recipes modules couldn’t be found or instantiated.&lt;/p&gt; &lt;p&gt;After having spent several hours searching for a solution by myself I finally stumbled upon a post of &lt;a href="http://www.sarasota.me/blog/orchard-website-upgraded-to-1.4-autoroute-projector-module-and-new-fields"&gt;David Hayden telling something about an UpgradeTo14 module&lt;/a&gt;. Apparently you need to activate a module to do a successful upgrade.&lt;/p&gt; &lt;p&gt;In my search for the problem I had already learned there are some issues with the blog titles not showing anymore if you didn’t had the Title module enabled while migrating. The recipes error was also something still fresh in my mind, so I decided to follow this upgrade path:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Navigate to the admin area of your site http://localhost:30320/YourSite/Admin/&lt;/li&gt; &lt;li&gt;Enable the Title module&lt;/li&gt; &lt;li&gt;Enable the Recipes module&lt;/li&gt; &lt;li&gt;Enable the UpgradeTo14 module&lt;/li&gt; &lt;li&gt;Click on the Migrate to 1.4 link&lt;/li&gt; &lt;li&gt;In the Migrate Routes tab, check all options and click Migrate&lt;/li&gt; &lt;li&gt;In the Migrate Fields tab, check all options and click Migrate&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;As I didn’t had any other 3rd party modules installed, this all worked out like a charm. If you’ve got modules installed which aren’t compatible with 1.4, you’re probably have a problem migrating and are better off staying at 1.3 for now.&lt;/p&gt; &lt;p&gt;Now that I’ve got the new version installed I can’t wait to play with the &lt;a href="http://www.davidhayden.me/blog/projector-module-in-orchard-cms"&gt;Projector&lt;/a&gt; module, which looks really awesome. For now I’ll stick with getting my new weblog online as soon as possible, so playing around will just have to wait.&lt;/p&gt;</description><pubDate>Tue, 24 Apr 2012 18:00:47 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/upgrade-orchard-1.3-to-1.4</guid></item><item><title>Disable hibernate via registry when nothing else works</title><link>http://www.jan-v.nl:80/disable-hibernate-via-registry-when-nothing-else-works</link><description>&lt;p&gt;One of my development machines has a dual-boot to a 2008R2 environment via the &lt;a href="http://blogs.msdn.com/b/knom/archive/2009/04/07/windows-7-vhd-boot-setup-guideline.aspx"&gt;Boot from VHD&lt;/a&gt; technique. This works all quite well, but today I received the message the C-drive was getting a bit full. Most of the time this isn’t much of a problem, just delete some log files, do a disk cleanup, empty the recycle bin and maybe use &lt;a href="http://www.sixty-five.cc/sm/"&gt;SpaceMonger&lt;/a&gt; to see what’s using up the rest of the space. Also, most of the time there’s about 500MB left free on the disk. &lt;/p&gt; &lt;p&gt;Today was different. Visual Studio wasn’t able to build my solution due to insufficient free disk space on the C-drive. Upon further inspection I saw a total of 0 free bytes were available. After doing the regular cleanup I had a stunning 119MB free on my C-drive. SpaceMonger had already shown me there was a hibernate file on the C-drive which took up 8GB. Quite strange considering I had turned off all of my hibernate options in Windows (I really don’t like hibernating). Also, this hibernate file doesn’t get generated when booting the machine in VMWare Player or VMWare Workstation.&lt;/p&gt; &lt;p&gt;All of my internet sources say you have to run &lt;font face="Courier New"&gt;powercfg –h off&lt;/font&gt; and reboot to completely remove the file. Problem with that is it gave (and still gives) me the following error:&lt;/p&gt; &lt;p&gt;“An internal system component has disabled hibernation”&lt;/p&gt; &lt;p&gt;&lt;img alt="image" src="http://sundium.files.wordpress.com/2011/05/image_thumb.png?w=584&amp;amp;h=121"&gt;&lt;/p&gt; &lt;p&gt;Microsoft also has a &lt;a href="http://support.microsoft.com/kb/920730"&gt;Fix it solution&lt;/a&gt; for it, but that didn’t do the trick for me either. Also &lt;a href="http://www.emptyloop.com/unlocker/"&gt;Unlocker&lt;/a&gt; couldn’t do a lot with this file.&lt;/p&gt; &lt;p&gt;After searching for a few hours on this subject I finally &lt;a href="http://sundium.wordpress.com/2011/05/25/an-internal-system-component-has-disabled-hibernation/"&gt;stumbled upon the weblog of Jian Sun&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The solution to the problem is to disable the hibernation via the registry. The hibernate options can be found in the following path:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentCongtrolSet\Control\Power\&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Over here you can find the &lt;font face="Courier New"&gt;HiberFileSizePercent&lt;/font&gt; and &lt;font face="Courier New"&gt;HibernateEnabled&lt;/font&gt; keys. The blog of Jian Sun says you need to change the &lt;font face="Courier New"&gt;HibernateEnabled&lt;/font&gt; from 1 to 0 to disable the hibernation (and reboot of course). This didn’t do the trick for me, so I started changing the &lt;font face="Courier New"&gt;HiberFileSizePercent&lt;/font&gt; key. It was saying 100 when I started, but I’ve changed it to 2 now (so I don’t confuse it with a &lt;em&gt;bit&lt;/em&gt; later on). After rebooting the filesize of hiberfil.sys was about 160MB. This really solved my disk space problem for now.&lt;/p&gt; &lt;p&gt;So, if you want to get rid of your hibernate file on the C-drive and aren’t able to get this working via the normal protocol, do some registry changes.&lt;/p&gt;</description><pubDate>Wed, 18 Apr 2012 17:29:22 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/disable-hibernate-via-registry-when-nothing-else-works</guid></item><item><title>Get your references when pulling a project via NuGet</title><link>http://www.jan-v.nl:80/get-your-references-when-pulling-a-project-via-nuget</link><description>&lt;p&gt;Because of a failing hard drive I had to re-install my Windows installation, including cloning all of my BitBucket repositories back to my projects folder. &lt;/p&gt; &lt;p&gt;Getting all the solutions back on the local development machine is very easy, but after opening, I discovered they couldn’t be build anymore. The reason for this: several references were missing. This wasn’t that strange at all, because these references were libraries pulled pulled down via NuGet and not pushed into the repository. &lt;/p&gt; &lt;p&gt;I had suspected there was something in NuGet which would make it easy to download the referenced packages. Reason for me to expect this is the &lt;font face="Consolas"&gt;packages.config&lt;/font&gt; file which is created after pulling down NuGet packages. This file contains all the information needed to re-download them, you see?&lt;/p&gt;&lt;pre class="brush:xml"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;packages&amp;gt;
  &amp;lt;package id="FluentAssertions" version="1.7.1.1" /&amp;gt;
  &amp;lt;package id="Moq" version="4.0.10827" /&amp;gt;
&amp;lt;/packages&amp;gt;
&lt;/pre&gt;
&lt;p&gt;At the moment there isn’t an option (i.e.: I couldn’t find it) to re-download the referenced libraries in the NuGet package manager. After doing a bit more research on the matter I discovered a page in the NuGet documentation called ‘&lt;a href="http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages"&gt;Using NuGet without committing packages to source control’&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Over there they tell you to use the ‘Enable NuGet Package Restore’-option, which is available after right-clicking on the solution file. &lt;/p&gt;
&lt;p&gt;&lt;img alt="Enable NuGet Package Restore Context Menu item" src="http://docs.nuget.org/docs/workflows/images/enable-package-restore.png"&gt;&lt;/p&gt;
&lt;p&gt;So, this is what I did and it kind of worked. This adds a new solution folder with the name .nuget and a nice NuGet executable.&lt;/p&gt;
&lt;p&gt;&lt;img alt="New Solution folder with package restore files" src="http://docs.nuget.org/docs/workflows/images/package-restore-solution.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;An important note&lt;/strong&gt;: Make sure you don’t have too much projects loaded in the solution. I’ve tried this option in my Orchard solution with several projects of my own and was confronted with several Internal Server Errors 500 (time outs). After I made sure just my own custom projects were loaded and all other Orchard projects were unloaded, this option worked like a charm.&lt;/p&gt;
&lt;p&gt;When building the solution, the libraries should get automatically downloaded and installed in the corresponding packages folder. &lt;br&gt;Well, I must have done something wrong when I added the references in the past (via an old NuGet console), because the libraries weren’t placed in the (correct) packages folder.&lt;/p&gt;
&lt;p&gt;Lucky for me, the newly added NuGet executable can be started via a command prompt also and it takes several startup parameters. The complete list (for the current version):&lt;/p&gt;&lt;pre class="brush:shell"&gt;NuGet Version: 1.7.30402.9028
usage: NuGet &lt;command&gt; [args] [options]
Type 'NuGet help &lt;command&gt;' for help on a specific command.

Available commands:

 delete      Deletes a package from the server.
 help (?)    Displays general help information and help information about other
             commands.
 install     Installs a package using the specified sources. If no sources are
             specified, all sources defined in %AppData%\NuGet\NuGet.config are
             used.  If NuGet.config specifies no sources, uses the default NuGe
             t feed.
 list        Displays a list of packages from a given source. If no sources are
             specified, all sources defined in %AppData%\NuGet\NuGet.config are
             used. If NuGet.config specifies no sources, uses the default NuGet
             feed.
 pack        Creates a NuGet package based on the specified nuspec or project f
             ile.
 publish     Publishes a package that was uploaded to the server but not added
             to the feed.
 push        Pushes a package to the server and optionally publishes it.
 setApiKey   Saves an API key for a given server URL. When no URL is provided A
             PI key is saved for the NuGet gallery.
 sources     Provides the ability to manage list of sources located in  %AppDat
             a%\NuGet\NuGet.config
 spec        Generates a nuspec for a new package. If this command is run in th
             e same folder as a project file (.csproj, .vbproj, .fsproj), it wi
             ll create a tokenized nuspec file.
 update      Update packages to latest available versions. This command also up
             dates NuGet.exe itself.

For more information, visit http://docs.nuget.org/docs/reference/command-line-re
ference
&lt;/pre&gt;
&lt;p&gt;As I only need to install the packages which are specified in the auto-generated &lt;font face="Consolas"&gt;packages.config&lt;/font&gt;. To do this, the following command can be used from within the command prompt:&lt;/p&gt;&lt;pre class="brush:shell"&gt;nuget i ..\MvcApplication3\packages.config -o ..\Packages&lt;/pre&gt;
&lt;p&gt;This will install the packages in the Packages folder on the same level as the project folder and your folder structure will look like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/0592503cad9b_130A1/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/0592503cad9b_130A1/image_thumb.png" width="183" height="86"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;After having executed this command I was finally able to do a successful build again.&lt;/p&gt;
&lt;p&gt;It takes a bit of research, but in the end everything will work. I guess these issues will get resolved in future releases of NuGet, but for now this workaround will work.&lt;/p&gt;</description><pubDate>Fri, 13 Apr 2012 20:33:25 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/get-your-references-when-pulling-a-project-via-nuget</guid></item><item><title>Update Orchard theme using SQL statement if the UI does not work anymore</title><link>http://www.jan-v.nl:80/update-orchard-theme-using-sql-statement-if-the-ui-does-not-work-anymore</link><description>&lt;p&gt;If you create a theme for Orchard, it&amp;rsquo;s only a matter of time before you stumble across a &lt;a href="http://en.wikipedia.org/wiki/Screen_of_death"&gt;yellow screen of death&lt;/a&gt;. I know this, because it happened multiple times to me. One of the reasons for these errors are the &lt;a href="http://msdn.microsoft.com/en-us/library/dd264741.aspx"&gt;dynamic&lt;/a&gt; objects, which are used a lot in Orchard.&lt;/p&gt;
&lt;p&gt;You won&amp;rsquo;t get compile-time errors with these objects, so they need to be handled with care.&lt;/p&gt;
&lt;p&gt;Now, when a theme causes a yellow screen you are kind of screwed as you can&amp;rsquo;t do anything anymore on the website, like logging in to the admin area.&lt;/p&gt;
&lt;p&gt;Lucky for us developers, the database isn&amp;rsquo;t obfuscated and we can make rapid changes to it. You can use this script to update your current Orchard theme and set it back to the default Theme Machine theme.&lt;/p&gt;
&lt;pre class="brush:sql"&gt;UPDATE [OrchardDatabaseName].[dbo].[default_Orchard_Themes_ThemeSiteSettingsPartRecord]
   SET [Id] = 1
      ,[CurrentThemeName] = 'TheThemeMachine'
GO
&lt;/pre&gt;
&lt;p&gt;Run the above script on your Orchard database and you will be able to start developing again.&lt;/p&gt;
&lt;p&gt;If the above script doesn&amp;rsquo;t work, check the &lt;span style="font-family: 'Courier New';" face="Courier New"&gt;[default_Orchard_Themes_ThemeSiteSettingsPartRecord]&lt;/span&gt; table entries. You possibly need to change the Id parameter of the script to the one which is the same as in the database&lt;/p&gt;</description><pubDate>Thu, 15 Sep 2011 07:29:42 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/update-orchard-theme-using-sql-statement-if-the-ui-does-not-work-anymore</guid></item><item><title>Getting the Orchard archive to work in your blog</title><link>http://www.jan-v.nl:80/getting-the-orchard-archive-to-work-in-your-blog</link><description>&lt;p&gt;A few months ago I decided to &lt;a href="http://www.jan-v.nl/migratie-naar-orchard"&gt;migrate my weblog from SharePoint to Orchard&lt;/a&gt;, because it’s more lightweight and better suited as a simple blog. I also started to develop some custom modules and themes for this CMS and have to say I like it!&lt;/p&gt; &lt;p&gt;One thing though, which has bothered me from the beginning, was the empty Archive block at the right side of my blog. I had done so much work to import the SharePoint blog entries to Orchard (a manual copy-paste action), so I knew the posts were there, I could even browse to them.&lt;br&gt;Why was it my posts weren’t visible in the archive block?&lt;/p&gt; &lt;p&gt;Today, I found the answer to my problem. It’s a small bug in Orchard when you set the &lt;a href="http://orchard.codeplex.com/discussions/254388"&gt;blog to be the homepage&lt;/a&gt; of the site. Somehow the records in the &lt;font face="Courier New"&gt;[Orchard_Blogs_BlogArchivesPartRecord]&lt;/font&gt; table aren’t updated properly. The &lt;font face="Courier New"&gt;BlogSlug&lt;/font&gt; column should be changed to NULL and not contain the name of your weblog.&lt;/p&gt; &lt;p&gt;Once I knew this I changed the entries so they would contain the value &lt;font face="Courier New"&gt;NULL&lt;/font&gt;:&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Getting-the-Orchard-archive-to-work-in-y_107BF/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Getting-the-Orchard-archive-to-work-in-y_107BF/image_thumb.png" width="173" height="145"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="1"&gt;&lt;strong&gt;Note&lt;/strong&gt;: You probably have got 1 record, but apparently I’ve done some adding and deleting of blogs, so I’ve got multiple. I can probably delete 3 of them, but just to be sure I didn’t.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Now, after checking the frontpage again I indeed saw a filled out Archive block. It wasn’t showing the correct/expected data, but at least it had some data in it.&lt;/p&gt; &lt;p&gt;In order to retrieve the Archive data, Orchard has a table called &lt;font face="Courier New"&gt;[Orchard_Blogs_BlogPartArchiveRecord]&lt;/font&gt;, which is filled with a summary of posts made in a specific year and month.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Getting-the-Orchard-archive-to-work-in-y_107BF/image_4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Getting-the-Orchard-archive-to-work-in-y_107BF/image_thumb_1.png" width="292" height="370"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;A nice feature performance wise, but somehow it didn’t had the correct information of my blog. That’s probably because I imported the SharePoint blog entries manual to Orchard and only changed the Created date in the &lt;font face="Courier New"&gt;[Common_CommonPartRecord]&lt;/font&gt; table of the database.&lt;/p&gt; &lt;p&gt;The Archive block probably uses some other columns and maybe even the &lt;font face="Courier New"&gt;[Common_CommonPartVersionRecord]&lt;/font&gt; table, so I had to change the dates of the other columns in these tables also.&lt;/p&gt; &lt;p&gt;Lucky for me, I’ve done some pretty big SQL queries in the past, so this didn’t pose as a big challenge. The correct dates were stored in the &lt;font face="Courier New"&gt;[Common_CommonPartRecord].[CreatedUtc]&lt;/font&gt; column, so updating the &lt;font face="Courier New"&gt;[Common_CommonPartRecord]&lt;/font&gt; table was fairly easy, I used this script:&lt;/p&gt;&lt;pre class="brush: sql"&gt;update Common_CommonPartRecord
set
	PublishedUtc = CreatedUtc,
	ModifiedUtc = CreatedUtc
&lt;/pre&gt;
&lt;p&gt;To update the &lt;font face="Courier New"&gt;[Common_CommonPartVersionRecord]&lt;/font&gt; I had to use a cursor in order to update the columns the way I wanted. Still a fairly easy script, if you know cursors exist in SQL Server.&lt;/p&gt;&lt;pre class="brush: sql"&gt;DECLARE @Id INT
DECLARE @CreatedUtc DATETIME

DECLARE blogCursor CURSOR FOR 
	select Id, CreatedUtc
	from Common_CommonPartRecord
	where Id &amp;lt; 236
	
open blogCursor;

fetch next from blogCursor
INTO @Id, @CreatedUtc

WHILE @@FETCH_STATUS = 0
BEGIN
	PRINT @Id
	PRINT @CreatedUtc
	
	UPDATE Common_CommonPartVersionRecord
	SET
		CreatedUtc = @CreatedUtc,
		ModifiedUtc = @CreatedUtc,
		PublishedUtc = @CreatedUtc
	WHERE Common_CommonPartVersionRecord.ContentItemRecord_id = @Id
	
	FETCH NEXT FROM blogCursor INTO @Id, @CreatedUtc
END
		
CLOSE blogCursor

DEALLOCATE blogCursor
&lt;/pre&gt;
&lt;p&gt;The site still displayed the wrong number of posts per year or month. This didn’t came as a surprise as the numbers within the &lt;font face="Courier New"&gt;[Orchard_Blogs_BlogPartArchiveRecord]&lt;/font&gt; table were still the same. I thought a search update might help. After rebuilding the search index the Archive posts were still all wrong.&lt;br&gt;Checking out the Orchard source code on this subject told me something I didn’t guessed:&lt;/p&gt;&lt;pre class="brush: csharp"&gt;public BlogPartArchiveHandler(IRepository&lt;blogpartarchiverecord&gt; blogArchiveRepository, IBlogPostService blogPostService) {
            OnPublished&lt;blogpostpart&gt;((context, bp) =&amp;gt; RecalculateBlogArchive(blogArchiveRepository, blogPostService, bp));
            OnUnpublished&lt;blogpostpart&gt;((context, bp) =&amp;gt; RecalculateBlogArchive(blogArchiveRepository, blogPostService, bp));
            OnRemoved&lt;blogpostpart&gt;((context, bp) =&amp;gt; RecalculateBlogArchive(blogArchiveRepository, blogPostService, bp));
        }
&lt;/pre&gt;
&lt;p&gt;Because of the nicely worded methods I was able to figure out I just needed to publish, unpublish or delete a blogpost. After re-publishing one of my posts the Archive block was updated with the correct numbers.&lt;/p&gt;
&lt;p&gt;And now, the Archives are shown correct. Still the current year doesn’t contain any elements, I’ll need to check out what’s the matter with that. The numbers in the tables are all correct, so it’s probably some other bug.&lt;/p&gt;&lt;pre&gt;&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;</description><pubDate>Wed, 27 Jul 2011 17:11:26 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/getting-the-orchard-archive-to-work-in-your-blog</guid></item><item><title>ForeFront TMG does not work after Windows Updates (Internet Explorer 9.0)</title><link>http://www.jan-v.nl:80/forefront-tmg-doesn-rsquo-t-work-after-windows-updates-internet-explorer-9.0</link><description>&lt;p&gt;A few weeks ago I was finally able to install some updates on my ForeFront TMG server, so I installed SP1 of Windows Server 2008R2, all other updates and Internet Explorer 9.0. After noticing my internet connection didn&amp;rsquo;t work anymore I logged in on the server and wanted to check what was wrong using the Management Console.&lt;/p&gt;
&lt;p&gt;This is when I noticed the ForeFront TMG Management Console didn&amp;rsquo;t work anymore. Every treenode I selected resulted in an alert message stating &amp;lsquo;Member not Found&amp;rsquo;, &amp;lsquo;Refresh failed&amp;rsquo;, etc.&lt;/p&gt;
&lt;p&gt;At times like this you wish you had created a backup of the server, before you updated it.&lt;/p&gt;
&lt;p&gt;Lucky for me I was able to go to the internet with a direct line on my router and search for a solution. Because these updates were long overdue, someone must have had the same issue as me. This is one of the reasons I don&amp;rsquo;t like working with new/beta software of area&amp;rsquo;s I don&amp;rsquo;t know much about. I know a thing or two about managing a Microsoft network, but most things are magic to me.&lt;/p&gt;
&lt;p&gt;An answer to my problem could be found on the &lt;a href="http://social.technet.microsoft.com/Forums/en-US/Forefrontedgegeneral/thread/bae2d851-6099-4367-a125-b77a2b8a694b/"&gt;ForeFront Technet forums of Microsoft&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To fix the issue you need to edit some file/html of ForeFront which resided on your local filesystem. The file which needs to be edited is: &amp;ldquo;&lt;em&gt;C:\Program Files\Microsoft Forefront Threat Management Gateway\UI_HTMLs\TabsHandler\TabsHandler.htc&lt;/em&gt;&amp;rdquo;. Open this file using Notepad as an Administrator.&lt;/p&gt;
&lt;p&gt;Now search for the lines which contain the text &amp;ldquo;&lt;strong&gt;paddingTop&lt;/strong&gt;&amp;rdquo; in them, these (3?) lines reside in some JavaScript blocks and you need to comment them out. You can do this by placing two slashes (//) at the front of the line.&lt;/p&gt;
&lt;p&gt;Example: Change the line: &lt;br /&gt;&lt;em&gt;m_aPages [niPage].m_tdMain.style.paddingTop = ((m_nBoostUp &amp;lt; 0) ? -m_nBoostUp : 0) ; &lt;br /&gt;&lt;/em&gt;into: &lt;br /&gt;&lt;em&gt;// m_aPages [niPage].m_tdMain.style.paddingTop = ((m_nBoostUp &amp;lt; 0) ? -m_nBoostUp : 0) ; &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Now, save the file and re-open the ForeFront TMG Management Console.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll be able to navigate in the console again and do your modifications.&lt;/p&gt;</description><pubDate>Wed, 27 Jul 2011 16:37:27 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/forefront-tmg-doesn-rsquo-t-work-after-windows-updates-internet-explorer-9.0</guid></item><item><title>Creating a developer SSL certificate on IIS 6.0</title><link>http://www.jan-v.nl:80/creating-a-developer-ssl-certificate-on-iis-6.0</link><description>&lt;p&gt;It’s one of those things you need to do once and forget about it. Sometimes it’s necessary to develop something which required talking to a webservice. A lot of the times, the webservice is secured with an SSL certificate in the real world. &lt;/p&gt; &lt;p&gt;As most companies don’t want to spend good money to real SSL certificates for development workstations/servers, we have to create our own. You can of course develop the functionality with a non-secured environment, but for testing purposes it’s probably useful to have the test environment match the QA or production servers.&lt;/p&gt; &lt;p&gt;A while back I had an issue in some production software. We discovered something was malfunctioning I was needed to figure out what was wrong. As the code hadn’t changed in quite some time and it appeared the code was good (enough), I started looking at the infrastructure and discovered it might have something to do with the webservice (in SSL) it was talking to. As I couldn’t connect to the production environment, I had to connect to a local service which was running in SSL, so I did.&lt;/p&gt; &lt;p&gt;If you want to do this, you need to take quite some steps if you are running on IIS 6.0. This feature has improved a lot IIS 7.0/7.5. ScotGu has &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/04/06/tip-trick-enabling-ssl-on-iis7-using-self-signed-certificates.aspx"&gt;written a nice walkthough&lt;/a&gt; about this. Just hit the &lt;em&gt;Create Self-Signed Certificate&lt;/em&gt; link and you are done. Too bad I was still developing in an IIS 6.0 environment (Windows 2003R2). I’ll describe the needed steps below.&lt;/p&gt; &lt;p&gt;The first thing which needs to be done is downloading the &lt;a href="http://support.microsoft.com/kb/840671"&gt;IIS 6.0 Resource Kit Tools&lt;/a&gt;. This doesn’t appear to be a big problem, but for me it was. I had found a lot of pages linking to the kit, but all of them were dead. After finally having found the &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=56fc92ee-a71a-4c73-b628-ade629c89499&amp;amp;displaylang=en"&gt;correct link&lt;/a&gt; I was good to go and installed the needed &lt;a href="http://support.microsoft.com/kb/840671#11"&gt;SelfSSL&lt;/a&gt; application.&lt;/p&gt; &lt;p&gt;The tool comes with a decent help which you can check by typing &lt;em&gt;selfssl /?&lt;/em&gt; in the command prompt. As we need to add a self-signed certificate to a website in IIS on a specific port number, we need the arguments /T, /S and /P. The values we need can be found in IIS Manager. The site ID and port number is specified in the overview of the websites:&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_thumb.png" width="570" height="28"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;In this case the site ID is 165159687 and the SSL port number we want to use is 82. The command we need to use will look like this:&lt;/p&gt; &lt;p&gt;&lt;font style="background-color: #000000" color="#ffffff" face="Courier New"&gt;selfssl /T /S:165159687 /P:82&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Now the certificate is in place and you can visit the secured website in the browser. Once there you’ll see a message, something like this (depending on the browser) &lt;br&gt;&lt;em&gt;(note: the following steps are also needed if you are running on the IIS7.0 webserver and are optional)&lt;/em&gt;:&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_4.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_thumb_1.png" width="579" height="246"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;As this is our development site we can safely choose &lt;em&gt;Continue on this website (not recommended)&lt;/em&gt;. Once we are on the website you can see a small message next to the address bar stating there’s a &lt;em&gt;Certificate Error&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_6.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_thumb_2.png" width="175" height="54"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;You can click on this message and a popup will appear.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_8.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_thumb_3.png" width="254" height="265"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;By clicking the link &lt;em&gt;View certificates&lt;/em&gt; you can add the certificate to your local store so this error won’t be shown again. The following popup will appear:&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_10.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_thumb_4.png" width="296" height="346"&gt;&lt;/a&gt;&lt;br&gt;&lt;em&gt;(machine name and dates will vary)&lt;/em&gt;&lt;/p&gt; &lt;p&gt;If you want you can check some of the details in this popup, but as we know this is all good we can just click the &lt;em&gt;Install Certificate&lt;/em&gt; button in the lower corner.&lt;/p&gt; &lt;p&gt;Stepping through the wizard you will get the option to place the certificate in a store. I first tried out the &lt;em&gt;Automatically select….&lt;/em&gt;, but that didn’t have the desired effect. After that I’ve tried the Personal store, but that didn’t help much either. After having tried those two options, I’ve placed the certificate in the &lt;em&gt;Trusted Root Certification Authorities&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_12.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/Creating-a-developer-SSL-certificate_12CEE/image_thumb_5.png" width="399" height="131"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;This had the desired effect, I could check the local SSL webservice without the annoying warning messages. With everything up and running the code could be debugged to check it was working properly with an SSL webservice. Lucky for me, it did, so I had to look for another solution for the problem.&lt;/p&gt;     &lt;p&gt;Remember, only apply the above steps if you know you can trust the certificate. Don’t add certificates from the web from ‘fishy’ sites. It can cause a lot of problems to you and your computer.&lt;/p&gt;</description><pubDate>Sat, 14 May 2011 20:09:26 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/creating-a-developer-ssl-certificate-on-iis-6.0</guid></item><item><title>Technical documentation: how and what to write</title><link>http://www.jan-v.nl:80/technical-documentation-how-and-what-to-write</link><description>&lt;p&gt;In the past couple of years I&amp;rsquo;ve written quite a lot of documentation, be it functional, technical, help files for end-users, flyers, proposals and much more. Most developers I know try to avoid writing these kind of things as much as they can, but let&amp;rsquo;s face it, it is part of our job.&lt;/p&gt;
&lt;p&gt;At the moment I&amp;rsquo;m working in a team with pretty smart and experienced developers, but as it goes, one of our team members has been placed on an other team at a different customer and I was asked to replace him. The leaving developer had created an awesome framework, the code looks good, unit test coverage was (and still is) near 100% and it&amp;rsquo;s quite understandable if you step through the code. The only thing missing was technical and functional documentation. He and I tried to write some of documentation on the framework, but what do you need write in such documents?&lt;/p&gt;
&lt;p&gt;Then it struck me, we developers are always trying to improve our coding and design skills and trying out new things and new languages, but we hardly try to improve ourselves in writing documentation.&lt;br /&gt;I&amp;rsquo;ve never had a class at school on how to write functional or technical documents. Also, I&amp;rsquo;ve never seen any specifications at a company on how such documents should look like or what you should describe. Most of the time you have to figure it out yourself, think of some stuff you would like to see in it yourself and create some UML-diagrams to keep managers happy (a lot of developers don&amp;rsquo;t understand UML, so they skip it). &lt;br /&gt;Another thing is where do you save these documents. Do you want them in a project repository (TFS), on a file share, in a CMS, etc.? In the past, most documents I&amp;rsquo;ve written were saved on some file share with a version number in the filename. A bit old-fashioned, but it works (for 1 editor at a time). At the current customer we&amp;rsquo;ve created a Wiki site in SharePoint in which we describe all the functional and technical specs. This is a bit better as to saving a Word document on a file share as everyone can change the contents and it&amp;rsquo;s available through the web. Also, it&amp;rsquo;s easier to maintain and SharePoint has it&amp;rsquo;s own versioning system for checking the changes.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;d recommend doing writing Wiki&amp;rsquo;s (or some other CMS solution) over writing Word documents as it&amp;rsquo;s easier to maintain and more user friendly (in my opinion).&lt;br /&gt;This still leaves the question on what you need to write in the documentation.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s not very useful to describe in detail on what the code fragments do. The code will probably be refactored and updating the documentation will be forgotten. Also, if the code is clear enough, the developer can see for himself what a specific code block does. Something which can (and should) be described is why a certain solution is chosen. If something can&amp;rsquo;t be made clear through code, it should probably be described in some documentation. Like, why are we using SOAP messages, can&amp;rsquo;t we handle JSON?&lt;br /&gt;Most of the time you can&amp;rsquo;t figure out why such design decisions were made during development. One of the things which I also found quite useful was the fluent configuration diagram. It described how the fluent configuration was implemented. If you are a newcomer to a project, you probably won&amp;rsquo;t know what a certain implementation will do and when to use it.&lt;br /&gt;Also describing some best practices can be useful for other developers. Hardware and software specifications are necessary most of the time and it&amp;rsquo;s probably a good idea to describe the main purpose of the different classes/interfaces.&lt;/p&gt;
&lt;p&gt;In short, I think it's good to do the following when writing documentation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Save it online (wiki, CMS)&lt;/li&gt;
&lt;li&gt;Make sure there's (automatic) version control&lt;/li&gt;
&lt;li&gt;Describe design decisions&lt;/li&gt;
&lt;li&gt;Describe why you implemented something in the way you did&lt;/li&gt;
&lt;li&gt;Only document stuff you think is necessary for the reading audience&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I do hope to come across some books or whitepapers which describe what I should be writing in these kind of technical (and functional) documents as I haven&amp;rsquo;t seen one yet. There are some guidelines, but most of them are bloated and have several chapters which you don&amp;rsquo;t want to read because they aren&amp;rsquo;t interesting for most people.&lt;/p&gt;
&lt;p&gt;Now, off writing some documents again&amp;hellip;..&lt;/p&gt;</description><pubDate>Fri, 13 May 2011 10:30:00 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/technical-documentation-how-and-what-to-write</guid></item><item><title>Expression trees, delegates, functors how and why to use them</title><link>http://www.jan-v.nl:80/expression-trees-amp-func-rsquo-s-differences-and-why-use-it</link><description>&lt;p&gt;As of two weeks ago I’ve had the privilege to start doing some development work in a project where a lot of expression trees are used and most classes have at least one implementation of a Func delegate. There’s nothing wrong with that, as it’s something which dates from the .NET 3.0 era if I’m not mistaken, so every .NET 3.5 certified/professional developer should know the existence of them. Downside is, if your only real experience with the matter is reading them up in a text book, there’s a big chance you have forgotten on how and why to use it. Most importantly, what it does.&lt;/p&gt; &lt;p&gt;Lucky for me I’ve done a WP7 project in the &lt;a href="http://www.jan-v.nl/wp7-silverlight-en-m%E2%80%99n-n-layer-architectuur"&gt;recent past&lt;/a&gt; where I became a bit more familiar with the Func and Action delegates. Still, I got the feeling I don’t know half of the stuff you can use it for. This became even more clear 2 weeks ago when I started on this project. I could read the code and visualize what the code was doing, but couldn’t implement new features in a reasonable amount of time. Lucky for me I’m working in a team with several other developers who have (a lot) more experience on the subject explained what I needed to do. While listening to them I thought “Hey, this is easy, why didn’t I think of it!” and started implementing the new code. &lt;br&gt;I think this is the tricky part of developing, it appears to be so easy if it’s explained to you, but hard to think of if you got no real experience with the matter.&lt;/p&gt; &lt;p&gt;Just to be sure, I did small search on what a &lt;a href="http://msdn.microsoft.com/en-us/library/bb549151.aspx"&gt;Func&lt;/a&gt; and an &lt;a href="http://msdn.microsoft.com/en-us/library/018hxwa8.aspx"&gt;Action&lt;/a&gt; represented. I also needed to do a sarch on something completely new to me, an &lt;a href="http://msdn.microsoft.com/en-us/library/bb397951.aspx"&gt;Expression tree&lt;/a&gt;. It’s probably me, but I can’t remember reading up on anything called like that studying for my exams (&lt;a href="http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-536&amp;amp;locale=en-us"&gt;70-536&lt;/a&gt;, &lt;a href="http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-562&amp;amp;locale=en-us"&gt;70-562&lt;/a&gt; &amp;amp; &lt;a href="http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-564&amp;amp;locale=en-us"&gt;70-564&lt;/a&gt;). This probably means I forgot it even existed and didn’t have any questions on it in the exams (phew!).&lt;/p&gt; &lt;p&gt;Reading up on the matter, it appears an Expression tree is just a fancy word for an ‘&lt;em&gt;uncompiled piece of code&lt;/em&gt;’. You can modify the body of the tree so it behaves just the way you want it. After compiling the piece of code you can invoke it with the parameters you want. Quite a powerful feature for sure, if you know how to handle it. A quite familiar expression tree (if you’ve done some database developing with LINQ) is the &lt;a href="http://msdn.microsoft.com/en-us/library/bb546158.aspx"&gt;IQueryable&lt;/a&gt;. You can extend the ‘body’ of the method by calling a lot of lambda’s on it and it get’s compiled when you need to retrieve the data of the collection. That’s the main reason it’s better to use an &lt;a href="http://www.sellsbrothers.com/posts/details/12614"&gt;IQueryable instead of an IEnumerable&lt;/a&gt; when creating a query.&lt;/p&gt; &lt;p&gt;While browsing through the code my mind blown by the following:&lt;/p&gt;&lt;pre class="brush:csharp"&gt;Expression&amp;lt;Func&amp;lt;IViewModel, object&amp;gt;&amp;gt;&lt;/pre&gt;
&lt;p&gt;I thought I understood the delegates, but this was above my comprehension. Luckily for me I’m not the only one who is struggling with it. Searching for it led me to &lt;a href="http://stackoverflow.com/questions/2664841/difference-between-expressionfunc-and-func"&gt;StackOverflow&lt;/a&gt; and I especially like the following comment:&lt;/p&gt;
&lt;div style="background-color: #aaa"&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;Expression&amp;lt;Func&amp;lt;...&amp;gt;&amp;gt;&lt;/code&gt;&lt;/strong&gt; is an &lt;em&gt;expression tree&lt;/em&gt; which represents the original source code (it is stored in a tree-like data structure that is very close to the original C# code). In this form, you can analyze the source code and tools like LINQ to SQL can translate the expression tree (source code) to other languages (e.g. SQL in case of LINQ to SQL, but you could also target e.g. JavaScript).&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;Func&amp;lt;...&amp;gt;&lt;/code&gt;&lt;/strong&gt; is an ordinary delegate that you can execute. In this case, the compiler sompiles the body of the function to intermediate language (IL) just like when compiling standard method.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/div&gt;
&lt;p&gt;Developing the WP7 app was my first real experience with these delegate methods. It is awesome what you can do, just by passing a ‘method’ as a parameter to another layer (or class) in your design. With the introduction of expression trees you can even pass methods to different pieces of code and modify the body of it, depending on the situation. Now that’s even more &lt;strong&gt;awesome!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You might have guessed it, I’m starting to become a big fan of these features. The main reason for this post is to remind me on how these things work and what’s the difference between them.&lt;br&gt;Next up are some code examples which will try to make it clear what the different kind of delegates mean and how they can be used. There’s a different &lt;a href="http://dotnetslackers.com/Community/blogs/simoneb/archive/2006/08/20/367.aspx"&gt;blogpost&lt;/a&gt; I found (via StackOverflow) which also does a good job describing the differences between the different delegates.&lt;/p&gt;
&lt;p&gt;First up, the &lt;strong&gt;Action&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you see an &lt;em&gt;Action&amp;lt;T&amp;gt;&lt;/em&gt; defined in your code, it just means there’s a method specified which returns void. You put in a parameter of the type &lt;em&gt;T&lt;/em&gt; and some magic happens. An example:&lt;/p&gt;&lt;pre class="brush:csharp"&gt;public void DemoMethod()
{
	Action&lt;string&gt; printMessage = ShowMessage;
	printMessage("Hello World");
}
private void ShowMessage(string message)
{
	Response.Write(message);
}
&lt;/pre&gt;
&lt;p&gt;Now, this example isn’t really meaningful, but this can also be used in more advanced scenario’s of course. It’s also possible to add more input parameters, so you could also use an &lt;em&gt;Action&amp;lt;T1, T2, T3, T4, …&amp;gt;&lt;/em&gt;. I’ve read somewhere it goes up until 16 parameters, which most of the time will be enough.&lt;/p&gt;
&lt;p&gt;As the &lt;em&gt;Action&lt;/em&gt; isn’t really exciting (I haven’t seen any advanced implementations with it), let’s move on to the &lt;strong&gt;Func&lt;/strong&gt;. This one is used a lot in LINQ and lambda expressions. First, let’s cover the basics. A &lt;em&gt;Func&lt;/em&gt; represents a method with one or more input parameters and an output of the type &lt;em&gt;TResult&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The method below is a &lt;em&gt;Func&lt;/em&gt;, just written in the old fashioned way:&lt;/p&gt;&lt;pre class="brush:csharp"&gt;public bool IsThisTextLong(string text)
{
	if(text.Length &amp;gt; 100)
		return true;
	return false;
}
&lt;/pre&gt;
&lt;p&gt;Just as with an &lt;em&gt;Action&lt;/em&gt;, you can put this logic in a variable and use it there. This will look like this:&lt;/p&gt;&lt;pre class="brush:csharp"&gt;Func&lt;string   , bool&gt; longText = IsThisTextLong;
bool isThisALongText = longText("Wow, this is a really short text, is it not?");
&lt;/pre&gt;
&lt;p&gt;The variable &lt;em&gt;isThisALongText&lt;/em&gt; will get the value of &lt;em&gt;false&lt;/em&gt;. This looks kind of cool, but when can you use such a thing? I’ve used it myself to do some UI manipulation in the business logic layer. I modified some values and they needed to be shown in the UI. &lt;br&gt;A fairly bad example (BusinessLogic needs to be in a different layer and nothing is done with the output string), but I think you know what I mean:&lt;/p&gt;&lt;pre class="brush:csharp"&gt;public MainMethod()
{
	BusinessLogic(Write);
}
public string Write(string text)
{
	Console.WriteLine(text);
	return text;
}
public void BusinessLogic(Func&amp;lt;string, string&amp;gt; func)
{
	func("Something for the console.");
}
&lt;/pre&gt;
&lt;p&gt;This could probably be handled in a much better and cleaner way (eventhandlers and callbacks perhaps), but I wanted to use a &lt;em&gt;Func&amp;lt;T, TResult&amp;gt;&lt;/em&gt; as I had never used that before and wanted to see how it worked.&lt;/p&gt;
&lt;p&gt;When using a lambda expression in your code, you are also using &lt;em&gt;Func&amp;lt;T, TResult&amp;gt;&lt;/em&gt; without even knowing it. Look at this Where-clause I placed on a string:&lt;/p&gt;&lt;pre class="brush:csharp"&gt;string hello = "Wow, Unicorns are in the house!";
var filteredHello = hello.Where(c =&amp;gt;
            	{
            		if (c == 'i')
            			return true;
            		return false;
            	});
&lt;/pre&gt;
&lt;p&gt;This is a lambda expression on a string, but if you take a look at the tooltip, you’ll see there’s a &lt;em&gt;Func&amp;lt;char, bool&amp;gt;&lt;/em&gt; defined in it:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/6f29e1b413b2_12F38/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/6f29e1b413b2_12F38/image_thumb.png" width="578" height="64"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As a string is just a collection of characters, you can check every character in the string to see if they match your criteria. If it matches, you need to return a &lt;em&gt;true&lt;/em&gt;, if not &lt;em&gt;false&lt;/em&gt;. In the example above the variable &lt;em&gt;filteredHello&lt;/em&gt; will be a string containing only i-characters, filtered from the hello-string.&lt;/p&gt;
&lt;p&gt;It’s all quite easy to understand when checking out the above examples, but most of the time things aren’t this simple in real life.&lt;/p&gt;
&lt;p&gt;Just when I thought I understood the delegates I saw something which blew my mind, it was the expression tree mentioned earlier:&lt;/p&gt;&lt;pre class="brush:csharp"&gt;Expression&amp;lt;Func&amp;lt;IViewModel, object&amp;gt;&amp;gt;
&lt;/pre&gt;
&lt;p&gt;The developer which showed me this was like “&lt;em&gt;Yeah, you need to create some methods blah blah blah expressions, blah blah blah, check them, blah blah blah&lt;/em&gt;”. While he was talking all I thought was “&lt;em&gt;…….oooookaaaay….let me check &lt;strike&gt;Goo&lt;/strike&gt;Bing for it.&lt;/em&gt;”.&lt;/p&gt;
&lt;p&gt;I knew I had to do something with an &lt;em&gt;IViewModel&lt;/em&gt; and something needed to come out of it, but what was the &lt;em&gt;Expression&lt;/em&gt; for, how is that used and what does it do? As written earlier in this post, I’ve read up on the subject and know a bit on how to use these expression trees.&lt;/p&gt;
&lt;p&gt;As lambda expressions are represented as &lt;em&gt;Func&amp;lt;T, TResult&amp;gt;&lt;/em&gt;’s, it’s easy to see a &lt;em&gt;Func&amp;lt;IViewModel, object&amp;gt;&lt;/em&gt; is a lambda expression. Also, an expression is just some piece of uncompiled code, I didn’t need to do anything special with it and could call the method like this:&lt;/p&gt;&lt;pre class="brush:csharp"&gt;public void Validate&amp;lt;TViewModel&amp;gt;(params Expression&amp;lt;Func&amp;lt;TViewModel, object&amp;gt;&amp;gt;[] optionalParameters)
{
	//Some validation logic is here.
}

public void ViewModelExpressionCalling()
{
	var dummyViewModel = new DummyViewModel();
	Validate&amp;lt;dummyviewmodel&amp;gt;(d =&amp;gt; dummyViewModel.DummyParameter1, d =&amp;gt; dummyViewModel.DummyParameter2);
}
&lt;/pre&gt;
&lt;p&gt;Now, this looks a lot easier as opposed to the very advanced looking parameter. The return type is an object (more specific, a string) and the input is a &lt;em&gt;DummyViewModel&lt;/em&gt; (because of the generic).&lt;/p&gt;
&lt;p&gt;Because you are passing it as an expression, you can use the local variables out-of-scope. That’s because if you use a local variable in an expression tree, it doesn’t get disposed when the scope ends, it keeps in memory until the expression is disposed (really awesome!).&lt;/p&gt;
&lt;p&gt;The expression tree above just returns a property of a local view model, that is, if you compile it. It’s good to know that before you can use an expression tree you need to compile it, remember, it’s uncompiled. After it’s compiled you can call the &lt;em&gt;Invoke&lt;/em&gt; method on it. What’s cool about this is you can pass any &lt;em&gt;DummyViewModel&lt;/em&gt; variable in the &lt;em&gt;Invoke&lt;/em&gt; method and it’ll use this in the &lt;em&gt;Func&lt;/em&gt;. The variable &lt;em&gt;d&lt;/em&gt; would be the variable we’d pass in the Invoke method. &lt;/p&gt;
&lt;p&gt;Another plus-side of using expression trees, I was able to check which property was passed in the above example. I needed to check if a specific property was supplied in the collection, if so, it needed validating. Because of this implementation I was able to check out the Body of the expression tree and use some reflection on it. Using this it was fairly easy to discover which properties were defined and in need of validation.&lt;/p&gt;
&lt;p&gt;I could go on writing on how amazing expression trees are and give examples on how useful they are in real life projects, but I’ll stop for now. Just one more thing for me to write: &lt;strong&gt;Try out expression trees, they are awesome!&lt;/strong&gt;&lt;/p&gt;</description><pubDate>Thu, 12 May 2011 19:07:16 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/expression-trees-amp-func-rsquo-s-differences-and-why-use-it</guid></item><item><title>SharePoint and the Local Activation permission on DCOM objects on 2008R2</title><link>http://www.jan-v.nl:80/sharepoint-and-the-local-activation-permission-on-dcom-objects-on-2008r2</link><description>&lt;p&gt;Another SharePoint farm installation, another problem.&lt;/p&gt; &lt;p&gt;I had to install SharePoint 2007 (don’t ask…..) on a Windows Server 2008R2 development machine. This is quite doable, as long as you install &lt;a href="https://msmvps.com/blogs/laflour/archive/2009/10/11/sharepoint-2007-on-windows-server-2008-r2.aspx"&gt;Service pack 2 of SharePoint&lt;/a&gt;. I figured it would be no problem and just another install, like I’ve done a gazillion times before.&lt;/p&gt; &lt;p&gt;Everything went quite well and because of the SSD disk, the installation didn’t take as long as I was used to. After the full installation was done I checked the Event Log to see if I maybe forgot something. Most of the time there’s something wrong with the Search services or something else which is easily forgotten. This time I saw a familiar message of some COM object not being able to start because of a permission error. A message similar as this one:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;{61738644-F196-11D0-9953-00C04FD919C1}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;to the user &lt;strong&gt;[account and SID]&lt;/strong&gt;. This security permission can be modified using the Component Services administrative tool.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;I’ve seen this a few times before and knew how to fix it.&lt;br&gt;Start up the &lt;em&gt;Component Services&lt;/em&gt; on the machine:&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_thumb.png" width="244" height="38"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Expand the treeview of the &lt;em&gt;Component Services&lt;/em&gt; on &lt;em&gt;My Computer&lt;/em&gt;:&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_4.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_thumb_1.png" width="244" height="61"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Now for the tricky part, search the component which has the same GUID as the error message has. This sounds easy, but the downside is you can’t sort the &lt;em&gt;Application ID&lt;/em&gt; column. Lucky for us you can also do a search in the registry for this GUID and it’ll tell you what the component’s name is.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_6.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_thumb_2.png" width="244" height="111"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;As you can see it’s the &lt;em&gt;IIS WAMREG admin Service&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_8.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_thumb_3.png" width="244" height="57"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Knowing the name makes the search a bit easier as the list is sorted alphabetically.&lt;/p&gt; &lt;p&gt;Right-click on the component and view the properties of it. Navigating to the Security tab gives you some options, but as you can see all of these options are disabled on a Windows 2008R2 machine.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_10.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_thumb_4.png" width="185" height="244"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Apparently the security model has changed a bit on Windows 2008R2 as these were still enabled on Windows 2008. Opening the Component Services as an Administrator makes no difference in what you will see.&lt;/p&gt; &lt;p&gt;Lucky I was able to find a &lt;a href="http://www.wictorwilen.se/Post/Fix-the-SharePoint-DCOM-10016-error-on-Windows-Server-2008-R2.aspx"&gt;solution&lt;/a&gt; for this problem. Quote:&lt;/p&gt; &lt;p&gt;&lt;em&gt;The reason for it being disabled is that this dialog is mapped to a key in the registry which theTrusted Installer is owner of and everyone else only has read permissions. The key used by the IIS WAMREG admin is:&lt;br&gt;HKEY_CLASSES_ROOT\AppID\{61738644-F196-11D0-9953-00C04FD919C1}&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Well, that just means we have to change this registry key. Just navigate to this key again, select the permissions on the key:&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_12.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_thumb_5.png" width="244" height="194"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Click the &lt;em&gt;Advanced&lt;/em&gt; button and navigate to the &lt;em&gt;Owner&lt;/em&gt; tab:&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_14.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_thumb_6.png" width="244" height="89"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Select the &lt;em&gt;Administrators&lt;/em&gt; group and hit the &lt;em&gt;Apply&lt;/em&gt; button.&lt;/p&gt; &lt;p&gt;Now you are able to give the &lt;em&gt;Administrators&lt;/em&gt; group&lt;em&gt; Full Control&lt;/em&gt; on the registry key&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_16.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_thumb_7.png" width="201" height="244"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;After you’ve done that you need to restart the &lt;em&gt;Component Services&lt;/em&gt; and after doing so you’ll be able to change the &lt;em&gt;Launch and Activation Permissions&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_18.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/f38116a253a9_10BE7/image_thumb_8.png" width="187" height="244"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Add the account which was mentioned in the event log entry and assign the &lt;em&gt;Local Launch&lt;/em&gt; and &lt;em&gt;Local Activation&lt;/em&gt; permissions to it.&lt;/p&gt; &lt;p&gt;Now you’re done!&lt;/p&gt;</description><pubDate>Fri, 15 Apr 2011 17:42:45 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/sharepoint-and-the-local-activation-permission-on-dcom-objects-on-2008r2</guid></item><item><title>Saving files from the web</title><link>http://www.jan-v.nl:80/saving-files-from-the-web</link><description>&lt;p&gt;A few weeks ago I had to create an application which would download files from several SharePoint libraries. I had just done a similar thing for a Windows Phone 7 application, so I could reuse most of the code.&lt;/p&gt; &lt;p&gt;After running the application I received an awkward exception message which said: “This stream does not support seek operations”. This exception was triggered by the following code snippet:&lt;/p&gt;&lt;pre class="brush: csharp"&gt;HttpWebRequest request = (HttpWebRequest)WebRequest.Create(filelocationUrl);
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
var stream = response.GetResponseStream();
&lt;/pre&gt;
&lt;p&gt;I though this probably had something to do with it being a stream from a web so it can’t really check the size of a file. Lucky for me I wasn’t the first developer who had stumbled upon this issue. &lt;a href="http://codemaverick.blogspot.com/2007/01/stream-does-not-support-seek-operations.html"&gt;This blog post&lt;/a&gt; describes the same issue.&lt;/p&gt;
&lt;p&gt;The code I was supposed to use is this:&lt;/p&gt;&lt;pre class="brush: csharp"&gt;Stream respStream = myResponse.GetResponseStream();
 
MemoryStream memStream = new MemoryStream();
byte[] buffer = new byte[2048];
 
int bytesRead = 0;
do
{
	bytesRead = respStream.Read(buffer, 0, buffer.Length);
	memStream.Write(buffer, 0, bytesRead);
} while (bytesRead != 0);
respStream.Close();
buffer = memStream.ToArray();
string html = System.Text.Encoding.ASCII.GetString(buffer);
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Using this I’m specifying the size of the chunks which need to be downloaded. This code is something I had used in the past also, but after I saw how easy it was in an asynchronous environment (WP7 / Silverlight) I had hoped it would work in ASP.NET / SharePoint also.&lt;/p&gt;</description><pubDate>Sun, 10 Apr 2011 12:42:25 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/saving-files-from-the-web</guid></item><item><title>New desktop setup</title><link>http://www.jan-v.nl:80/new-desktop-setup</link><description>&lt;p&gt;It’s been about 8 or 9 years since I’ve bought a new desktop system for myself. You can imagine the desktop I had was pretty antique and didn’t run the newest software quite well. Running Windows 7 on the &lt;a href="http://www.extremeoverclocking.com/reviews/processors/Intel_Pentium4_3.2C_1.html"&gt;Pentium 4 @ 3.2GHz&lt;/a&gt; and a &lt;a href="http://ixbtlabs.com/articles2/radeon/r9800xt.html"&gt;ATI Radeon 9800XT&lt;/a&gt; was a pain. Even running Windows XP SP3 was a starting to be a bit too much for the system.&lt;/p&gt; &lt;p&gt;Most of the time I’m buying a system I don’t need to upgrade too much in the future, perhaps some extra memory, but that’s about it. That’s why I needed to configure some high-end system which would be able to load a developer environment without much delay. Also running multiple VM’s is a requirement. Visual Studio requires quite some disk I/O, so an SSD is needed. VM’s can grow quite large, which means a second bulk storage disk has to be bought also. The more cores, the merrier. Lucky for me Intel had just released the &lt;a href="http://www.intel.com/technology/architecture-silicon/2ndgen/index.htm"&gt;Sandy Bridge&lt;/a&gt; architecture processors, which have 4 cores and Hyper Threading, resulting in 8 ‘cores’. An SB system should be compatible with 32GB of memory. At the moment RAM isn’t that expensive, but getting 32GB right from the start might be a bit overkill. I needed to save a bit of money for other parts, so I decided to go for 8GB for now. This means I can run 1 or 2 VM’s at the same time (depending on what’s running on them), which is good enough for now.&lt;br&gt;I’m a big fan of multiple monitors. For a developer, 2 monitors is the &lt;a href="http://www.codinghorror.com/blog/2008/03/does-more-than-one-monitor-improve-productivity.html"&gt;bare minimum&lt;/a&gt;. At work I always try to plug my laptop to a second (big) screen. Running with just 1 screen I feel crippled. At home I’ve got a single 24” monitor with a resolution of 1920x1200. It’s good, but it’s still 1 screen. AMD has this nice thing called &lt;a href="http://www.amd.com/US/PRODUCTS/TECHNOLOGIES/AMD-EYEFINITY-TECHNOLOGY/Pages/eyefinity.aspx"&gt;Eyefinity&lt;/a&gt;, which let’s you hook up to 6 monitors. For this to work I needed a graphics card which supported this. At the moment I don’t need to hook up 6 screens, but in the future I might just do that. For this to work you need 2 DisplayPort output connectors. Even though AMD says every HD6850 (and up) should/could support this, there’s awfully few who have implemented 2 of these ports. Lucky for me &lt;a href="http://www.sapphiretech.com/presentation/product/?leg=&amp;amp;psn=000101&amp;amp;pid=973"&gt;Sapphire&lt;/a&gt; has made a card which has 2 mini DP ports.&lt;/p&gt; &lt;p&gt;For all of these reasons I’ve chosen the following setup:&lt;/p&gt; &lt;p&gt;- &lt;a href="http://ark.intel.com/Product.aspx?id=52213"&gt;Intel Core i7 2600&lt;/a&gt;&lt;br&gt;Reason: The non-K version can’t be OC’ed, but has some extra virtualization features. Maybe usefull when running VM’s.&lt;br&gt;- &lt;a href="http://www.asus.com/product.aspx?P_ID=G1ixnvUxN70FJLbR"&gt;ASUS P8H67&lt;/a&gt;&lt;br&gt;Reason: I actually wanted the P8P67 (4x 6Gbps SATA), but that one costs a lot more, so this one will suffice&lt;br&gt;- &lt;a href="http://www.corsair.com/solid-state-drives/force-series/cssd-f120gb2-brkt.html"&gt;Corsair F120 SSD&lt;/a&gt;&lt;br&gt;Reason: 120GB as a boot disk is large enough for me (now), also this disk is still produced with 34nm memory which doesn’t suffer the performance loss to the 25nm disks.&lt;br&gt;- &lt;a href="http://www.samsung.com/global/business/hdd/productmodel.do?group=&amp;amp;type=94&amp;amp;subtype=98&amp;amp;model_cd=560&amp;amp;ppmi=1219"&gt;Samsung Spinpoint F3 1TB&lt;/a&gt;&lt;br&gt;Reason: Well, it’s a good disk and 1TB is good enough for a local disk as I still got a server with 8TB of storage&lt;br&gt;- &lt;a href="http://www.geil.com.tw/products/show/id/202"&gt;GeIL BlackDragon 8GB kit&lt;/a&gt;&lt;br&gt;Reason: Cheapest memory I could find in the webshop&lt;br&gt;- &lt;a href="http://www.sapphiretech.com/presentation/product/?leg=&amp;amp;psn=000101&amp;amp;pid=973"&gt;Sapphire TOXIC HD 6850&lt;/a&gt;&lt;br&gt;Reason: The two mini-DP connectors for Eyefinity setup&lt;br&gt;- &lt;a href="http://www.coolermaster.com/product.php?product_id=6658"&gt;CoolerMaster Silent Pro Gold 700W&lt;/a&gt;&lt;br&gt;Reason: Has the gold label, so 90% efficient. Also the cheapest I could find with a gold label&lt;br&gt;- &lt;a href="http://www.antec.com/demo/ThreeHundred/"&gt;Antec Three Hundred&lt;/a&gt;&lt;br&gt;Reason: Antec has some very good cases. Every desktop I assembly will get an Antec case. They are a bit more expensive, but the quality is good.&lt;/p&gt; &lt;p&gt;After having had some problems with the hardware, I now run the full setup and it’s great! Boot time is under 15 seconds. VS2010 with ReSharper is faster as ever, installing and running software is a joy.&lt;/p&gt; &lt;p&gt;Only thing missing is the Eyefinity setup. At the moment I still got 1 monitor, an &lt;a href="http://hardforum.com/showthread.php?t=1096025"&gt;Acer AL2423W&lt;/a&gt;. It’s a good enough screen, considering it’s age, but it’s 1 screen. I was hoping for a nice deal with several used monitors, but there aren’t many to my liking. For this reason I’ve bought 2 new &lt;a href="http://www.giga-zone.com/tw/products/features.php?prodNo=50050122"&gt;Gigazone Envision G2461w&lt;/a&gt; monitors. They are Edge-lit LED screens, which probably means the colors are a lot better compared to my old screen and use a lot less power. Hope they’ll arrive soon.&lt;br&gt;&lt;/p&gt; &lt;p&gt;The only thing I need now is a VESA desk mount and attach all 3 monitors to them and pivot them, but that’s something for the future.&lt;/p&gt;</description><pubDate>Mon, 28 Mar 2011 18:19:56 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/new-desktop-setup</guid></item><item><title>Decrypting encrypted data in config file</title><link>http://www.jan-v.nl:80/decrypting-encrypted-data-in-config-file</link><description>&lt;p&gt;This is something which has been available in the .NET Framework since, well, forever. I’m talking about encrypting data in the config file of your (web)application. Every time I studied for the Microsoft developer exams I was reminded on this feature and thought “Hey, I really should use this in the next project”. Up until now I’ve never used this feature though.&lt;/p&gt; &lt;p&gt;The project I’m currently working on has some setup which encrypts the the config file when it’s deployed. A great feature, but this means I can’t read and edit the config file anymore. Manually editing the file shouldn’t be done anyway, but reading it would be nice though.&lt;/p&gt; &lt;p&gt;I knew this data could be decrypted also, but not how to do it exactly. Lucky for me this is a really old feature and there are dozens of people who have written something about it. &lt;a href="http://msdn.microsoft.com/en-us/library/ff647398.aspx"&gt;This article on MSDN&lt;/a&gt; helped me out the most. I also read the feature had became available in the .NET Framework 2.0, apparently this wasn´t available in version 1.1.&lt;/p&gt; &lt;p&gt;As with most encrypting algorithms you need some kind of seed to create a stronger (and safer) encryption. If I’m not mistaken this method used the machine key of the computer it’s encrypted on. That’s not all too bad, but this means you can’t decrypt the encrypted data on a system with a different machine key. &lt;br&gt;The linked article says the machine key is stored in &lt;em&gt;%windir%\system32\Microsoft\Protect\S-1-5-18&lt;/em&gt;, which probably is right, but I haven’t checked that out as I can’t log in on the server(s).&lt;/p&gt; &lt;p&gt;If you have encrypted the files, or are able to retrieve the machine key, it’s possible to decrypt the data using the aspnet_regiis tool (Visual Studio Prompt).&lt;br&gt;If you’d want to decrypt the appSettings block of a website in a virtual directory called &lt;em&gt;virtualDir&lt;/em&gt;, the following line should suffice:&lt;br&gt;&lt;font face="Courier New"&gt;aspnet_regiis –pd “appSettings” –app “/virtualDir”&lt;/font&gt;&lt;/p&gt; &lt;p&gt;I tried this myself and it didn’t work. The following error was thrown:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;Failed to decrypt using provider 'DataProtectionConfigurationProvider'. Error message from the provider: Key not valid for use in specified state. (Exception from HRESULT: 0x8009000B) (C:\VRIESJAN\ApplicationDir\Source\CustomerApp\CustomerApp.Presentation\web.config line 104)&lt;/font&gt;&lt;/p&gt; &lt;p&gt; &lt;p&gt;This probably had something to do with me not having the correct machine key on my system. Lucky for me the sysadmin could discover the values through IIS Manager so there wasn’t a real loss, but this is exactly the reason why I haven’t implemented such a thing in a solution of mine. It makes reading production data a lot harder.&lt;/p&gt;</description><pubDate>Mon, 28 Mar 2011 15:32:09 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/decrypting-encrypted-data-in-config-file</guid></item><item><title>Nieuw espresso apparaat</title><link>http://www.jan-v.nl:80/nieuw-espresso-apparaat</link><description>&lt;p&gt;Al een aantal jaar drinken we thuis koffie uit de &lt;a href="http://en.wikipedia.org/wiki/Senseo"&gt;Philips Senseo&lt;/a&gt; die we hebben gekregen. Een ideaal apparaat om en snel kopje koffie mee te zetten. Toch vonden we de smaak al sinds de eerste keer niet echt super (understatement).&lt;/p&gt; &lt;p&gt;Bij een klant waar ik nu zit hebben ze sinds kort een redelijk luxe espresso appraat staan en de koffie die daar uit komt is enorm lekker. Nu wilde ik dit thuis ook wel graag hebben, dus was ik op zoek gegaan naar die apparaten. Behalve dat ze behoorlijk prijzig zijn, is er ook nog heel veel keus.&lt;/p&gt; &lt;p&gt;Uiteindelijk heb ik maar een 2e hands gekocht, zodat het toch nog betaalbaar is voor een software ontwikkelaar. Het is de &lt;a href="http://www.saeco.be/nl/products/volautomatische-huishoudelijke-toestellen/1/automatic/0/talea-touch-plus/5/talea-touch-plus.html"&gt;Saeco Talea Touch&lt;/a&gt; geworden, inclusief een melk eiland.&lt;/p&gt; &lt;p&gt;&lt;img src="http://www.cerinicoffee.com/images/products/saeco/Talea_Touch.jpg"&gt;&lt;/p&gt; &lt;p&gt;Een mooi apparaat en de koffie is ook prima te drinken. Ben er helemaal blij mee. &lt;/p&gt;</description><pubDate>Sun, 20 Mar 2011 11:57:46 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/nieuw-espresso-apparaat</guid></item><item><title>Windows Home Server en Server Storage Manager Service</title><link>http://www.jan-v.nl:80/windows-home-server-en-server-storage-manager-service</link><description>&lt;p&gt;Enkele maanden terug heb ik WHS afgeschaft en vervangen voor een eenvoudige fileserver. Nu wilde ik toch weer wat meer redundantie en vond ik de Drive Extender van WHS toch wel handig (van meerdere schijven 1 grote maken), dus heb ik het toch maar weer ge&amp;iuml;nstalleerd op een virtuele machine. Uiteraard ook enkele extra schrijven er aan gehangen, waardoor ik nu ongeveer 6TB aan data opslag heb. Klinkt als veel, maar als je enkele VM&amp;rsquo;s draait, backups maakt en alle DVD&amp;rsquo;s die je hebt er opslaat ben je er toch snel doorheen.&lt;/p&gt;
&lt;p&gt;Na een reboot van de WHS kreeg ik continu een melding dat een of meerdere services niet geladen konden worden. Meestal een voorteken dat er iets niet aan de haak is. Even later zag ik ook de melding voorbij komen dat de Windows Home Server Storage Manager Service niet opgestart kon worden. Dit klink al redelijk serieus. Ook bij het rebooten kreeg ik continu foutmeldingen dat een bestand in de map DE niet kon worden weggeschreven. Ik ben er maar vanuit gegaan dat DE voor Drive Extender staat en een Storage Manager Service ook belangrijk is voor een veilige opslag van de data.&lt;/p&gt;
&lt;p&gt;Aangezien al m&amp;rsquo;n foto&amp;rsquo;s en documenten ook op de WHS staan moet dat wel een beetje veilig zijn. Na wat zoeken kwam ik al vrij snel op een KB artikel (&lt;a href="http://support.microsoft.com/kb/940349"&gt;940349&lt;/a&gt;). Dit gaat dan wel over Windows 2003 en VSS, maar dit zou dus een oplossing kunnen bieden.&lt;/p&gt;
&lt;p&gt;Na installatie even 2 reboots gedaan (voor de zekerheid) en sindsdien draait de server weer stabiel.&lt;/p&gt;</description><pubDate>Fri, 11 Feb 2011 20:24:17 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/windows-home-server-en-server-storage-manager-service</guid></item><item><title>Orchard installatie en configuratie</title><link>http://www.jan-v.nl:80/orchard-installatie-en-configuratie</link><description>&lt;p&gt;Zoals is te &lt;a href="http://www.jan-v.nl/migratie-naar-orchard"&gt;lezen&lt;/a&gt; ben ik onlangs overgestapt naar &lt;a href="http://www.orchardproject.net/"&gt;Orchard&lt;/a&gt; als blogging platform. Qua interface en beleving bevalt het me tot nu toe prima. Het is een redelijk snel platform en laat zich eenvoudig installeren, mede dankzij het &lt;a href="http://www.asp.net/webmatrix"&gt;WebMatrix&lt;/a&gt; platform van Microsoft.&lt;/p&gt; &lt;p&gt;Hoewel de installatie redelijk goed ging, waren er toch enkele haken en ogen die ik tegen kwam. Om deze reden beschrijf ik de genomen stappen even stuk voor stuk.&lt;/p&gt; &lt;p&gt;Ten eerste moet WeMatrix worden opgestart. Op het startscherm kan dan worden gekozen voor de optie Site From Web Gallery, we willen immers een Orchard site maken en dat is een type site dat door WebMatrix wordt ondersteund. Uiteraard kan er ook voor een Joomla, WordPress, Umbraco of ander systeem worden gekozen.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_thumb.png" width="244" height="180"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Zodra het vervolgscherm is geladen zoeken we naar het Orchard template. &lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_thumb_1.png" width="244" height="180"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Na het invullen van de site naam kan er op &lt;em&gt;Next&lt;/em&gt; worden gedrukt. Door in het vervolgscherm op &lt;em&gt;I Accept&lt;/em&gt; te drukken zal het template worden gedownload en de site worden aangemaakt. Dit wordt bevestigd in nog een vervolgscherm.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_6.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_thumb_2.png" width="244" height="180"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Uiteindelijk zul je in een WebMatrix scherm verschijnen waar eigenlijk alles in kan worden beheerd. De interface biedt (nog) niet enorm veel opties, maar op zich voldoende om mee uit de voeten te kunnen.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_8.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_thumb_3.png" width="244" height="180"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Wanneer je op de link klikt van de aangemaakte site zul je in een soort startscherm verschijnen waar de initiele configuratie plaats kan vinden. &lt;/p&gt; &lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_10.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_thumb_4.png" width="244" height="234"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Behalve de site een naam te geven en het administrator account aan te maken, dient hier ook het type SQL database te worden gekozen. Hier kan standaard een SQL Server Compact of een ‘echte’ SQL Server worden gekozen.&lt;/p&gt; &lt;p&gt;Omdat SQL Server Compact nieuw en hip is wilde ik m’n weblog eerst daarmee draaien. Het biedt ook gelijk als voordeel dat je dan bij iedereen de site kunt hosten, omdat ze geen MS SQL (Express) ondersteuning hoeven te installeren.&lt;br&gt;Tijdens de installatie en configuratie van het weblog werkte alles prima en snel. Echter toen ik de site bij m’n hoster had geplaatst begonnen de problemen. Er kwamen continu &lt;a href="http://en.wikipedia.org/wiki/Screen_of_death"&gt;Yellow Screens of Death&lt;/a&gt; tevoorschijn welke te maken hadden met het feit dat het bestand van SQL Server Compact reeds in gebruik was, waardoor er niet nogmaals een connectie naar kon worden gemaakt. Dat is natuurlijk niet de bedoeling bij een database, zeker niet een van een website. Dit heeft waarschijnlijk meer te maken met de opzet van de servers bij de hosting partij en niet iets met SQL Server Compact, maar was voor mij toch de reden waarom ik ben overgestapt naar MS SQL Express. Ik zou dan ook aan iedereen aan willen raden om een gewone SQL Server te gebruiken en niet de compact versie, tenzij daar een goede reden voor is.&lt;/p&gt; &lt;p&gt;Mocht je later toch besluiten om over te stappen naar een andere database, dan kan dit ook redelijk eenvoudig. In de map &lt;em&gt;App_Data\Sites\Default&lt;/em&gt; van je website is een bestand te vinden genaamd &lt;em&gt;Settings.txt&lt;/em&gt;. Wanneer je gebruik maakt van SQL Compact, dan staat hier iets in als:&lt;/p&gt; &lt;p&gt;&lt;pre class="brush: plain"&gt;Name: Default
DataProvider: SqlCe
DataConnectionString: null
DataPrefix: null
RequestUrlHost: null
RequestUrlPrefix: null
State: Running
EncryptionAlgorithm: AES
EncryptionKey: 22222222222222222222222222222222222222222222222222222222222222222
HashAlgorithm: ACSHA256
HashKey:22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
&lt;/pre&gt;
&lt;p&gt;Wanneer je overstapt naar een SQL Server, dan kan de tekst &lt;em&gt;SqlCe&lt;/em&gt; worden vervangen met &lt;em&gt;SqlServer&lt;/em&gt; en moet de &lt;em&gt;null&lt;/em&gt; bij &lt;em&gt;DataConnectionString&lt;/em&gt; worden vervangen met een valide connectiestring naar de Orchard database.&lt;/p&gt;
&lt;p&gt;Wat wel vervelend is bij een migratie van SQL Server Compact naar SQL Server (Express) is dat zowel Management Studio als Visual Studio 2010 momenteel nog geen ondersteuning bieden voor de Compact variant. Dit wordt hopelijk met Servicepack 1 opgelost. Gelukkig zijn er wel anderen die hier een oplossing voor hebben gemaakt. Zo is er tegenwoordig de &lt;a href="http://sqlcetoolbox.codeplex.com/"&gt;SQL Server Compact Toolbox&lt;/a&gt; te vinden op CodePlex. Deze heb ik dan ook gebruikt om scripts te genereren tussen een gevulde Orchard en een lege database. Nadat ik die synchronisatie had uitgevoerd heb ik de connectiestring in de &lt;em&gt;Settings.txt&lt;/em&gt; aangepast.&lt;/p&gt;
&lt;p&gt;Wanneer alles echter gelijk goed werkt, dan heb je al een website die redelijk netjes oogt.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_12.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_thumb_5.png" width="244" height="156"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In de Dashboard kan redelijk veel worden aangepast. Tijdens het gebruik mis ik toch wel het een en ander en vind het zelf ook enorm lastig dat er meerdere malen dezelfde term in het menu wordt gebruikt (onder een ander kopje), maar dat zal er alles mee te maken hebben dat het een relatief nieuw product is en nog volop in ontwikkeling.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_14.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_thumb_6.png" width="85" height="244"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Zodra de website eenmaal klaar is om te worden gepubliceerd, dan kan er via de WebMatrix manager (zo noem ik het maar) voor worden gekozen om dit te doen.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_16.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_thumb_7.png" width="244" height="111"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Er kunnen dan 2 methoden worden gekozen, Web Deploy en FTP, vergelijkbaar als in Visual Studio. De deployment via Visual Studio is echter wel een stuk geavanceerder. Bij WebMatrix betekend een publish gewoon het copy-pasten van de lokale map naar de remote locatie. Zelf had ik toch verwacht dat er nog enige encryptie zou plaatsvinden in de web.config, de pdb-bestanden zouden worden uitgeruimd, de web.config op debug=false worden gezet en allerlei van dit soort kleine acties. Dit is jammergenoeg niet het geval.&lt;/p&gt;
&lt;p&gt;Omdat ik eerst had gekozen om gebruik te maken van een SQL Compact database, moest ik de schrijfrechten in de App_Data map binnen de website aan zetten. Blijkbaar staat dit standaard uit bij m’n hoster. Nadat ik dat had gedaan kon ik in ieder geval lezen en schrijven in de database, ware het niet dat ik eerst nog enkele andere problemen op moest lossen.&lt;/p&gt;
&lt;p&gt;Het eerste scherm dat ik zag toen ik de website had gedeployed was dat er een dll niet kon worden gevonden. Dit waren er niet 1 of 2, maar een stuk of 8. Blijkbaar konden die lokaal wel ergens worden gevonden, maar niet bij de hoster.&lt;br&gt;Uiteindelijk heb ik de broncode van &lt;a href="http://orchard.codeplex.com/"&gt;Orchard&lt;/a&gt; maar van CodePlex gedownload en de volledige &lt;em&gt;bin&lt;/em&gt; en &lt;em&gt;App_Data&lt;/em&gt; map gekopieerd naar de remote locatie. Daarna had ik in ieder geval geen problemen meer met het vinden van de juiste dll’s. &lt;/p&gt;
&lt;p&gt;Het volgende probleem kwam toen naar voren:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_18.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://jan-v.nl/Media/Default/Windows-Live-Writer/a26f8142998c_111D4/image_thumb_8.png" width="244" height="117"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Een &lt;em&gt;Access is Denied&lt;/em&gt; melding bij het bezoeken van de website. Dit blijkt voort te komen uit het feit dat Orchard gebruik maakt van &lt;em&gt;dynamic coupling&lt;/em&gt; van assemblies die binnen de App_Data map staan. De reden die ik hiervoor had gevonden is dat er dan gebruik gemaakt kan worden van verschillende versies van een assembly binnen dezelfde site. Wanneer je de dll’s in de bin-map stopt wordt er altijd met die versie gewerkt.&lt;br&gt;De reden voor de &lt;em&gt;Access is Denied&lt;/em&gt; melding zou zijn dat er geen voldoende (schrijf)rechten zouden zijn binnen de &lt;em&gt;App_Data&lt;/em&gt; map. Dit vond ik nogal raar, aangezien ik dat al aan had gezet voor de database. Aangezien het ook zo zou kunnen zijn dat er problemen waren bij de hoster heb ik een ‘tijdelijke’ oplossing gevonden.&lt;/p&gt;
&lt;p&gt;Alle bestanden die in de map &lt;em&gt;App_Data\Dependencies&lt;/em&gt; staan heb ik gekopieerd naar de bin-map. Daarna werkte de site weer prima en nog redelijk snel ook.&lt;/p&gt;
&lt;p&gt;Dit waren de bevindingen tot nu toe. Hopelijk heeft iemand er wat aan.&lt;/p&gt;</description><pubDate>Fri, 11 Feb 2011 19:21:38 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/orchard-installatie-en-configuratie</guid></item><item><title>SharePoint 2007 development in Visual Studio 2010</title><link>http://www.jan-v.nl:80/sharepoint-2007-development-in-visual-studio-2010</link><description>&lt;p&gt;Aan mij was de taak om een applicatie te schrijven welke informatie van SharePoint (Wiki sites) website kon wegschrijven naar HTML bestanden met een bepaalde opmaak. &lt;/p&gt; &lt;p&gt;Niks aan de hand, ware het niet dat ik op m’n Windows 2008 VM zowel MOSS 2007 als Visual Studio 2010 had geïnstalleerd. Bij het toevoegen van de benodigde references kwam ik er ineens achter dat ik de SharePoint 2007 DLL’s niet kon vinden in de lijst. Het is ook een bekend ‘probleem’, aangezien het ook op &lt;a href="http://connect.microsoft.com/VisualStudio/feedback/details/512137/not-found-microsoft-sharepoint-dll-sharepoint-2007-on-net-tab-of-add-references"&gt;Connect&lt;/a&gt; staat geregistreerd als issue. Er staat ook dat het probleem is geëscaleerd naar het betreffende team, maar dat was al op 20 november 2009. Jammer dat dergelijke calls dan niet verder worden bijgewerkt, want blijkbaar is het antwoord gewoon ‘zoek het lekker zelf uit’.&lt;/p&gt; &lt;p&gt;Gelukkig kan ik dat ook prima zelf uitzoeken. &lt;br&gt;De dll’s staan namelijk gewoon in de map &lt;em&gt;C:\Program Files\Common Files\Microsoft Shared\Web Server Extenstions\12\ISAPI&lt;/em&gt;. Door de Browse knop te gebruiken bij het Add Reference scherm kan dan gewoon, net als vroeger, de betreffende dll worden geselecteerd, bijvoorbeeld Microsoft.SharePoint.dll.&lt;/p&gt; &lt;p&gt;Het werkt dan allemaal prima, maar is wel jammer dat dit niet standaard wordt ondersteund. Het is al erg genoeg dat we met Visual Studio 2008 ook al niet met SharePoint 2010 kunnen werken.&lt;/p&gt;</description><pubDate>Fri, 11 Feb 2011 16:00:16 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/sharepoint-2007-development-in-visual-studio-2010</guid></item><item><title>Navigatie op binnen een WP7 applicatie</title><link>http://www.jan-v.nl:80/navigatie-op-binnen-een-wp7-applicatie</link><description>&lt;p&gt;Tijdens het ontwikkelen van een van m&amp;rsquo;n WP7 applicaties liep ik er tegenaan dat er naar een andere pagina moest worden genavigeerd. Je kunt, naar mijn mening, namelijk niet alles binnen een Pivot- of Panorama-control plaatsen. Het kan ook zijn dat dit nog een ouderwetse gedachtengang is, maar daar ben ik nog niet achter.&lt;/p&gt;
&lt;p&gt;Het probleem was echter dat navigatie niet echt (goed) is ge&amp;iuml;mplementeerd binnen WP7 of Silverlight. Omdat dit toch moest binnen mijn applicatie heb ik hier een oplossing voor moeten verzinnen. Gelukkig was ik niet de enige met dit probleem en kwam ik op Stack Overflow (link ben ik kwijt) al snel op een antwoord waar ik mee kon werken.&lt;/p&gt;
&lt;p&gt;Het idee is dat je je views laat afleiden van een BaseView. In deze BaseView definieer je dan de navigatie methoden, zodat alle views dit kunnen doen. De navigatie wordt gedaan aan de hand van een navigatie object en het registreren op de wijzigingen binnen dit object. Door gebruik te maken van de Message bus die je gratis bij MVVM Light krijgt is dit eenvoudig te realiseren.&lt;/p&gt;
&lt;p&gt;Eerst dient er een object te worden gemaakt waar de pagina en querystring in kan worden gestopt. Dit is bij mij een nieuwe klasse welke er als volgt uit ziet:&lt;/p&gt;
&lt;pre class="brush: csharp"&gt;public class NavigationMessage : NotificationMessage
{
	public string PageName
	{
		get { return base.Notification; }
	}

	public Dictionary QueryStringParams { get; private set; }

	public NavigationMessage(string pageName) : base(pageName) { }

	public NavigationMessage(string pageName, Dictionary queryStringParams)
		: this(pageName)
	{
		QueryStringParams = queryStringParams;
	}
}
&lt;/pre&gt;
&lt;p&gt;Zodra deze is gemaakt kan er een BaseView worden aangemaakt waarin deze zichzelf registreert op wijzigingen van objecten van de vooraf gedefinieerde klasse. Bij een wijziging kan er dan een methode worden aangeroepen welke de navigatie tot stand brengt. Dit zal er ongeveer als volgt uit komen te zien:&lt;/p&gt;
&lt;pre class="brush: csharp"&gt;public class BaseView : PhoneApplicationPage
{
	public BaseView()
	{
		Messenger.Default.Register(this, NavigateToPage);
	}

	public void NavigateToPage(NavigationMessage message)
	{
		string queryStringParams = message.QueryStringParams == null ? "" : GetQueryString(message);

		string uri = string.Format("/{0}.xaml{1}", message.PageName, queryStringParams);
		NavigationService.Navigate(new Uri(uri, UriKind.Relative));
	}

	private string GetQueryString(NavigationMessage message)
	{
		string queryString = string.Empty;
		bool first = true;
		foreach (var s in message.QueryStringParams)
		{
			if (first)
			{
				queryString += "?";
				first = false;
			}
			queryString += string.Format("{0}={1}", s.Key, s.Value);
		}
		return queryString;
	}
}
&lt;/pre&gt;
&lt;p&gt;Wat wel belangrijk is om te weten is dat de XAML en de code-behind hiervan beide moeten afleiden van de BaseView. Dit was waar ik de fout in ging, aangezien ik niet wist hoe je in XAML zoiets kunt bewerkstelligen. Gelukkig is dit heel eenvoudig. De code-behind gaat zoals je dat normaal doet:&lt;/p&gt;
&lt;pre class="brush: csharp"&gt;public partial class MainPage : BaseView&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;In de XAML is dit iets uitgebreider. Daar moet er namelijk een namespace worden toegevoegd en het root element moet worden gewijzigd in de juiste BaseView klasse.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Wanneer je dit niet doet krijg je de melding dat een partial klasse niet van verschillende base klassen kan overerven. Logisch!&lt;/p&gt;
&lt;p&gt;Zodra alles is opgezet en geregistreerd kun je, dankzij de Messenger bus, met een regel een andere pagina aanroepen:&lt;/p&gt;
&lt;pre class="brush: csharp"&gt;Messenger.Default.Send(new NavigationMessage("Results"));
&lt;/pre&gt;
&lt;p&gt;Op zich is het allemaal heel eenvoudig, maar je moet er wel even aan denken. Wat ik wel een eye-opener vond is dat Silverlight dus blijkbaar ook werkt met Uri&amp;rsquo;s en querystrings, net zoals een web applicatie. Dit is waarschijnlijk triviale kennis voor een Silverlight developer, waardoor wel weer blijkt dat ik nog een beginner ben op dit vlak.&lt;/p&gt;</description><pubDate>Fri, 11 Feb 2011 14:29:15 GMT</pubDate><guid isPermaLink="true">http://www.jan-v.nl:80/navigatie-op-binnen-een-wp7-applicatie</guid></item></channel></rss>
