C# PDB file being held by another process and can't be deleted

Viewed 28

In our program we programmatically create a .dll and .pdb file from code that is stored in a database.

With certain settings, the assembly can be rebuilt every few minutes and then the folder must be cleaned out and new .cs and .dll and .pdb files are created.

We've been doing this for years. Now suddenly it can not delete the .pdb file.

System.UnauthorizedAccessException: Access to the path 'Sym.pdb' is denied.

If I try to delete it manually while the program is running (that is, the program that uses this assembly eventually), then I can't do it, but as soon as I stop debugging I can delete it. Note that I a not debugging the generated .dll at this time and also not using the .pdb actively. Those files should only be created in the folder at this time.

I have set the File Attributes to normal:

 fileName.Attributes = FileAttributes.Normal;

I have unchecked the following:

Tools -> Options -> Debugging -> General -> Enable Diagnostic Tools while debugging.

So I don't know what else. It might be my new laptop (but it occurs on a colleague's laptop as well). It might be a newer Visual Studio, currently working on VS2017, or a newer Windows.

Any suggestions?

0 Answers
Related