문제

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 ^^

도움이 되었습니까?

해결책 2

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;
}

다른 팁

You can use a key in the AppSettings to identify your application.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top