ASP.NET Core System.Runtime.CompilerServices.Unsafe does not match

This error popped up randomly for me when I created a new ASP.NET with our standard framework.

Why this happens, even though this project is 100% identical to our other ASP.NET web projects is not quite clear; the SDK for ASP.NET is 2.1 and all packages are pinned to specific versions for our framework. However, Kestrel will pop an error saying it cannot load CompilerServices.Unsafe because it does not match the assembly reference.

One workaround, which is not very nice, is to remove the conflicting reference from *.deps.json in our bin directory; of course we are not supposed to touch that file, but studying it can give insight which package tries to load the wrong version.

A better approach is to just pin the version you require:

<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.1" ExcludeAssets="all" />

This seems to be caused by an issue with the Manifest file from a particular version of ASP.NET in a particular .NET Core install (2.1.503 in my case); it somehow sets the version of the assembly to while it means to use 4.5.1.

NLua on iOS 11

There have not been a lot of updates on NLua; I am still using it quite a bit and the version in NuGet doesn’t work on iOS 11. So I thought I quickly throw a version up here which works on iOS 11. It fixes the KeraLua issue with system() being removed in iOS 11 (using posix_spawn()) and the transition to VS (from XS).

Download here.

I will update my github and do a pull request when I have some more time later.

Searching for a static site CMS

I am getting fed up with WordPress. There are more reasons than one for that, but it being heavy and needing too many updates are the two major ones. For the first one; WP isn’t really that nimble. It is quite heavy on a server, especially for a blog that gets only a few updates and a few comments per month. There is no reason for all this overhead.

There are multiple blogs running on the server where this one is running, but together they are heavy enough to make a dent in the IO and CPU of that monster sometimes even though none of those sites have a lot of traffic. Some of them daily updates though, but that shouldn’t give that kind of load; a lot of the load is because of bot attempts to guess passwords, try out exploits and trying to post comments. With caching on (which they all have), it is ok, but still, these sites should be running fine on a Rasberry Pi I, all of them. That’s how light they are.

Second point; if I don’t keep updating, it will get cracked/defaced/abused; it is not a matter if it will but when it will. I have been trying out some static CMS software like Jekyll and others but unfortunately I do need some kind of CMS to keep clients and friends who run sites with me happy.

There are a few commercial CMS’s that allow static site generation with an advanced content management system on top of some open source generator. The most popular one in that space seems to be Siteleaf.

Unfortunately I want to be able to fix things myself when they come up, so I need an open source solution.

In my searches, I found a few interesting projects:

First of all, a very interesting tool you can add on top of a simple site generator of your own making, CreateJS. It is interesting because it is quite flexible in it’s configuration. You add RDF notations to your pages and you can start editing; it supports blocks, collections and more. When I have more time, I will certainly check it out again, but looking at the ‘small’ CreatePHP example of usage, I am not sure if I would call this a lightweight solution. Might not be a bad thing, but not now.

Second interesting project I ran into was Directus. A structured editor on top of any database/structure; phpmyadmin on steroids so to say (it is far more advanced). It is a flexible solution for many things I often need, but not this. Definitely something to keep in mind for another project that needs more than just simple content management.

The last one I ran into was RespondCMS. A static, WYSIWYG, bootstrap based CMS. It is very flexible with it’s plugins and content components and, using Javascript or your own API, it can be used to basically create anything you want statically and hybrid without writing too much code. It’s WYSIWYG frontend requires a bit of playing around with before you can use it in production. 

In the coming months I will play around with Respond and see if it works well enough to use (or if it is easy enough to contribute to the things that do not work well enough). Even the combination Directus & Respond for a hybrid static/dynamic system seems compelling. AJAX all the dynamic stuff with simple custom Angular components that go into Respond. 


Recompile your Xamarin iOS projects to Android – Proof of concept

My first mobile programming experience was, unfortunately, using Jquery Mobile. I won’t go into too much detail, but it definitely wasn’t great. HTML on mobile devices definitely wasn’t ready at the time; it is not now either, but it’s at least bearable and jqm did not make that experience better.

