We have an internal error reporting system (inside our functions dll) and one of the info pieces we send is the name of the application that caused it.
Current code:
string applicationname= Assembly.GetCallingAssembly().GetName().Name;
The problem is when the error is send from one of our websites as it sends application names like "App_Code.6p_c415d".
One possible way was determining if the app is an executable or a website dinamically (how do we do that?) and in the case of being a website get the folder containing it or so...
But if you have better ways we are open to any idea ^^
We ended up creating the following function and it works fine:
public static string getApplicationName()
{
return string.IsNullOrEmpty(HttpRuntime.AppDomainAppId)?
Assembly.GetEntryAssembly().GetName().Name :
new DirectoryInfo(HttpContext.Current.Server.MapPath("")).Name;
}