Wednesday, December 25, 2013

Channel 9 series: What’s new in Visual Studio 2013

If you get bored, during the Christmas holidays, have a look at the Channel 9 series: What’s new in Visual Studio 2013.

Developers, are you trying to figure out what Visual Studio 2013 has to offer you? Whether you develop for the web, Windows, or Windows Phone, and whether you are using C#, XAML, HTML, or Visual Basic, this course is for you. It focuses on some of the key new features, addressed individually in sessions throughout the day, so that you can tune in to the specific tools that will help you develop more quickly and easily. Start by learning about the integrated development environment (IDE), and then attend sessions including improved IntelliSense, easier debugging, and better tools for application lifecycle management (ALM).


Tuesday, December 24, 2013

OpenSSL: Creating an ADFS certificate

Just as a quick reference for myself, here are the required statements to create your own certificate using OpenSSL:

  • Create the ADFS certificate:

openssl req -x509 -nodes -days 3650 -newkey rsa:1024 -keyout adfs01.pem -out adfs01.pem-extensions v3_ca

  • Pack the certificate and the key into a pfx file so we can easily import it into the Windows Certificate store:

openssl pkcs12 -export -out adfs01.pfx -in adfs01.pem -name "adfs01"

Monday, December 23, 2013

OpenSSL: Unable to load config info from /usr/local/ssl/openssl.cnf

When trying to create a new certificate using OpenSSL, it failed with the following error message:

“unable to load config info from /usr/local/ssl/openssl.cnf”


This error was an easy one to solve. Just restarting the computer fixed it. Jippie! Glimlach

Friday, December 20, 2013

Angular.js: Combining $index and orderBy filter

When creating an application with Angular.js, I was using the $index variable inside an ng-repeat to track the index of the current item. The problem was that the moment I start combining this with an orderBy filter, the $index value was no longer correct.

I worked around the issue by passing the item itself around instead of the index.  In my function I used the indexOf method of an array.

Anyone with a better solution?

Thursday, December 19, 2013

NHibernate: Unrecognised method call:Boolean Contains(Int64)

A colleague asked me for help with a complex NHibernate query. He had written a query using the NHibernate Linq support but when he tried to execute the query, NHibernate complained with the following error message:

‘'Unrecognised method call: System.Int64:Boolean Contains(Int64)”

Let’s have a look at his query first:

It seems that NHibernate cannot translate the Contains() call in a related NHibernate query. To fix this, we switched from the Linq syntax to the QueryOver syntax:

Wednesday, December 18, 2013

Angular.js: Simple orderby sample

In the Angular.js documentation you can find a sample of how to use the orderby filter.

The problem is that this sample is already quite complex and allows you to specify a custom filter based on a predicate value.

Here is a simple sample that applies the order filter based on a specific column:

Tuesday, December 17, 2013

Combining oData and a custom authentication module

If you are looking for a way to integrate oData and custom authentication, I can recommend the following article: Securing OData services using Basic Authentication.

There is one thing that you should notice:

The moment you start using a custom authentication module, it’s important that you configure IIS for Anonymous Access. Otherwise the built-in authentication modules will kick in even when your own custom authentication module is called.

We forgot to change this and it took us some time to figure out why we always got a login dialog although the authentication module authenticated us successfully.

Monday, December 16, 2013

Visual Studio 2013: RunSettings vs TestSettings?

After creating some tests, I wanted to exclude some assemblies from the code coverage. In Visual Studio 2010 this could be done through the .testsettings file. In Visual Studio 2013you’ll notice that a .testsettings file is no longer included in a unit test project. The newer test framework, introduced in Visual Studio 2013, can be configured using a .runsettings file.

If you use a .testsettings file, the MSTest test framework will be used to run your tests. This runs more slowly and does not allow you to run tests from third-party test frameworks.

The stupid thing is that, although the .runsettings file is the recommended solution, Microsoft only added a .testsettings template to Visual Studio 2013. In the MSDN documentation they mention creating a custom XML file and renaming it, but there is a better solution.

In the Visual Studio Gallery, you can find a solution item template that creates a default runsettings file under Solution Items, and saves you from having to do this manually.  See for information on how to change the default settings.

