Bug 4443 - Can't lock file and can't remove file errors
Summary: Can't lock file and can't remove file errors
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: 2.8.8.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-04-15 14:34 UTC by pinggi
Modified: 2012-04-19 16:54 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Error dialogs (65.30 KB, image/png)
2012-04-15 14:43 UTC, pinggi
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description pinggi 2012-04-15 14:34:00 UTC
1. I develop test app which uses GTK# and Cairo.
2. I build it and run it several times from Monodevelop IDE only. No problem.
3. When I run Windows explorer and I go into the bin/Debug folder of the project directly, Explorer touches Debug folder (starts holding file handle of that folder according to Sysinternals Process Explorer - probably monitors folder file changes).
4. When I go back to the Monodevelop and rebuild the project, it ends up with exception dialog: "Can't lock file" or another message: "Can't remove file". In the details there is:

System.UnauthorizedAccessException: Access to the path '...\PerfDrawing3\PerfDrawing3\bin\Debug\PerfDrawing3.exe' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.Delete(String path)
   at MonoDevelop.Core.FileSystem.DefaultFileSystemExtension.DeleteFile(FilePath file)
   at MonoDevelop.Core.FileService.DeleteFile(String fileName)

5. If I go up, out of the Debug folder in Windows Explorer and then switch back to Monodevelop, I can't build the project because of those exceptions at least 50 seconds! After ~50 seconds it is ok and I can rebuild the project as before. Ehen I go out of the Debug folder in Windows Explorer, Sysinternals Process Explorer stops showing me explorer.exe file handles of Debug folder immediately, but still I can't build the project in Monodevelop at least 50 seconds!

It is really annoying because I can't build the project, switch to explorer, test it by run it, switch back to Monodevelop, make a change and rebuild it. I have to wait 50 seconds.

I don't understand why it is behave like this. Something smells there. Not sure if it is my local problem or it is problem of Monodevelop how handles with file access.

However I can't look at the directory by Windows Explorer, or run built file, because I can't build the project in Monodevelop then. This quite critical bug I would say.
Comment 1 pinggi 2012-04-15 14:43:23 UTC
Created attachment 1672 [details]
Error dialogs
Comment 2 Mikayla Hutchinson [MSFT] 2012-04-17 12:16:32 UTC
TBH that's a bug in Explorer or an Explorer extension, I don't think there's anything we can do about it.

Why don't you run the exe using MD's "Run" command instead of running from Explorer?
Comment 3 pinggi 2012-04-19 16:31:00 UTC
I made additional tests. You are right.

I downloaded Handle from sysinternals and new version displays file handles correctly. So when I go to the bin\Debug folder by Windows Explorer. It opens file handle to that file. Very interesting for me.

--------------------------------------------------------------------------------
>handle PerfDrawing3.exe
Handle v3.46
Copyright (C) 1997-2011 Mark Russinovich
Sysinternals - www.sysinternals.com

System             pid: 4      type: File          25A0: PerfDrawing3.exe
--------------------------------------------------------------------------------

If I minimize Windows Explorer window. It holds file handle at least 50 seconds and then drops it.


--------------------------------------------------------------------------------
>handle PerfDrawing3.exe
Handle v3.46
Copyright (C) 1997-2011 Mark Russinovich
Sysinternals - www.sysinternals.com

No matching handles found.
--------------------------------------------------------------------------------

I'll try investigating it more deep...
Comment 4 pinggi 2012-04-19 16:54:43 UTC
Oh my. It is really Windows 7 bug!

More info here:
http://stackoverflow.com/questions/4378192/windows-2008-r2-kernel-system-process-pid-4-is-locking-files-and-folders