I am working on a Service Fabric application that contains a number of stateless services and a single stateful service. When I publish the first time, everything is fine and it's deployed to my local cluster. After this, if I try to package or publish the app without explicitly stopping it first, I get the following error:
CSC : error CS2012: Cannot open 'C:...\ProjectFolder\obj\x64\Debug\ProjectName.pdb' for writing -- 'The process cannot access the file 'C:...\ProjectFolder\obj\x64\Debug\ProjectName.pdb' because it is being used by another process.'
According to process explorer, the PDB is locked by my own ProjectName.exe. This is the single stateful service in my application.
- Why would my exe lock its own PDBs? I could understand if it was Visual Studio doing it.
- I see nothing in my own code that should cause this, so I'm assuming it's something in the Fabric code I'm calling.
- The PDBs are deployed with the application, but it's the files in the original source directory that are locked - why not the PDBs adjacent to the running code?
- Why do I only see this error relating to the stateful service, and not the stateless services?
- I suspect this has something to do with the stateful service generating lots of errors on startup, which Fabric may need symbols to properly display.
- How can I stop it happening - either using the correct PDBs or not using them at all unless I'm debugging through Visual Studio?
Edit: Raised on github. Current workaround for this:
A current workaround at this point in time would be to restrict the Network Service access to the pdb in the build folder (obj\x64\Debug).