Wednesday, November 30, 2011

Unity IsRegistered throws exceptions when registering Open Generic types.

For a long time, I had a very annoying error message when I called the IsRegistered method on the Unity container.

Error Message:
System.ArgumentException: GenericArguments[0], 'T', on 'Infrastructure.Data.NHibernateRepository`1[T]' violates the constraint of t
ype 'T'. ---> System.TypeLoadException: GenericArguments[0], 'T', on 'Infrastructure.Data.NHibernateRepository`1[T]' violates the c
onstraint of type parameter 'T'.

Last week I finally found the root cause of this issue. Let’s have a look at my code first:

public interface IRepository<T> where T:Entity


public class NHibernateRepository<T> : IRepository<T> where T : Entity, new()


So what’s causing the issue? Have a look at the generic constraints. You see that my interface is less restrictive than my implementation and that is what makes Unity chokes...

One workaround(which is still far from ideal) is that you can apply the same type constraints to the interface. Another (better) workaround is posted by Walter Almeida. Either way I hope it will be solved in the next release of Unity…

Tuesday, November 29, 2011

Creating test data using ElasticObject

For a recent project I had to write a lot of data-oriented tests. This required me to populate the domain model with lot’s of test data. Having to write a lot of new statements and property setters, I was looking for a cleaner alternative when I stumbled over this library: ElasticObject - An expandable dynamic object for .NET 4.0.

A dynamic ElasticObject implementation using .NET 4.0 dynamic features, for fluent access of data types like XML - Access XML <entry name="user"/> via fluent dynamic wrappers, like var; - You can also use it like ExpandoObject, with multi level property support
To start with, here are few scenarios you can use ElasticObject

  • An easier, fluid way to work with data formats – like XML and JSON. Presently, we’ve some support for XML.
  • Cleaner code though it is duck typed
  • A hierarchical way to maintain loosely typed data.

I used it to create a whole object hierarchy in a very simple way, like this:


Read More:

Monday, November 28, 2011

Visual Studio cannot start debugging because the debug target is missing

Sometimes you lose a lot of time finding the most idiot problems. Last week I had to do a code review so I downloaded the solution from Team Foundation Service and opened it. First I wanted to try to run the application but it failed with the following error message:

“Visual Studio cannot start debugging because the debug target 'D:\dev\ApplicationToReview\bin\Debug\ApplicationToReview.exe' is missing. Please build the project and retry, or set the OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly.”

Ok. So I rebuild the project a few times, had a look at the output folders only to see that the required assembly was definitely there. In the end I noticed that although the current project was set as the start up project but it was not configured to run in the Configuration Manager.

After checking the project under configuration manager everything worked fine.

Friday, November 25, 2011

Adobe Flex/Flash versus Microsoft Silverlight. And the winner is… HTML 5!

The last weeks there were some rumors that Silverlight 5 might just be the last version of the technology. Combine this with the fact that Adobe is  killing any further development of it's flash mobile plugin and you can only conclude that both Microsoft and Adobe think that the future of web development does not lie in a proprietary plugin technology, but in HTML5.

Flash has long been the standard bearer of richer experiences inside browsers. I’ve always had the feeling that Microsoft only created Silverlight to get a piece of this cake. (Maybe someone still remembers that Silverlight version 1 was based on JavaScript?!). Although I have to admit that Silverlight showed some real potential and allowed to create stunning user experiences , far better than I had ever even seen imagined with Flash. And now that Adobe is refocusing it’s effort to HTML 5, Microsoft no longer cares and I’m guessing that Silverlight 6 will never see the light.

But what about the Windows Phone than you could ask?

It’s all based on Silverlight so it will not disappear right? Even there I think we’ll see Silverlight replaced by a new WinRT alternative(just by guessing that Windows Phone 8 will have the same version number as Windows 8 Smile).

Should you care as a WPF/Silverlight developer?

No. One XAML framework will be replaced by another. And as long as the tooling for HTML 5 doesn’t keep up, we’ll remain far more productive in XAML development (without even talking about the technical expertise required to build an enterprise level business application, and no that’s not the same as a web application enhanced with some JavaScript here and there…). However in a future were HTML5 will become more and more important, it’s not wise to place all your eggs in one basket.

