Monday, November 8, 2010

Fix : Dll locking issue by Visual Studio

I have observed the following error while building BizTalk schemas and maps projects.

Unable to copy file "obj\Deployment\Schemas.dll" to "bin\Deployment\Schemas.dll". The process cannot access the file 'bin\Deployment\Schemas.dll' because it is being used by another process.

I could get rid of this annoying error after doing following tasks,

1. Paste the following script in PreBuild events section of
Schema Project->Properties window (found about this script on this blog entry),

if exist "$(TargetPath).locked" del "$(TargetPath).locked"

if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

2.Set CopyLocal property of Schemas dll to False

UPDATE [06.14.2015]:
Here is another alternative to get rid of this error:

We get this error most likely when we add references to other projects or dll file from project bin directory directly. Instead build and GAC the referenced project and then add reference from GAC. This way even if we open both projects in different Visual Studio windows, we will not see this locking error.

HTH.

2 comments:

Ritesh said...

The solution mentioned by you did not work for me. It seems that there is not a signle solution for this. Microsoft agreed that there is problem with BizTalk Server Project template for Visual Studio. They recommend installing 2 hot-fixes, but that still doesn't work. I could not spend much time on this due to time-line and had to alter my solution and used only one project with different folder for Schemas, Maps, Orchs instead of diff project.

Rajesh Babu said...

Sorry to hear that it didnt work out for you, Ritesh. There could be multiple root causes for this kind of issues as you mentioned and thus there may not be a single solution. But having different projects for different types of BizTalk artifacts is ideal pattern used by most. Please provide me with little more information about your environment and I will try to help as much I can. (You know how to catch hold of me, right :-))