4

类似于 以编程方式查找 ASP.NET 工作进程和应用程序域上次启动的时间?但更一般。

如何找出 AppDomain 的开始时间?

我已经证实了这样的事情:

private readonly static DateTime _appDomainStarted = DateTime.UtcNow;

        public static DateTime GetApplicationDomainStartedTimeUTC()
        {
            return _appDomainStarted;
        }

但是静态只有在运行时被引用一次后才会创建,所以它不起作用。

也许有一种方法可以确保在加载程序集时自动运行此代码?

4

0 回答 0