Should you care as a Mobile developer?

Although a native experience remains the ideal, I don’t see a world where every application will be written for each and every mobile platform. So I think the future of mobile is HTML5 and mobile web applications. For now, there are a few restrictions, but if you know about the device APIs you should realize those few limitations are going away in the near future.

So the safest guess today as a developer is to spend time learning HTML5 and JavaScript and you are ready to build rich user experiences for Web, Windows AND Mobile.

I know how I’ll spend my time the upcoming months…

Thursday, November 24, 2011

Mobile website vs Mobile application

With Mobile being the new hype everyone wants to build web application. But should I build a native Mobile application or is it better to build a mobile version of my web application?

HeadScape released this nice info graphic helping you in answering this question:

Wednesday, November 23, 2011

Web.config Transformation Tester

When you deploy a Web site, you often want some settings in the deployed application's Web.config file to be different from the development Web.config file. For example, you might want to disable debug options and change connection strings so that they point to different databases. Starting from Visual Studio 2010, ASP.NET provides tools that automate the process of changing (transforming) Web.config files when they are deployed. For each environment that you want to deploy to, you create a transform file that specifies only the differences between the original Web.config file and the deployed Web.config file for that environment.

A transform file is an XML file that specifies how the Web.config file should be changed when it is deployed. Transformation actions are specified by using XML attributes that are defined in the XML-Document-Transform namespace, which is mapped to the xdt prefix. The XML-Document-Transform namespace defines two attributes: Locator and Transform. The Locator attribute specifies the Web.config element or set of elements that you want to change in some way. The Transform attribute specifies what you want to do to the elements that the Locator attribute finds.

More information about creating a transformation file here and about the syntax here.

Last week I discovered the Web.config Transformation Tester, a simple web tool that allows you to test your transformations in a very easy way. It allows you to paste your web.config into the top text box and your transform into the second one. Click the 'Transform' button to see the result of the transformation.


Tuesday, November 22, 2011

Windows Azure Updates: SDK 1.6 and Training Kit November 2011 update released

And there is Microsoft again with 3 new updates for Windows Azure—a new version of the Windows Azure SDK, a new Windows Azure HPC Scheduler SDK, and an updated Windows Azure Platform Training Kit. 



  • Windows Azure SDK (November 2011)—Multiple updates to the Windows Azure Tools for Visual Studio 2010 that simplify development, deployment, and management on Windows Azure. The full Windows Azure SDK can be downloaded via the Web Platform installer here.
  • Windows Azure HPC Scheduler SDK— Works in conjunction with the Windows Azure SDK and includes modules and features to author high performance computing (HPC) applications that use large amounts of compute resources in parallel to complete work.  The SDK is available here for download.
  • Windows Azure Platform Training Kit—Includes hands-on labs, demos, and presentations to help you learn how to build applications that use Windows Azure. Compatible with the new Windows Azure SDK and Windows Azure Tools for Visual Studio 2010. The training kit can be downloaded here.

Here are the details:

The Windows Azure SDK for .NET includes the following new features:

  • Windows Azure Tools for Visual Studio 2010
    • Streamlined publishing: This makes connecting your environment to Windows Azure much easier by providing a publish settings file for your account.  This allows you to configure all aspects of deployments, such as Remote Desktop (RDP), without ever leaving Visual Studio.  Simply use the Visual Studio publishing wizard to download the publish settings and import them into Visual Studio.  By default, publish will make use of in-place deployment upgrades for significantly faster application updates.
    • Multiple profiles: Your publish settings, build config, and cloud config choices will be stored in one or more publish profile MSBuild files. This makes it easy for you and your team to quickly change all of your environment settings. 
    • Team Build: The Windows Azure Tools for Visual Studio 2010 now offer MSBuild command-line support to package your application and pass in properties.  Additionally, they can be installed on a lighter-weight build machine without the requirement of Visual Studio being installed.
    • In-Place Updates: Visual Studio now allows you to make improved in-place updates to deployed services in Windows Azure. For more details visit
    • Enhanced Publishing Wizard: Overhaul of publishing experience to sign-in, configure the deployment, and review the summary of changes
    • Automatic Credential Management Configuration: No longer need to manually create or manage a cert
    • Multiple Subscription Deployment Management: Makes it easier to use multiple Windows Azure subscriptions by selecting the subscription you want to use when publishing within Visual Studio.
    • Hosted Service Creation: Create new hosted services within Visual Studio, without having to visit the Windows Azure Portal.
    • Storage Accounts: Create and configure appropriate storage accounts within Visual Studio (no longer need to do this manually)
    • Remote Desktop Workflow: Enable by clicking a checkbox and providing a username/password – no need to create or upload a cert
    • Deployment Configurations: Manage multiple deployment environment configurations
    • Azure Activity Log: More information about the publish and virtual machine initialization status

