MSB3027 🟪 .NET

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

  1. Stop the process named in the message
  2. Close IIS Express / kill testhost
  3. Exclude bin/obj from antivirus scanning

Detailed fix by platform

Shell

  1. csharp
    taskkill /F /PID 1234
    dotnet build-server shutdown

How to diagnose

  1. Locker — Process named in the error
  2. 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:

🧠 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.