Category Archives: Uncategorized

Issue with Xaml Designer – An error occurred loading this property page

So after installing Visual Studio 2015 Update 2, my Xaml Designer decided to stop working. Every time I open the designer by clicking on a xaml file, it would show an error dialog that says “Visual Studio has encountered an unexpected error.” – not very helpful. Going to the menu, Options > Xaml Designer > General property page would yield an error “An error occurred loading this property page”.

I then tried re-installing Visual Studio 2015. Same issue. I then tried opening Expression Blend, it doesn’t work, but I got a some more interesting clues – it tells me to check ActivityLog.xml – In it, there was a telling error:

SetSite failed for package [XamlDesignerPackage][This access control list is not in canonical form and therefore cannot be modified.

Basically my permissions were corrupted somewhere in some file. I had a hunch. A test by logging on to a fresh Windows user account and opening VS xaml editor confirmed that the issue was limited to my profile account. I tried remove all traces of Visual Studio from profile but removing the obvious AppData folder didn’t fix the issue. There were just too many places it hides files. As a last resort, I reset all permissions on my profile folder such that I was the owner and had write access and surprise! it works!! Now I know what to try next time.

Let’s Encrypt with Exim and Dovecot

Following my post on setting up Let’s Encrypt with nginx, I experimented with installing the certificates from letsencrypt on my mail server. It was surprisingly straightforward. The key was that the verification of the domain, which requires port 80 or port 443 to be accessible on the host of the mail server. I run a secure mail server with Dovecot and Exim. Since on the server, nothing was hosted on port 80, I used the standalone plugin that runs a temporary standalone HTTP server for letsencrypt / certbot to access:

Continue reading

HTTPS with Let’s Encrypt SSL and Nginx (using certbot)

A few days ago I enabled HTTPS and SSL/TLS on this blog. A big barrier to enabling SSL on your website is the cost of the SSL certificate and the maintenance overhead of having to constantly renew your certificate. You could already get free SSL certificates with StartSSL, but the process of obtaining the certificate is still a manual process. A few months ago Mozilla and a bunch of companies came together and created Letsencrypt, a service which issues free SSL certificates that are automatically generated with a command line tool. When set up correctly, it alleviates the need for manual intervention. As of the writing of this blog post, the service is still in beta and support for Nginx is minimal, but it’s not difficult to set up.

Continue reading

How I fixed my random Visual Studio 2015 crash

For the past few days, my newly installed Visual Studio 2015 would randomly crash, naturally at the most inconvenient of times. In the 10 odd instances I could notice no discernable pattern to the crashes. It seems to happen randomly but consistently.

2015 comes with a new feedback feature in the form of smilies. You can send Microsoft a smile or a frown. I have been sending frowns every time the crash happened. Whoever opens and reads this frown would have seen my increasingly desperate messages.

Continue reading

Bridging VirtualBox and LXC

I have a Linux box that runs both LXC and VirtualBox side by side. All the containers and VMs are set to bridge mode. Unfortunately for some reason, the VirtualBox VMs can’t talk to LXC containers. Pinging yields a response, but any TCP connection fails. Both LXC and VBox can talk to the host fine. This is how you can resolve the issue.

Continue reading

Android Studio keeps deleting my project files (.iml) after a gradle sync

I had this annoying issue where Android Studio kept deleting my top-level project file (.iml) whenever I do a gradle sync. For months I had no idea why and Google search doesn’t seem to show this as a common issue. Finally today I got to the bottom of this.

The issue was the casing of the file names. For the project file, I had mixed capital and lowercase, whereas the project folder name was all lowercase. This inconsistency was due to a move of the project from a windows environment to a mac where I had a different folder name.

The fix for this issue was simple: Close the project in Android Studio and delete all the .iml files. Then use File > Import project and select the project folder and this will regenerate all the .iml files. The new .iml files should now match the case of the folder.

PouchDB for Firefox Addon SDK

I started investigating a database for my Chrome and Firefox addon yesterday and came across PouchDB. PouchDB is basically a NoSQL database for the browser. It is inspired by CouchDB and can even sync to it. PouchDB has excellent cross browser compatibility uses different backends (WebSQL, IndexedDB, LevelDB for Node.js) depending on browser or js runtime capabilities. This makes it an excellent option for cross platform web applications.

Continue reading

Node.js fun with the same typescript module spread over several js files

I’m building a web application with Node.js and typescript for the first time and have discovered some “fun” quirks with how Node.js modules and typescript modules interact with each other. I use the term interact loosely as they don’t actually talk to each other, and in fact each do their own separate thing. In this post, I’ll offer some tips on how I untangled this.

Node.js modules are based on the CommonJS modules architecture, using require and exports. Typescript has language level support for modules, which are basically glorified namespaces. Typescript also has support for AMD, which is yet another module loading specification. Each of these patterns all create a very confusing Javascript ecosystem.

Tying together Typescript’s module system and Node.js requires a bit of glue code. First up you need to ensure that you’ve told typescript to allow the exports and require keywords. This can be easily done by going to this helpful library of typescript module definitions and download node.d.ts. Next up import the definition into your ts file by putting this line at the top. We put the node.d.ts in a sub folder called typescript-node-definitions.

///<reference path='typescript-node-definitions/node.d.ts'/>

After that exports and require should now be recognised by the Typescript compiler. You should be able to use nodejs modules by calling require inside your ts files. And you can export with ease by doing at the end of your ts file:

exports.HomeController = MyWebSite.HomeController;

You can then reference the compiled js file normally in your main file:

var MyWebSite = require('./HomeController.js');

Most likely, you’ll have several files/classes that need to be under the same namespace, so a helper method can be used to corral them under the same object namespace.

function requireall() {
	var cns = { };
	for (var i = 0; i < arguments.length; i++) {
		var ns = require(arguments[i]);
		for (var o in ns) {
			cns[o] = ns[o];

	return cns;

And replace require with

var MyWebSite = requireall('./HomeController.js', './AboutController.js');

Trouble occurs when you try to make one class per file. You have your module distributed off multiple ts files and one of them is a sub class which references a base class. You can add a reference to the base class:

///<reference path="BaseController.ts"/>

This satisfies tsc, but when you run the node you’ll get an error:

    __.prototype = b.prototype;
TypeError: Cannot read property 'prototype' of undefined

That’s because node.js has no concept of typescript references. We need to use require to import the other file. Unfortunately, the module namespace we need to import into is recognised by the typescript as the module and any attempt to assign to it will result in a compiler error. This is where things need to get a bit hacky. We need to inject the base class into the namespace without triggering the compiler alarm. Underhandedly, we can use eval to achieve this. Put this under the module blabla { line and modify the __importClassName and __importModuleName variables:

var __importClassName = "HomeController";
var __importModuleName = "MyWebSite";
eval(__importModuleName + "." + __importClassName + " = require(\"./" + __importClassName + ".js\")." + __importClassName + ";");

This will allow node.js to resolve the base class and the whole thing to run!