For more information on Windows Azure Tools for Visual Studio 2010, see What’s New in the Windows Azure Tools.

  • Windows Azure Libraries for .NET 1.6
    • Service Bus & Caching: Service Bus and caching client libraries from the previous Windows Azure AppFabric SDK have now been updated and incorporated into the Windows Azure Libraries for .NET to simplify the development experience.
    • Queues:
      • Support for UpdateMessage method (for updating queue message contents and invisibility timeout)
      • New overload for AddMessage that provides the ability to make a message invisible until a future time
      • The size limit of a message is raised from 8KB to 64KB
      • Get/Set Service Settings for setting the analytics service settings
  • Windows Azure Emulator
    • Performance improvements to compute & storage emulators.

Click here to download the Windows Azure SDK via the Web Platform Installer.

The Windows Azure Training Kit November 2011 includes the following updates:

  • [New demo] Publishing Cloud Applications with Visual Studio
  • [Updated] Labs and Demos to leverage the new Window Azure SDK & Tools 1.6
  • [Updated] SQL Azure Presentations
  • Applied several minor fixes in content

Click here to download the Training Kit via the Web Platform Installer.

Monday, November 21, 2011

.NET Framework 4.5–New features overview

You want to get an idea of all the new features in .NET Framework 4.5? Have a look at this nice poster created by Jouni Heikniemi.

Friday, November 18, 2011

Showing the ‘Runas’ option in the context menu

Just a simple reminder for something that I always seem to forget:

In Windows you can run the ‘Runas’ command/ This allows you to run a program as if it was running from a different user account on your computer while you are still logged on to your user account.

  • Press and hold the Shift key and right click on the program's shortcut or EXE file, then click on Run as different user. (See screenshot below)


  • Type in the user name and password of the user account that you want to run this program as. (see screenshot below)
    NOTE: If the user account is on a domain, then you would use UserName@Domain or Domain\UserName for the user name instead.

Thursday, November 17, 2011

TFS 2010: TF203028 and TF203071 branching errors

TF203028: You cannot create a branch at {path} because a branch already exists at {sub path}.

You see this message when a branch root exists at a sub path of the folder you are trying to mark as a branch root.

In the case a sub-folder was incorrectly marked as a branch root, you can recover easily from this by converting the branch root back to a folder , from the File->Source Control->Branching & Merging->Convert to Folder menu.

TF203071: The operation cannot be completed because the source folder that you specified contains a branch. If you want to perform this operation on the branch, then you must specify {path} as the source of the operation.

This occurs when you try to create a branch from a folder and there is a “branch roots” below this.

The reason for this restriction is consider the scenario, I have the following tree structure:

$/proj/MyProduct/Branches – regular folder

$/proj/MyProduct/Branches/v1.1 – regular folder

$/proj/MyProduct/Branches/v1.1/Dev - branch root

$/proj/MyProduct/Branches/v1.1/Test - branch root, related to Dev

$/proj/MyProduct/Branches/v1.1/Release - branch root, related to Test.

Users were branching v1.1 to v1.2, hoping that the relationship between Dev->Test->Release is maintained. However the relationship being established ends up being:

$/proj/MyProduct/Branches/v1.1/Dev -> $/proj/MyProduct/Branches/v1.2/Dev

$/proj/MyProduct/Branches/v1.1/Test –> $/proj/MyProduct/Branches/v1.2/Test

$/proj/MyProduct/Branches/v1.1/Release –>$/proj/MyProduct/Branches/v1.2/Release

To prevent users from making this assumption, we have the restriction. If you hit this message, you have a choice:

a. You are in the scenario described above, in that case you can setup your branches by branching $/proj/MyProduct/Branches/v1.1/Dev -> $/proj/MyProduct/Branches/v1.2/Dev and then branching -> $/proj/MyProduct/Branches/v1.2/Dev -> $/proj/MyProduct/Branches/v1.2/Test ->$/proj/MyProduct/Branches/v1.2/Release

b. If you still want to proceed with the operation (this is likely because $/proj/MyProduct/Branches/v1.1/Dev was incorrectly marked as a branch root). You can do so by converting the “branch root” back to a folder, from the File->Source Control->Branching & Merging->Convert to Folder menu.

Wednesday, November 16, 2011

TFS 2010: Cube processing failed

At a customer, we had some problems with the TFS Datawarehouse cube no longer being processed. When looking at the logs, I noticed the following error message:

<LastRun QueueTimeUtc="2011-11-10T13:15:59.497Z" ExecutionStartTimeUtc="2011-11-10T13:16:00.517Z" EndTimeUtc="2011-11-10T13:18:00.637Z" Result="Blocked">

<ResultMessage>[Version Control Warehouse Sync]: ---> MakeDataChanges() result=DataChangesPending. ---> TF221033: Job failed to acquire a lock using lock mode Shared, resource DataSync: [TFSDB].[Tfs_Warehouse] and timeout 30.</ResultMessage>


Some useful links to solve this problem:

Our solution:
  • Go to the warehouse control service, which in our case is at: http://tfs:8080/tfs/TeamFoundation/Administration/v3.0/warehousecontrolservice.asmx
  • From there click on the SetWarehouseJobEnabledState operation. In here you'll see that you can specify the collection, the job, and what state to put it in.
  • If you want to know the list of jobs, you can run the GetProcessingStatus operation from the warehouse control service.
  • Set all jobs to FullyDisabled.
  • Then set one to Enabled and process the warehouse using the ProcessWarehouse link on the warehouse control service page.

Tuesday, November 15, 2011

TFS 2010: Administrative reports

After blogging about 2 administrative reports some time ago, I have a new list with useful reports for the TFS administrator.

Microsoft released some reports that visualize the information that TFS stores about the health of the data warehouse.

These reports are useful to TFS administrators, operations/support teams, project administrators & end-users. The reports in this pack display the following kinds of information:

  • Recent processing times
  • Current status (whether the cube is processing now and, if not, when it is scheduled to process next)
  • Schema conflicts
  • Most recent time that each adapter successfully ran
Interpreting the reports

In the download, there is a FAQ document which includes screenshots of what different reports mean and common questions. The contents of the FAQ are also available at Monitoring the TFS Data Warehouse – FAQ.

  • SQL Server Reporting Services 2008 or 2008 R2
  • A shared datasource to which you connect the report, as the installation instructions describe how to configure.

Download and install this report pack to the Team Foundation Server Reporting Services Instance to monitor warehouse and cube processing status.

For information about how to install this report pack, see Installing Admin Report Pack for TFS.docx that is included in the download.

The pack includes:

  • Admin Report Pack for TFS FAQ.docx
  • Installing Admin Report Pack for TFS.docx
  • Reports\Cube Status.rdl
  • Reports\Blocked Fields.rdl
  • Reports\Reportable Fields.rdl

Here’s an overview of how the reports look and what questions you can answer with them.

More information and the original post:

Monday, November 14, 2011

Attempt by security transparent method to access security critical method

Last week I was spending some time integrating the Microsoft Enterprise Library Data Access Application Block with the MVC Mini Profiler.

After overriding some methods, I was ready to run my first test. But instead of getting some profiling results all I got was the following error message:

“Attempt by security transparent method 'Microsoft.Practices.EnterpriseLibrary.Data.Database.CreateConnection()' to access security critical method 'MvcMiniProfiler.MiniProfiler.get_Current()' failed.”

So why did I got this error and what does it mean?

Let me first tell you that the Enterprise Library assembly is marked with the AllowPartiallyTrustedCallersAttribute and uses the level 2 security transparency model.  Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default.

