Background
Occasionally, I run into an error when trying to build a project in Visual Studio.
Error
Sample Error
Images
Image – Build Errors. Run the last successful build?
Textual
There were build errors. Would you like to continue and run the last successful build?
Image – Process cannot access the file because it is being used by another process
Textual
Severity Code Description Project File Line Suppression State Error System.IO.IOException: The process cannot access the file 'sample.ispac' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.InternalDelete(String path, Boolean checkHost) at System.IO.File.Delete(String path) at Microsoft.DataTransformationServices.Project.DataTransformationsProjectBuilder.IncrementalBuildThroughObj(IOutputWindow outputWindow) at Microsoft.DataTransformationServices.Project.DataTransformationsProjectBuilder.BuildIncremental(IOutputWindow outputWindow) 0 Error System.IO.IOException: The process cannot access the file 'sample.ispac' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.InternalDelete(String path, Boolean checkHost) at System.IO.File.Delete(String path) at Microsoft.DataTransformationServices.Project.DataTransformationsProjectBuilder.IncrementalBuildThroughObj(IOutputWindow outputWindow) at Microsoft.DataTransformationServices.Project.DataTransformationsProjectBuilder.BuildIncremental(IOutputWindow outputWindow) 0 Error System.IO.IOException: The process cannot access the file 'sample.ispac' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.InternalDelete(String path, Boolean checkHost) at System.IO.File.Delete(String path)
TroubleShooting
Outline
- File Write Lock Process Identification
Task – File Write Lock Process Identification
Tools
Let us quickly review some of the tools for identifying processes holding a write lock on a file.
- SysInternals
- handle
SysInternals
Handle
Availability
The handle process is available here.
Install
No need to install, it is an executable ( exe ).
We just launch a command shell and run it.
Help
To get help, please issue “handle.exe /?“.
Argument | Detail |
---|---|
Name |
|
-nobanner | Do not display the startup banner and copyright message |
Run
Syntax
handle [name]
Sample
- To find references matching our culprit, we can supply the file’s full name or any part of the file name.
- For the sake of simplicity and also knowing that our file extension is not so common, we will simply supply the file’s extension ( ispac ).
handle ispac
Output – Image
Output – Text
handle ispac Nthandle v4.22 - Handle viewer Copyright (C) 1997-2019 Mark Russinovich Sysinternals - www.sysinternals.com DTExec.exe pid: 21220 type: File 78: sample.ispac
Explanation
- Matches
- Application Name:- DTEexec.exe
- Process ID:- 21220
- Type:- File
- File Name:- sample.ispac
Remediation
Outline
- Review running processes
Task – Review Running Processes
Our matched process is dtexec.exe
DTexec.exe is a hosting container for SSIS and DTS Packages.
Images
Image – Previous Execution
Text
Traced the blocking process back to a previous same application project run.
Accessed the previous shell and did as told: “Press any key to continue …. “.
Dedication
Dedicating: to my spouse.
She and the computer know all my foibles.