MSB3027 .NET Origin: Application & API Last updated 12 Oct 2026

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.

Exact message you may see Could not copyThe file is locked byExceeded retry count of 10
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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

0x80070020 — 0x80070020: The process cannot access the file because it is being used by another process (Windows)0x80070020COPY failed — COPY failed: file not found in build context / "/app/x": not found (Docker)COPY faileddid not complete successfully — failed to solve: process "/bin/sh -c ..." did not complete successfully: exit code: 1 (Docker)did not complete succ…ELIFECYCLE — npm ERR! code ELIFECYCLE / Command failed with exit code 1 (npm)ELIFECYCLEERR_OSSL_EVP_UNSUPPORTED — Error: error:0308010C:digital envelope routines::unsupported (Node.js)ERR_OSSL_EVP_UNSUPPOR…Failed building wheel — error: subprocess-exited-with-error / Failed building wheel for x (Python)Failed building wheelfailed to read dockerfile — failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory (Docker)failed to read docker…forbidden path outside the build context — COPY failed: forbidden path outside the build context: ../file (Docker)forbidden path outsid…MSB3027

Explore the map of this error Full error map →

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