Unsafe reference arithmetic in .NET

Taking a closer look at the CompilerServices Unsafe approach to unsafe reference arithmetic over fixed statement in .NET. .NET has a garbage collector (GC) that automates memory management. This is incompatible with working with direct memory pointers, since the GC needs to track object usage and move objects around when required. You are of course … Read more

Why C# multidimensional arrays are slow

In a previous blog post I detailed how you can speed up array access in certain cases. This time I’m taking a look at what is happening when we access arrays in .Net, and digging into why multidimensional arrays are slow. First a quick refresher on array types. Array This is just a standard array. … Read more

Automatic unlock QNAP volumes from network

Automatically unlock encrypted volumes in QNAP via network using a BASH-script in a Cron-job. This script will log on, list locked drives and unlock them. Data stored on the disks are encrypted, and you need a key do access the disks. The key is kept in memory, so if power is lost the disks are … Read more

Code sharing between VS and Unity 3D

In my previous blog post I covered how I usually set up new .Net projects. The post covered both naming convention, .Net Standard and .Net Core. In this post I will show a four ways you can share code between .Net projects and Unity 3D projects. There are several good reasons why you would like … Read more

Automatic class generator for CsvHelper

CsvHelper helps in reading CSV files. But creating the model and mapper classes can be a bit time consuming. On this page you can generate the classes. Just fill inn the fields below with the header for your CSV file. It will generate the model and a mapper class. Code sample to use classes generated: … Read more

IIS redirect HTTP to HTTPS but allow Let’s Encrypt

Let’s Encrypt makes it easy for everyone to use HTTPS. The Windows client letsencrypt-win-simple simplifies installing and updating certificate in IIS. Using IIS URL Rewrite function you can allow Let’s Encrypt certificate retrieval/renewal and redirect all visitors to HTTPS URL of site.  

Template replacement engine

Using Regex as a template engine is an efficient way to replace strings in a template. Regex replace method supports executing a method upon match. We can populate a dictionary and make a lookup on all matches. This way we do the replacement in a single pass, rather than executing multiple .Replace(). Since dictionaries can be made case … Read more

ASP.Net 5 Areas

Visual Studio 2015 with ASP.Net 5 doesn’t support Areas in the GUI editor. Hopefully that will come, but until then here is a simple workaround. Create folder structure In the root of your project (not wwwroot) create the folder structure for Areas manually. In this example I created an area named “Foobar”. Edit Startup.cs to … Read more