سؤال

I have a ASP.NET web application on Windows 7.

The application runs as an administrator on the server and intermittently I get the unexpected error:

System.ComponentModel.Win32Exception (0x80004005): Access is denied
    at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
    at System.Diagnostics.Process.GetProcessTimes()
    at System.Diagnostics.Process.get_StartTime() 

When I call:

_process = Process.GetCurrentProcess();
_startupTime = _process.StartTime;
هل كانت مفيدة؟

المحلول

It looks like the issue is caused because of the way we do security. This function should only get called on start up which should happen as an Admin but if the Application Pool restarts itself after a period of inactivity (set to 20 minutes) by changing it to 24 hours the problem went away as we never have a period of 24 hours of inactivity.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top