The runsettings file is used to change the code coverage analysis settings for a test run, in particular which files to be included and excluded from analysis,  and also used to set symbol search paths.

Friday, December 13, 2013

Things I learned at NDC London: ElasticSearch River Plugin

After the first 2 days of workshops, NDC London continued with lots of great speakers and sessions. I was planning to share some information during the conference itself but due to technical difficulties I had to postpone it. For the next few days I will be sharing some of the great content.

I’m already using ElasticSearch, so one of the sessions I didn’t want to miss was Full Text Searching & Ranking with ElasticSearch.

It was a great session overall. One of the things that was new to me was the concept of a ‘River’.  The ‘River’ is a metaphor for the stream of constant data. That constant data stream can come in different forms and from different sources.

Rivers in elasticsearch provides you with functionality that listens for changes in another data source and apply them to elasticsearch. Rivers are allocated to nodes within the cluster. They are provided with automatic failover in case of node failure, and allow to store state associated with them.

There are multiple River plugins out there, some of them are build by the ElasticSearch team themselves, other come from the community.

Supported by Elasticsearch

Supported by the community

Note: If you are looking for SQL support, this is possible through the JDBC driver.

More information:

Thursday, December 12, 2013

Things I learned at NDC London: OAuth integration in ASP.NET SPA template

After the first 2 days of workshops, NDC London continued with lots of great speakers and sessions. I was planning to share some information during the conference itself but due to technical difficulties I had to postpone it. For the next few days I will be sharing some of the great content.

Security was one of the hot topics at the conference. With sessions about Layered Security, OAuth, OWASP, Security of ASP.NET Web API, and so on… there was no excuse to follow at least one security related session.

One of the things that was shown to us by Dominick Baier was the new OAuth integration in the Visual Studio 2013 SPA template. The SPA template has been completely rewritten and uses OAuth with a bearer token and  OWIN for authentication purposes.

Have a look at following blog posts to learn more about it:


Wednesday, December 11, 2013

Things I learned at NDC London: The Future of C#

After the first 2 days of workshops, NDC London continued with lots of great speakers and sessions. I was planning to share some information during the conference itself but due to technical difficulties I had to postpone it. For the next few days I will be sharing some of the great content.
One of the sessions that got a lot of traction, was ‘The Future of C#’ session by Mads Torgersen.
Here is a list of some of the language features the C# team is considering:
  • Primary constructors - public class Point(int x, int y) { }
  • Read-only support for auto implemented properties - public int X { get; }=x;
  • Using statement support for static types - using System.Math; Sqrt(X);
  • Support for Property Expressions - public double Distance => Sqrt(X * X + Y * Y);
  • Improved null checking - if (points?.FirstOrDefault()?.X ?? -1) { }
  • Support for Method Expressions - public Point Move(int dx, int dy) => new Point(X + dx, Y + dy);
  • Inline declarations for out parameters - public void Foo(out var x, out var y) { }
  • Support for using enumerables in combination with the params keyword - public Point Average(params IEnumerable<Point> points) { }
I probably missed some features. So if you were there, feel free to share your info. I’ll add the items to the list…

Update: After creating this post, I noticed the following blog post that contains the same info+ some extra details:

Tuesday, December 10, 2013

Things I learned at NDC London: Reactive Extensions Training Camp

After the first 2 days of workshops, NDC London continued with lots of great speakers and sessions. I was planning to share some information during the conference itself but due to technical difficulties I had to postpone it. For the next few days I will be sharing some of the great content.

Rx (Reactive Extensions)I’m a big fan of reactive extensions although I still have a hard time to grab my head around it. During one of the Rx sessions I heard that Netflix contributed a great series of interactive exercises for learning Microsoft's Reactive Extensions (Rx) Library for JavaScript as well as some fundamentals for functional programming techniques:

This is a series of interactive exercises for learning Microsoft's Reactive Extensions (Rx) Library for Javascript. So why is the title "Functional Programming in Javascript"? Well it turns out that the key to learning Rx is training yourself to use functional programming to manipulate collections. Functional programming provides developers with the tools to abstract common collection operations into reusable, composable building blocks. You'll be surprised to learn that most of the operations you perform on collections can be accomplished with five simple functions:

  1. map
  2. filter
  3. mergeAll
  4. reduce
  5. zip

