Search code examples
c#visual-studio-2015azure-service-fabricpdb-files

Why does my Service Fabric code lock its own PDBs?


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.

  1. 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.
  2. 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?
  3. 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.
  4. 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).


Solution

  • Based on the issue that was raised, it looks like this is now fixed.

    "Going to close the issue as we believe both issues have now been addressed by the 5.6 runtime and the 1.6 tooling."

    Seems upgrading is now the answer to point 4. If anyone can answer 1-3 I'd be very happy to move the big green tick.