Environment:
Microsoft Visual Studio Professional 2017 RC
Version 15.0.26206.0 D15REL
Microsoft .NET Framework
Version 4.6.01586
Error:
error CS2012: Cannot open [file.pdb] for writing -- 'Access to path [path to pdb file] is denied'.
Description:
I am building a .netcore application for .net core 1.1 with other libraries targeting .netstandard1.6. When I build the project I get above error. I cannot clean/build or run the project when it is in this state. Does not happen the first time the project is open, it seems very random, because it may work a few times before I get the error.
When I navigate to it via explorer I also cannot delete the .pdb file nor the parent folder which is either the netcore1.0 or netstandard1.6 folders in in the Debug directories. I cannot even change the permissions on the files or folders. I am an administrator on the pc.
When I close Visual Studio and open it again all is fine and I can build again, which is not an answer.
Link to my question on the Visual Studio forum.
Thanks
This issue is more relate to the Visual Studio could not write the [file.pdb] files when Visual Studio executed the build operation. Due to this issue, Visual Studio could not complete the build process, then it will keep this file lock. So you could not clean/build or run the project and also could not delete the .pdb file nor the parent folder when it is in this state.
It`s very difficult to figure out the root of Visual Studio can not open the [file.pdb] for writing. Because this issue occurs randomly and could not be reproduced by us. But you can try to close Visual Studio, then delete the [file.pdb] file and rebuilding the project.
Note that:Thanks for Jean Roux`s contribution, he used Process Explorer to find out the process called ServiceHub.DataWarehouseHost.exe that has a handle on the file. Kill that handle then the build works again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With