Try this tutorial on-line.

Monday, December 9, 2013

Things I learned at NDC London: Azure Friday

After the first 2 days of workshops, NDC London continued with lots of great speakers and sessions. I was planning to share some information during the conference itself but due to technical difficulties I had to postpone it. For the next few days I will be sharing some of the great content.

Today we start with Windows Azure Friday.

Every Friday Scott Hanselman tries out some stuff on Windows Azure and shares his experiences. This video series was new to me but I started watching it yesterday and I’m already hooked. You can bookmark the link or add a reminder to your calendar.


Tuesday, December 3, 2013

NDC London–Day 2

Yes, we survived day 2 of NDC London. With our heads filled with AngularJs, SignalR and Web API knowledge we spent the evening shopping in the Westfield mall after enjoying a delicious meal at one of Jamie Oliver’s Italian restaurant.  I’m still digesting the great food and all the new things we learned. 

You can find my sample code here:

And here are my notes of day 2 of the workshop.

Overriding Services

  • You can overwrite any service bij creating a new factory registration
  • Last registration wins…

Decorating Services

  • Add pre- and post processing logic
  • Use $provide.decorator()

Service Providers

  • Different way to create services(there are multiple, remember)
  • Use $provide
  • Configure the service during the configuration phase(2 phases as you should know; configuration and run phase)

Service Constants

  • Inject primitives as a service

Service Values

  • Similar to Constants, can also inject a value
  • The only difference is that constants are available in the config phase, values are only available during the run phase

Service factories

  • Another way to create a service and service provider

Service operator

  • Another(yes indeed) way to create a service and provider
  • Difference is that with a service you need to attach the service to the this object
  • Scott says "don't use it"

HTTP Interceptors

  • Request and response interceptors

HTTP Transforms

  • Transform the request and response itself


  • Gives you a very simple GET,PUT, POST, DELETE interface to your Web API

Extending HTML

  • Give you custom HTML elements through the use of directives
  • Most directives work in multiple ways
    • As an element <accordion>
    • As an attribute <div accordion>
    • As a class <div class=accordion> --> Avoid this one, it's confusing to find out if its a CSS class or directive

Event Directives

  • Multiple events are available out-of-the-box

Custom Directives

  • Build your own directives through a Directive Definition Object
  • Can become quit complex
  • With the restrict option you can specify how the directive can be used(as an element,…)


  • Note that you should call it as otc-greeting


  • Transclude option
    • Take the content from your custom directive and merge it with the template
  • Scope option
    • Allows you to create an isolated scope(by default the scope of the parent controller is used)
      • Useful for re-usable widgets
    • You can also create a new inherited scope
  • Compile function
    • Is called once for every directive
    • Can be used to manipulate the template
    • Most of the time you don't need this
  • Link function
    • Is called


  • Uses jQuery Lite; "the 20% jQuery you used all the time"


  • One of the core concepts of Angular is that it should be testable
  • Helps avoid global state and singletons through dependency injection
  • Helps separation of concerns by splitting out responsabilities over controllers, templates, services, etc…
  • Framework options
    • Qunit
    • Jasmine
    • Mocha
  • Test runner options
    • Karma
    • Grunt
    • Chutzpah


  • Through angular-mock.js(part of the NuGet package)
  • Use $httpBackend to test HTTP interaction


  • Very important part of Angular
  • Use ngView
  • RouteProvider used during configuration phase
  • Is available as a separate NuGet package
  • Include the module


  • Multiple Routing Events are available
  • You can also use HTML 5 routing if you don't like the # sign in your URL's


  • Separate module(angular-animate.js)
  • Supports CSS transitions and animations
  • Contains a list of built in animations

UI Bootstrap