After that I did some native work; it was my first brush with Objective C / iOS. I promised someone I would make that code open source but I would need to stamp it with a lot of warnings as the code (to me anyway) is absolutely ghastly when I read it now. It was kind of a side project which I did in the summer because I wanted to make something nice; the app turned out well but there was no marketing so you can’t even find it in Google anymore. I did learn a lot though; cramming a lot of learning into a very short time worked well for me. iOS turned out to be nice to code for and it thought me a lot about the API, transitions, animations etc.

I continued working native on both Android & iOS, far preferring iOS at that moment (at the time of writing that is still the case); the projects were usually little apps and games which with lower budgets. Clients were really trying to figure out mobile still.

Fast forward a year, I got in touch with more long term mobile development; I was asked to develop the mobile applications on Android + iOS for a fintech startup. This would be a project of at least months to a year. The previous developers were gone (… no reasons given) and I was allowed to start from scratch, not using the code of the previous coders.

As we suddenly now had a bunch of clients lined up next to this one and I was the only coder, I had to find some way of doing this while we gathered stability to hire more developers and in some way that I would not burn out.

I was very fast at doing projects for iOS by that time, but my Android skills were lacking. It took me far too much time to do both of them natively at the same time, so I, early on, picked Xamarin to do the development. It would at least save me from doing double work on the core of the system; most of the logic could be reused and the code still compiles to the respective native platforms while the frontends are really platform specific.

As I was working on the fintech startup, I had to delegate work for other clients to a freelancer for the time being. I would lay the groundwork in the evenings while he would build the actual app and while I worked fulltime on the fintech apps.

That turned out to be hard; even the apps I was doing focused 100% on were quite hard to do on both platforms at the same time.

So I took a week off to think how to fix this without driving myself and the freelancer mental. The latter basically already happened and we were to blame for that.

One of the options was to just drop Android; for most clients, Android was an afterthought anyway. They designed everything for iOS and then said something like ‘yeah, and that then also for Android!’.

But I went for another solution, at least I decided to see how far I could get; on the laptop I brought were my projects for Xamarin iOS and the projects by my colleague as well. I decided, lead by these projects solely, to see if I could get them to compile and run on Android ‘well enough’ to give to clients.

Locking myself up for a few weeks to get that done was a lot of fun and in the end I hoped it would help clients.

And it did; the LoB (Line of Business) projects we had could be recompiled without issues. The more consumer focused ones could also but were not sell-able that way. Great for prototypes however to show how it will look if you would run it on Android functionally, and, as a practical side effect; clients without an iPhone or no interest in getting their UDID or jumping through Apple hoops could now immediately test the app at the same time as their colleagues.

We tried to get investment for the project for a short while as we noticed that especially Microsoft shops were very interested in it; the fact that they could dev LoB applications in C# on client and server for all platforms (we were going to create a Windows mobile version) by writing one frontend was attractive to them. Unfortunately we didn’t have the time to pursue it and just left it.

After Xamarin Forms emerged, our developers started using that and my proof-of-concept remains what it was; a proof-of-concept. After some legal fixes, I can now finally release the source code. Don’t mind the code too much; it was rapidly written as people were desperately waiting for me. Here you go; hope it helps someone.


Ignoring files in Webpack

People tend to whine a lot about the documentation of Webpack; while I agree that it could be better, the thing is open source so if you want to help out just do it! One question however seems to be very poorly answered on the internet and my colleagues (and others) keep asking it; how do you simply ignore files?

You might have seen tons of warnings like “You may need an appropriate loader to handle this file type.” popping up when you run Webpack and you might want to get rid of them without doing what Webpack suggests; add a specific loader for all of them.

While this might mean you need more studying of how to use Webpack, often people get blocked for hours or even days(!) by searching for a quickfix(-and-we’ll-change-it-when-needed); that quick fix is;

npm install --save-dev ignore-loader

after which you can add;

loaders: [
{test: /\.(jpe?g|png|gif|svg|map|css|std|indent|html|txt)$/i,
loader: 'ignore-loader'},