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.
Could not copyThe file is locked byExceeded retry count of 10 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
- FileNotFoundException assembly Could not load file or assembly 'X, Version=…' or one of its dependencies
- Unable to cast object of type System.InvalidCastException: Unable to cast object of type 'X' to type 'Y'
- NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 12 Oct 2026