Rico Suter's blog.
 

Articles

Inside Async/Await: Synchronize an async method or code block

Have you ever tried to await a task inside a lock() block? It is not possible, because you can only synchronize synchronous code with the lock keyword. However, in today’s .NET development, async/await is used everywhere and the need to synchronize asynchronous code blocks is coming up quite often. This is why I wrote a simple class which can be used to synchronize asynchronous code blocks.
Read More ›

Avoid wrongly scoped injections with a custom Ninject kernel

I’m currently working on a large project where different teams implement assemblies which are consumed by other teams. We use Ninject for dependency injection: Each assembly has a Ninject module class which registers the available interface-to-implemenation bindings. At the moment, the consumers of these assemblies just know what module classes to load and what interfaces to inject into own objects like ASP.NET controllers or own service objects, but nothing about the scope of the injected objects. Recently we had some nasty runtime errors, because a consumer of one of these assemblies injected a per-request scoped object into a singleton-scoped object. This is why I looked for a way to detect injections of wrongly scoped objects (also known as captive dependencies).
Read More ›

Getting started with Entity Framework Code First Migrations

The following post describes the steps to setup and use Entity Framework Code First Migrations. For more information read this Microsoft page. The sample application shown in this article can be found on GitHub.
Read More ›

How to implement an enum with string values in TypeScript

I currently work an a single-page application (SPA), where we use TypeScript to access web services. In some places, the sent and received data structures use enums to describe the range of allowed values.
Read More ›

Bug Fix: Code Contracts compile error in Visual Studio 2015 and Windows 10

This article shows how to fix Code Contracts compile errors in Visual Studio 2015 and Windows 10.
Read More ›

Avoiding DLL file locks when using .NET reflection in external assemblies

For one of my projects, I had to load external assemblies and query the exported types (i.e. the public classes) using reflection. Everything worked fine, except that the .DLL files were being locked until the application was terminated.
Read More ›

Precompile ASP.NET MVC Razor views in Release mode to find errors at compile time

A problem we often face when developing ASP.NET MVC applications is that errors in Razor views are only detected at runtime while browsing the site. This is because the Razor views are not compiled until they are requested by the browser.
Read More ›

Post-process the HTML output of an action in ASP.NET MVC

This article shows how to implement a post-processor for an ASP.NET MVC application, which transforms the output of an controller action before it is transmitted to the client. The obvious way to do this is by implementing a custom action filter. First, we implement the base filter class:
Read More ›

Manually triggered computed observables in KnockoutJS

In KnockoutJS I sometimes need to create a computed observable which does not automatically detect the dependencies and which has to be triggered manually. This may be required if the computation is very complex and should only run in certain situations.
Read More ›

ASP.NET MVC: How to implement an edit form for an entity with a sortable child collection

This article shows how to implement the edit form for an entity with a collection property. As a show case, we will implement the edit form for a person entity with multiple addresses. The following diagram shows the UML diagram of the two entity classes:
Read More ›