Annoyances(again) :-(

  • Kind of confusing combination of service constants and service values
  • Custom directives can be quit complex
    • Especially if you start to play with the scope

NDC London–Day 1

Day 1 at NDC London is over. Learned a lot about Angular.js and looking forward for the next day.

You can find my sample code here:

If you are interested, I added all my notes during the workshop. You’ll see that we learned a lot Glimlach


  • More like MVVM & Silverlight building experience
  • Very extensible framework
  • Forward looking
    • Takes into account future evolutions in JavaScript & HTML

Getting started

  • Use Nuget


  • Multiple modules available
  • Angular.core is the only one required
  • Angular does not have any dependencies(!)
  • 'ng-app' : bootstrap element

Other starting points

  • Yeoman: does scaffolding(more designed for MAC, Linux)


  • Angular-Seed: gives you an example of how to structure your app


  • Default directive syntax is not HTML compliant
    • Will not pass through an Html validator
    • Alternative syntaxes available

Templates and Views

  • Representation of the model
  • Uses a combination of {{ }} and directives

Change detection

  • Not done through observables but through snapshot change detection
    • Is a little more expensive than what Knockout etc… does
  • In EcmaScript 6 this will be fixed, it will have an object.observe function

ng-cloak directive

  • It's annoying to see the raw html before the template is applied
  • To fix this, you can use the ng-cloak element in combination with a css rule


Browser support

  • Angular officially supports IE8 and up
    • Most things should also work on IE6 and up


  • Uses a subset of JavaScript in {{ }}


  • Hides an element when the expression evaluates 'falsy'





  • Default module that we are using is the 'ng'-module
  • Always a good idea to split up your application into modules
  • Use 'angular.module'
  • Specify the root module through ng-app=""


  • My first modularized controller:



  • Multiple ways to create services(at least 5 :-))
  • Easiest way is through the factory
  • Angular has its own IOC container
    • Makes it easy to mock dependencies
  • By default every service is a singleton by default

Bootstrap phase

  • 2 parts
    • config phase: app.configure()
    • Run phase:
  • During the config phase NO services are available, but you can use serviceProviders
  • During the run phase NO serviceProviders are available, but you can use services
  • Example:




  • The DI container that is used behind the scenes
  • Be careful when using a minifier!
    • 2 ways to fix this:
      • One way is to use a minifier that knows angular
      • Another way is to use a specific annotation syntax
        • Specify all dependencies as a string array


  • Or specify the $inject property --> Use this one, it's cleaner…


Code Organization

  • Not everyone has the same opinion
  • Most people use a different file per abstraction(e.g. Angular-Seed)
  • Possible structure(folder per abstraction):
    • Apps
      • reportApp
      • adminApp
      • patientApp
      • common
        • common.js
        • custom directives
        • controllers
        • Services
  • Alternative structure(folder per feature)
    • Apps
      • reportApp
        • search
          • SearchDirective.js
          • SearchController.js
        • saveReport

Core Angular API

  • equals: does a 'deep' equal check on 2 objects
  • copy: create a copy of the movie
  • Has an embedded jqLite library(=20% of jQuery that you use all the time)

$scope inheritance

  • Uses prototypical inheritance
  • Use objects on your scope if you want to point multiple scopes to the same object

Digest loop

  • To detect changes Angular goes through a digest loop
  • After a change a second digest loop is triggered
  • Be careful to not create an infinite loop of digest loop updates
    • Angular will throw an error after 10 $digest() iterations


  • Don't call an $apply inside an $apply


  • Allows you to listen for changes

Working with forms

  • FormController can attach to named forms
  • Angular understands HTML5 validation attributes


  • Format and modify model data
  • Filters can be piped together




  • Includes other templates or views


  • Services can be anything in Angular
    • Doesn't have to be fancy objects
    • Anything that is not a filter, controller, directive
  • Services are singletons
  • There is a long list of built-in services

Annoyances Bedroefde emoticon

  • Most typo's will not result in exceptions, makes it sometimes hard to find out why you don't see your data
  • Strange way to resolve promises(should be fixed in AngularJs 1.2)
  • Minification in combination with injector
  • Angular only updates it's view when it thinks something has changed
    • It only knows this if something happens inside the angular context(otherwise Angular has no clue)
    • The so called '$digest loop'
      • You can trigger a digest by calling $scope.$apply();
  • Beware of browser versions <IE 8