I’ve been working on a BizTalk Server 2004 project that had (not anymore) between 6 and 8 Visual Studio solutions, each with a BizTalk Project inside. After a few minutes of swapping from one solution to another, I decided to add all the projects to a single solution.
I notice that all the solutions are configured to build the assemblies to a common reference folder shared by all projects:

And the other project is referring to the assemblies from that folder.
However, when trying to compile the project, I was getting the following error:
The file ‘MyDLLProject.dll’ cannot be copied to the run directory. The process cannot access the file because it is being used by another process.
But when I open that project isolated from the other projects, I can successfully compile.
📝 One-Minute Brief
Learn how to fix the common Visual Studio build error: “The file cannot be copied to the run directory because it is being used by another process.” This issue usually occurs when multiple solutions share a common output folder or when Visual Studio maintains a lock on an assembly. Solutions include changing the output path to the default bin\Development\, using Project References instead of file references, or closing conflicting Visual Studio instances.
Cause
The cause is easy… Visual Studio has a lock on the file.
Note: This lock could be from the Visual Studio instance that you are working on or another Visual Studio instance in another session.
Solution 1
The easy solution to avoid further problems is to change the “Output path” to another location, for example, the default, bin\Development\.
And then, instead of referring to the assembly from a folder, choose Add reference from Projects

Work like a charm!
Solution 2
Close all the Visual Studio solutions that reference this assembly or assemblies and build the project.
Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son.
Another solution is to unload the projects from within visual studio and than reload the projects.