OK I found the solution. I found the following snippet
private static string RetrieveAssemblyDirectory()
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
var uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
After thinking about the solution it makes perfect sense, hence the palm slap to the forehead while muttering a duh sound.