My Instagram feed

My Instagram feed


Webpack has been initialised using a configuration object that does not match the API schema.

On Windows, when running yarn (custom action "start") to start the dev server, on the step that starts the webpack-dev-server, I had the following error message:

$ webpack-dev-server --debug --hot --progress --colors
 10% building modules 2/2 modules 0 active
 Invalid configuration object. 
 Webpack has been initialised using a configuration object that does not match the API schema.

This was not an easy one to understand, but it turned out to be very simple.

When I had CD-ed into the React app folder, I had typed the foldername with only lower case characters. The foldername was originally typed with a capital first letter. Webpack did not like that.

cd ..
cd Folder
yarn start


Adding nicer icons to the PageTree in EPiServer

I did some research about adding nicer icons for pages in the EPiServer Page Tree, and I came up with some nice resources.

What seems to be common for all approaches is that you must create css-classes that encapsule each icon to use. At the moment I don't see how to get around this without actually creating the classes.

You also need to create an InitializableModule which sets up the icons when the web is started. I have omitted that code here. Please read the example from the first example below (from, for that code.

This example is complete and shows how to use your own (or a third party lib) icons:

This example shows how to create your own icons (as an image sprite) and use for the icons:

Here's one that shows how to use the already included icons from EPiServer:

In stead of creating and maintaining the list of Episerver icons yourself, as in the example above, you could go for the Jon D Jones nuget package: This iconpack does not really contain any icons, just convenience constants that point to the built-in episerver icons (it seems so to me anyway).

I created a generic attribute, based on reflection, that plugs in the JonDJones icon pack (download from Nuget, as mentioned) into the first example I mentioned from the "nansenblog":

public class ContentIconAttribute : Attribute
    public ContentIconAttribute(Type type, string propertyName)
        IconClass = GetStaticStringValueFromLib(type, propertyName);

    private string GetStaticStringValueFromLib(Type libType, string name)
        var fieldInfo = libType.GetField(name);
        var propInfo = libType.GetProperty(name);
        var value = (fieldInfo?.GetValue(null) ?? propInfo?.GetValue(null)) as string;
        return value;

    /// Css class to apply to the icon
    public string IconClass { get; set; }

And here's how to use it:
using JonDJones.IconPack;

[ContentIcon(typeof(ObjectIcons), nameof(ObjectIcons.Start))]
public class StartPageModel : BasePage


Always run Visual Studio as administrator

I am using Visual Studio a lot, and when I pin it to the task bar in Windows 10, right-clicking it will bring up a (popup) list of my last opened projects.

I need to run VS as Administrator, to be able to debug my web applications running on the local IIS.

So when I right-click the pinned VS-icon on the task bar, I can right-click on Visual Studio, then select "Run As Administrator", which is fine. The problem is that I cannot right-click on any of my previously opened solutions and run VS as admin while opening that solution.

On a shortcut (and probably also some exe-files) you will get the option to "always run as administrator". Problem is, this option does not appear when looking at the properties of the DevEnv.exe file, so you need to "fake" it by going into the compatibility settings.

In essense: What I want to do is basically to always open Visual Studio "As Administrator".

So here's how:

From link 1 below:
  1. Locate devenv.exe, by right-clicking the VS icon and selecting properties, then see the link in the shortcut.
  2. Right-click devenv.exe and choose Troubleshoot compatibility
  3. In the new window click at Troubleshoot Program
  4. Check The program requires additional permissions
  5. Click "Next" until you get to a button that says "Test the application". 
  6. Click the button and VS will be launched "As Administrator". 
  7. Switch back to the dialog, press "Next".
  8. Click the top option to save the preferences.



Get time for given country

This code gets the first time zone for a country (meaning it probably won't work if your country has more than one), and calculates the date/time given the UTC date/time.

The method is an extension to the DateTime type, meaning you can use it by typing .AsLocalTimeForGivenCountryFromUtc(countryCode) after a variable or function returning that type. The countryCode parameter is a string, and must be a two-letter ISO 3166-1 country code.

You need to import John Skeets NodaTime library from NuGet.

using NodaTime.TimeZones;
using System;
using System.Linq;

namespace MyNameSpace

    public static class DateTimeExtension

        public static DateTime AsLocalTimeForGivenCountryFromUtc(this DateTime utcDateTime, string countryCode)
            //no matter what tz info is on the date, assume it is UTC
            var dte = new DateTime(utcDateTime.Year, utcDateTime.Month, utcDateTime.Day, utcDateTime.Hour, utcDateTime.Minute, utcDateTime.Second, DateTimeKind.Utc);
            var tzMapping = TzdbDateTimeZoneSource.Default.WindowsMapping.MapZones.FirstOrDefault(t => t.Territory == countryCode); //NodaTime
            var tz = TimeZoneInfo.FindSystemTimeZoneById(tzMapping.WindowsId);
            return TimeZoneInfo.ConvertTimeFromUtc(dte, tz);


Visual Studio 2015 Freezes when ReSharper is running

Ok, so finally got ReSharper installed. Again. Been doing fine without it for a while, but the team is using it so I got myself a license. But it was a bit of a disappointment at first. It seems that whenever I build my solution, which has both some C# and one F# project, VS freezes. Today it even crashed after being unresponsive for quite a few minutes. Seems more people have the same problem:

So what happened was that I was in my F# project making some changes, then I built the solution, and then I went on to do some more changes in the same project, but things were moving very slowly, and in the end froze completely and then the crash.

So my working theory is that the problem may be related to F#. So I have added the F# project folder to the exclude list in R# options. I also added the *.fs file type to the excluded files.

So far it's looking good. I have built several times, and editing F# code is smooth.

PS. Still looking good! :) Think I found the solution!

PPS. Also disabling R# for TypeScript files may be a good idea (or so I've heard).


Things that may be confusing when moving to F#

I have been doing C# for quite a few years, and I have started using F# recently. I am only occasionally coding in F# so I tend to forget some things from one time to the other. So here's what I must remember:
  • The sequence of F# code files in Visual Studio matters!
    • To have access to a module or type from another module, that module must be declared before (higher up) the other module.
    • To move a module up, use Alt + ArrowUp.
  •  Indentation matters!
    • If some code is part of some enclosing element, that code must be indented.
Here's a great article: