error MSB3027: Could not copy "obj\...\App.dll" to "bin\...\App.dll". Exceeded retry count of 10. The file is locked by: "App (1234)"
The build can’t overwrite the output DLL/EXE because the app (or IIS Express, a test runner, antivirus) is still running and holds it.
Seen on:
.NET
Meaning
Stopping the debugger without stopping the process, dotnet watch, background test hosts or IIS Express keep files locked. MSB3021 is the same issue.
Common causes
- App still running (orphaned process, dotnet watch)
- IIS Express/test host holding the DLL
- Antivirus/indexer scanning bin/
⚡ Quick fix
- Stop the process named in the message
- Close IIS Express / kill testhost
- Exclude bin/obj from antivirus scanning
Detailed fix by platform
Shell
- csharp
taskkill /F /PID 1234 dotnet build-server shutdown
How to diagnose
- Locker — Process named in the error
- Watchers — dotnet watch running?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in .NET
- NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object
- FileNotFoundException assembly Could not load file or assembly 'X, Version=…' or one of its dependencies
- InvalidOperationException InvalidOperationException: Unable to resolve service for type 'X' while attempting to activate 'Y'
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026