In .Net4.0 framework, security tranparency rules prevent any security transparent code to call into security critical code. In .Net4.0 default security transpareny of library assemblies is security critical. The Enterprise Library assembly is marked with AllowPartiallyTrustedCallers attribute. This explicitly tells the security framework that this library will accept calls from security transparent callers. But the assembly MvcMiniProfiler do not have AllowPartiallyTrustedCallers attribute on it. This means it will not allow partial trusted or untrusted code to call into it.

I solved the problem by forking the MvcMiniProfiler code and adding the AllowPartiallyTrustedCallers attribute on the assembly. Anyone who knows a better(read=more secure) alternative?

Friday, November 11, 2011

Windows Azure Training Kit: October 2011 release

And there is the Azure team again…

The October release of the Windows Azure Platform Training Kit (WAPTK) is now available as a free download. Download the full training kit including the hands-on labs, demo scripts, and presentations here. Browse through the individual hands-on labs on MSDN here.

The October 2011 version of the training kit includes the following new and updated content:

  • HOL: SQL Azure Data-tier Applications NEW
  • HOL: SQL Azure Data Sync NEW
  • HOL: SQL Azure Federations NEW
  • DEMO: Provisioning Logical Servers using Cmdlets NEW
  • DEMO: Parallel Computing on Windows Azure - Travelling Salesman NEW
  • SQL Azure Labs and Demos with the new portal and tooling experience UPDATED
  • Applied several minor fixes in content UPDATED

For more information about the new SQL Azure content, including the new HOLs, please refer to the blog post, “New and Updated SQL Azure Labs Available”, just posted to Roger Doherty’s blog.

Thursday, November 10, 2011

Waterfall project management was a mistake

Last week I was reading the ‘Are project managers living a lie?’ blog post by Peter Saddington, when I noticed the following eye-opening paragraph:

“It has always been eye-opening to many people when I tell my workshop participants or clients that they old waterfall way of doing software was never intended to be used. It was a misinterpretation of Dr. Royce’s seminal paper. What happened was that government agencies read the first page, saw a diagram (with a poorly chosen caption), and said: “Hey, that’s how we do software development!

Yes, that’s right. Waterfall project management was never the point. It was actually iterative development that Dr. Winston Royce was pointing to… later in his paper.

If they had read the second page of Dr. Royce’s paper, they would have found the following quotes:

“I believe in this concept, but the implementation described above is risky and invites failure.”

“Yet if these phenomena fail to satisfy the various external constraints, then invariably a major redesign is required.”

“The required design changes are likely to be so disruptive that the software requirements upon which the design is based and which provides the rationale for everything are violated. Either the requirements must be modified, or a substantial change in the design is required. In effect the development process has returned to the origin and one can expect up to a 100-percent overrun in schedule and/or costs.”

It’s kind of sad that the most used Project Management technology today is based on a misinterpretation of a paper. I hope that some (project) managers will read this paper and maybe even start thinking about how they are managing their projects today… (and yes, I’m also talking about the ‘Scrum but…’ adepts!)

Waterfall Managing the Development of Large Software Systems Royce

Wednesday, November 9, 2011

Visual Studio 2010: NUnit support

Microsoft announced full support for NUnit and other Testing frameworks in Visual Studio 11. However today you still don’t have NUnit integration out-of-the-box. Of course you can use the Resharper plugin or TestDriven.NET but these are not free(although worth every cent). Last week I discovered Visual Nunit, a free alternative to run your NUnit tests inside Visual Studio.

 Visual Nunit is an open source NUnit runner for Visual Studio 2010. It provides convenient view to test cases and enables debugging (red arrow) tests easily inside development environment. It does not require separate test project. Implemented as Visual Studio Integration Package.

  • Easy test debugging
  • Easy and fast NUnit test execution
  • NET 2.0, 3.0, 3.5 and 4.0 support
  • Test execution progress, time and summary
  • Stack trace view
  • Test filtering based on project, namespace and fixture

Visual Nunit 2010

Tuesday, November 8, 2011

JavaScript Patterns: Settings object

One of the patterns you see a lot in jQuery and other JavaScript based framework is the use of a Settings object to pass configuration data to a module or function.
Again without spending too much words, a short sample:
(function ($) {
      $.fn.blink = function (options) {
      var settings = {
     'speed': 'fast', 
    'repeat': 3
        //if the options isn’t null extend defaults with user options.
        if ( options ) { 
        $.extend( settings, options );

        for(var i = 0;i<settings.repeat;i++)

This is a function from a jQuery plugin(can’t remember the exact name). But the important things to notice here are:
  1. The blink method allows you to pass an options object.
  2. Inside the blink method a settings object is created with some default settings.
  3. If the user specified the options object, it will override one or more defaults by using the ‘extend’ method.
Learn it, love it…

Monday, November 7, 2011

IBM Rational to Team Foundation Server Integration Tools - Training and Exploration Sandbox

While I’m busy working on a IBM Rational ClearCase to Team Foundation Server migration, I discovered that the ALM rangers have provided an evaluation and training sandbox. It offers an easy to use and near-zero-admin exploration, training and testing environment for IBM Rational ClearCase and/or IBM Rational ClearQuest migrations to Team Foundation Server, based on the latest supported Team Foundation Server Integration Tools.

Supported scenario’s

Some of the supported scenario’s in this environment are:

  • IBM Rational ClearCase to Team Foundation Server migration
  • IBM Rational ClearQuest to Team Foundation Server migration
  • Team Foundation Server to Team Foundation Server migration
How do you get started?
  • Access the sandbox in three steps:
    1. Register at
    2. Check your e-mail
    3. Connect using RDC over the Internet as per received instructions

More information here.

Friday, November 4, 2011

Telerik MVC Grid: Client Side filtering

One of the nice features of the Telerik MVC Grid is filtering. What makes this even cooler is that you can easily add your own filters using the client side API.
An example:
$(function () {
    var button = $("#filterButton");

    var filtered = false; (e) {
        var grid = $("#ordersGrid").data('tGrid');

        if (filtered === false) {
            button.html('Remove filter');
            filtered = true;
   //Add filter
        else {
            button.html('Add filter');
            filtered = false;
   //Remove filter


Remark: Unfortunately this only seems to work when operationmode of the grid is not changed to GridOperationMode.Client.

Thursday, November 3, 2011

Javascript Patterns: The Module pattern

There are a lot of different ways to structure your Javascript code (and the most popular one remains no structure at all Glimlach). One of the most used patterns out there is the Module pattern. Instead of giving you a long explanation, let me show you a short sample:
var module=(function(){
 var helloText='Hello world'
 function sayHello(){

 return { sayHello: sayHello}; 


What’s happening inside this code?
  1. I create a JavaScript function that I immediately invoke. The result is assigned to the variable ‘module’.
  2. Inside this function I create a variable called ‘helloText’. As JavaScript uses function scope instead of block scope, this variable is available everywhere inside this function but not outside of it.
  3. I add a function ‘sayHello’, this function is also only accessible inside the ‘Module’ function.
  4. As a last step I create a new JavaScript object with a function sayHello on it that refers to the internal ‘sayHello’ function I’ve just created. This object is then returned. When I immediately invoked the function in step 1 I got the object back we’ve created with one public function ‘sayHello’.
By following this Module pattern, I can create nicely scoped functions and variables without fear for naming conflicts and without polluting the global scope.

Learn it, love it…

Wednesday, November 2, 2011

Bug in Telerik MVC Grid Control: Displaying items 1 - NaN of undefined

After starting a project with the jqGrid control, we decided to move to the Telerik MVC Grid control. Although a very powerful control, some advanced scenario’s were just too painful to implement with the jqGrid. So we replaced the jqGrid control with the Telerik MVC Grid control and were really happy with the result(we were able to get the same functionality with half the amount of code).

However it still has some rough edges here and there. One error we got was when our grid control was bound to an empty list, the following text was shown in the pager part: ‘Displaying items 1 - NaN of undefined’. This issue is mentioned on the Telerik MVC forums and a bug fix is available here.

UPDATE: Last week Telerik released their first beta of the Q3 2011 version of the Telerik MVC controls. I validated the beta and it seems that the issue is no longer there. Great job Telerik!