In order to locate where a .NET executable has been loaded from, you can simply write:
var assembly = System.Reflection.Assembly.GetExecutingAssembly ();
var dir = System.IO.Path.GetDirectoryName (assembly.Location);
This will return the path of the containing folder, not a file://
URI as you would get back by using .CodeBase
instead of .Location
(see this Stack Overflow question
on the topic).