与Programmatically find when the ASP.NET worker process and app domain last started?相似,但更为一般。
如何找出AppDomain的开始时间?
我已经完成了这样的事情:
private readonly static DateTime _appDomainStarted = DateTime.UtcNow;
public static DateTime GetApplicationDomainStartedTimeUTC()
{
return _appDomainStarted;
}
但静态只在运行时引用一次后才会被创建,所以它不起作用。
也许有一种方法可以确保在程序集加载时自动运行此代码?