One of the most common deployment and runtime errors that pop-up from time to time is an Access Denied exception, or file in use by other process, while a disk operation is being done over a file or folder. We can find this type of errors in several stages of an application life-cycle using the Agile Platform. In more detail:
Some of the typical exception messages we can get are like:
The process cannot access the file '_delivery.aspx.cs' because it is being used by another process.
Details : System.IO.IOException: The process cannot access the file '_delivery.aspx.cs' because it is being used by another process.
Message: System.UnauthorizedAccessException: Access to the path 'D:\Program Files\OutSystems\Platform Server\OMLProcessor.xif' is denied.
The variations are many, but usually the error message is always explicit to the point of indicating that either a specific file is not accessible due to being locked by another process, or lack of security priviledges to access that file.
The best way to troubleshoot this type of problems is to identify the exactly which file is being accessed that generates the exception, and if there's other processes accessing it to. To do this, there's a very simple toll named Filemon, now owned by Microsoft, which will allow you to see all filesystem accesses, and identify the processes/files that are causing the exceptions, as shown in the image in attachment.
With Filemon you can start a capture of filesystem accesses, and filter by file extensions, file path, processes, and types of access results (Success, Failure, etc).
To use it,
Hope this is useful in troubleshooting filesystem locks and denied accesses on our systems.
Unfortunately, Microsoft removed the Filemon utility from availability, because it recommends the Process Monitor tool, which provides more information about a process accesses, instead of just File System accesses.
Thus, I would like to complement this topic with the recommendation to also use the Process Monitor in troubleshooting errors during file system accesses, and how to do it.
How to use Process Monitor to find file system locks or access denied errors
Just download the Process Monitor tool from the link above, decompress the zip archive, and run the ProcMon.exe executable.
This tool monitors several types of accesses by a process (registry, file system, network and process activity and threads).
To get only the file system accesses, unselect the Show Registry Activity, Show Network Activity and Show Process and Thread Activity from the upper tool bar. This will get you only the file system accesses.
If your troubleshooting an Access Denied, check for file system accesses with result ACCESS DENIED.
Hope this helps you troubleshooting file system locks and permissions issues while using the Agile Platform and it's applications.
Miguel Simões João