But now I have found by chance a much better solution, which is more robust and also useful for other shadow copying scenarios like hosting WCF services in IIS. You can use the assemblies CodeBase property to get the original location. The only drawback is that the codebase is formatted as a Uri. It normally includes a file protocol “file:///” and uses slashes ‘/’ instead of backslashes ‘\’, so you need to modify the returned string a bit:
var assembly = Assembly.GetExecutingAssembly();
var path = assembly.CodeBase.Replace("file:///", "").Replace("/", "\\");
var path = assembly.CodeBase.Replace("file:///", "").Replace("/", "\\");