0

When I build any of my WPF App projects, I often get this error:

"Unknown build error, 'The process cannot access the file '...\obj\Debug\GeneratedInternalTypeHelper.g.cs' because it is being used by another process.'"

In order to make the error go away, I must rebuild the project. Sometimes, the error persists, even if I rebuild many times. As far as I can tell, both its occurrence and its disappearance seem to be random.

A similar bug is reported here: Build error: "The process cannot access the file because it is being used by another process". That's a different problem because it concerns the project executable, while mine concerns GeneratedInternalTypeHelper.g.cs. Nevertheless, I've tried most of the suggestions posted there, including:

  • Switch from Debug to Release and back (or vice versa)
  • Close all designer windows before building
  • Use Task Manager to close all instances of MSBuild.exe
  • Manually delete GeneratedInternalTypeHelper.g.cs
  • Restart Visual Studio

None of these measures reliably resolve the error. Can anyone suggest what else I might try?

Edit:

Solved. The problem was an extension called FastFind. The suggestion to run Visual Studio in SafeMode was the advice I needed. Thanks to everyone who posted a comment.

Further Edit:

I reported the problem to the developers of FastFind, and they fixed it in an update. Kudos to them.

Lewis J
  • 11
  • 3
  • 2
    Have you tried running VS in administrator mode, and trying rebuild all? If that helps the situation, then that would give a hint as to why the problem is cropping up, IMHO. Also worth trying: Solution->Clean All. – code4life Dec 20 '17 at 23:11
  • On your suggestion, I tried running Visual Studio in administrator mode. Unfortunately, that doesn't seem to make any difference -- I still get the error. Likewise, cleaning the solution doesn't seem to help. – Lewis J Dec 20 '17 at 23:41
  • Look i know this is trivial, in the case there is a process hanging around, have you tried turning the pc off and on again? do you still get the error? The fact that you get this with all your apps is concerning, also it may not help have you tried startign VS in safe mode devenv.exe /SafeMode . this will cancel out 3rd part plugin problems – TheGeneral Dec 20 '17 at 23:55
  • My usual workaround for this issue is Clean Solution, Restart Visual Studio, Clean Solution again. The first clean will often give the same error but the second one usually works for me. Failing that I close the solution and delete all the bin/obj directories manually (or via a batch file if there are a lot of projects). – Tone Dec 21 '17 at 00:11
  • 1
    Have you checked what keeps the file handle? You can use this answer: https://serverfault.com/a/1980 – Maciek Świszczowski Dec 21 '17 at 00:19
  • Saruman's suggestion to run in safe mode has led me to the answer. The culprit is an extension called FastFind. With that disabled, the problem has vanished. – Lewis J Dec 21 '17 at 01:33
  • Please add that as an answer and accept it (you may need to wait some time to be able to accept your own answer) so it is easier to find for others. – Richard Dec 21 '17 at 08:30

1 Answers1

1

Solved. The problem was an extension called FastFind.

Lewis J
  • 11
  • 3