Wednesday, July 1, 2020

WslRegisterDistribution failed with error: 0xffffffff

While setting up WSL2 I came across this error. This seems like a scary error "WslRegisterDistribution failed with error: 0xffffffff", but all it means is port 53 is taken. 

The solution for me was to run this in cmd:
netstat -aon | findstr ":53"

And then find the PID that was using port 53, go to the task manager and kill it.

I also stopped the Docker services just in case (in the Windows "Services" UI).

Friday, June 26, 2020

React native error: EPERM: operation not permitted, lstat signing-config.json

So I started working with React native. While setting up a project in Visual Studio Code, this error came up. What ended up fixing the error is deleting the file "android/app/build/intermediates/signing_config/debug/out/signing-config.json".

Monday, May 25, 2020

Bind a list of non-sequential indexes

I recently discovered a bug in an application. There was a list of items in a form, each with an index (0, 1, 2, 3...) and if I removed item 2 only items 0 and 1 would get posted.

This seemed to me a rather common problem and something more people would have encountered by now. Luckily, I came across this post from 2008 by Phil Haack (https://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx/) in which he basically says we need a hidden input with the Index suffix for each item we need to bind to the list.

And guess what? It works!!

Saturday, April 18, 2020

Upgrade to .NET Core 3.1 - Could not load file or assembly Microsoft.IntelliTrace.Core

The last error I came across was this one, "Could not load file or assembly Microsoft.IntelliTrace.Core". This happened while debugging a test.

The initial fix was upgrading the referenced nuget packages to their latest version. However, after this, I still got the error. The solution was to update Visual Studio 2019 to it's latest version. Not very intuitive, but it worked.

Friday, April 17, 2020

Upgrade to .NET Core 3.1 - Using StructureMap in .NET 3.1

In short, you should stop using StructureMap. It's no longer supported. Instead, use Lamar, and only have to make minimal changes. It's written by the same guy who wrote StructureMap.

In your Program.cs:

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .UseLamar()
                .ConfigureWebHostDefaults(webBuilder =>
                {

In your Startup.cs:

        public void ConfigureContainer(ServiceRegistry services)
        {
             ...
services.Scan(scan =>
             {
...

Wednesday, April 15, 2020

Upgrade to .NET Core 3.1 - Could not find an IRouter associated with the ActionContext. If your application is using endpoint routing then you can get a IUrlHelperFactory with dependency injection and use it to create a UrlHelper

The error itself exposes the solution. You need to stop using: 

            return new UrlHelper(helper.ViewContext).DisplayLink(action, linkText, returnLink);

And instead use (notice I'm not using DI, but you should use DI to retrieve IUrlHelperFactory):

            var urlHelperFactory = ServiceLocator.Current.GetInstance<IUrlHelperFactory>();
            return urlHelperFactory.GetUrlHelper(helper.ViewContext).DisplayLink(action, linkText, returnLink);

Tuesday, April 14, 2020

Upgrade to .NET Core 3.1 - Migration warning CS0618 'RazorViewAttribute' is obsolete

This error is simple, you can even find the answer is SO. It's caused by one of your nugets, you only need to update it to the latest version. Finding the offending nuget is another story. Hopefully you don't have too many nugets to update.