Skip to main content

Posts

Showing posts from November, 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

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 n=entry.name; - 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:

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.

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 th

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:

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 Loc

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.    Highlights: 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 Vi

.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 .

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 .

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/v

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> </LastRun> Some useful links to solve this problem: Monitoring the TFS Data Warehouse – FAQ TFS2010: Warehouse and Job Service Administrator Reports 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

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 . Requirements SQL Server Reporting Services 2008 or 2008 R2 A shared datasource to which you connect the

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 cod

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.

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 co

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. Features: 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

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.fadeOut(settings.speed); this.fadeIn(settings.speed); } } })(jQuery); This is a function from a jQuery plugin(can’t remember the exact name). But the important things to notice here are: The blink method allows you to pass an options object.   Inside the blink method a settings object is created with some default settings.   If the user specified the options object, it will ove

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 teamdevcentral.com 2. Check your e-mail 3. Connect using RDC over the Internet as per received instructions More information here .

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; button.click(function (e) { e.preventDefault(); var grid = $("#ordersGrid").data('tGrid'); if (filtered === false) { button.html('Remove filter'); filtered = true; //Add filter grid.filter("OrderID~eq~10255"); } else { button.html('Add filter'); filtered = false; //Remove filter grid.filter(''); } alert("clicked"); }); }); Remark: Unfortunately this only seems to work when operationmode of the grid is not changed to GridOperationMode.Client.

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 ). 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(){ alert(helloText); } return { sayHello: sayHello}; })(); module.sayHello(); What’s happening inside this code? I create a JavaScript function that I immediately invoke. The result is assigned to the variable ‘module’.   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.   I add a function ‘sayHello’, this function is also only accessible inside the ‘Module’ function.   As a last step I create a new JavaScript object with a function sayHello on it that refers to the internal ‘sayHel

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!