Question

The summarized problem is that I cannot delete specific files in a network share. The files seem to be locked on the server side and not by a windows service. The computers where this problem originated was under a domain and the documents and other windows libraries are on a network share. I have tried several solutions that will be described below.

Here is what happened: While debugging a web application in Visual Studio, I got the infamous blue screen of death. After I restarted and wanted to resume debugging, the project did not compile. I got this error: "Unexpected error creating debug information file z:\MY_Proj_Dir\obj\Debug\My_Proj_Name.pdb Access is denied". Which I found weird, since I have debugged that project in that location many times before. The unexpected windows error while running the debug session in Visual Studio must have locked it somehow. This file is for debugging information and after looking in forums how to resolve the issue, they recommended to delete the Debug directory.

So here are the solutions I have tried: - First, of course, I tried to clean and rebuild the project. - Close visual studio and restart the computer and tried again. - try to manually delete the obj\Debug directory: The files My_Proj_Name.dll and .pdb could not be deleted because apparently I need permission to perform this action from the administrator, which is myself. - So I right click the directory, open properties -> Security -> Advanced-> ownership -> and the ownership is of my_user_name@the_domain. Which is the account I am logged in from. If I try to change ownership to the only option that gives me there, which is the same (my_user_name@the_domain) , ticking replace owner on subcontainers and objects, it gives me an error “Error applying Security: access denied”. The same if I try to do it on the individual .dll and .pdb files.

  • I have tried turning User Account Control off, restarting and trying to delete the file.
  • I have also tried using the command line with no luck.
  • I tried the tool "unlocker" to see if I can release the file from other windows services or write permissions, but I still cannot delete them.

To see if the problem was on the computer, I tried to log in using VPN from my home computer and accessing the network drive: - If I delete the files from there, they immediately reappear, without any "cannot delete" dialog. It doesn’t let me change ownership of those files either.

  • I started up my Ubuntu VM and accessed the network share. and tried to delete the files from there. It gives me an even more weird error message: "File does not exist". But I can see it there!

  • I tried to log in to the network share from WinSCP and putty, but I cannot access the domain DNS with ssh or ftp. Probably the server only supports SMB (windows share)... I am not sure.

  • note: I only have problems with that specific folder and its files. I have no problems with any other folders in my network drive. One thing I have learned is not to debug projects located on a network share.

Was it helpful?

Solution

The problem was solved by working offline and debugging locally. Working offline Visual studio was able to rewrite the debug information files. From visual studio I clean the solution and the files were deleted. It seems that released the lock visual studio had on those files. Once it was working offline it was just a matter of turning the work online mode again. Then I was able to compile and debug normally.

I learned not to debug directly on the network share, but instead have my visual studio projects locally to avoid ownership and permission problems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top