The file ‘…’ cannot be copied to the run directory. The process cannot access the file because it is being used by another process.

Posted: July 25, 2013 in BizTalk
Tags: , , , ,

I’ve been working on a BizTalk Server 2004 project that had (not any more) between 6 or 8 visual studio solutions each one with a BizTalk Project inside. After a few minutes swapping from a solution to another I decided to add all the project in a single solution.

I notice that all the solution are configure to build the assemblies to a common reference folder shared by all projects:

Visual-studio-2003-build-options

And the other project are referring 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 others projects I could successfully compile.

CAUSE

The cause is easy… the Visual Studio has a lock on the file.

Note: That 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 the assembly from a folder, chose Add reference from Projects

Visual-studio-2003-add-reference-from-project

Work like a charm!

SOLUTION 2

Close all the Visual Studio solution that reference this assembly or assemblies and build the project.

About these ads
Comments
  1. Andy says:

    Another solution is to unload the projects from within visual studio and than reload the projects.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s