The design of .NET makes this an interesting discussion.
Microsoft social moderator David M. Morton makes the point
Please don’t use System.Windows.Forms.Application.StartupPath unless you’re actually writing a Windows Forms application. There’s no need to add an unneeded reference to the project. Please use Assembly.GetEntryAssembly to figure out which assembly is the startup assembly in a project that is not a Windows Forms project.
Further discussion on this thread
Assembly.GetExecutingAssembly().Location will return the directory of the executing DLL. You know, good thing you brought this up. I think it would actually be better to use
Instead, because that would give you the first assembly that was executed (the executable) on the off-chance that you call GetExecutingAssembly() from the GAC, you’d get a directory path that would point to the GAC, in case you managed to register your library.
I believe the best option in this case, however (From one of Boban’s posts) might actually be
Although, I’m not completely sure why this is a better option than GetEntryAssembly() would be. I think it may be because of the lack of having to call into Reflection methods, but I personally don’t see any problem with it, as long as it doesn’t kill your performance. I will say that calling the AppDomain version is good if you don’t want to have to pass the string into the Path method for GetDirectoryName.