Wednesday, March 17, 2010

Warning: the dependency 'file' in project 'project' cannot be copied to the run directory because it would overwrite the reference 'file.'

In Visual Studio 2003 (.net 1.1) you will see this error on your compiler everytime you update the version of a dll on the reference.
The official fix will tell you to add the dll to the GAC, or to make a link to the project (projects -> add reference) instead of linking to a file. If you link a project you can make sure that you recompile the projects from which you depend on. If you put the dll in the GAC, GAC will do version control for you.

The stupid thing about this error though, is that you don't really add version information when you first link the dll, and most times you just want to upgrade the dll version, not keep both of them, so what's the catch?

It seems that this error will occur if you use VS.net dll reference property "copy locally". If you set copy locally to false for each dll referenced and copy them by hand to the bin (or whatever folder you choose under project properties), the error will disapear. The error is misleading since, as far as i can tell, the conflict happens when VS will try to overwrite the file with itself.

I'll buy a coffee to the person that can tell me what is the internal file where VS is recording the referenced dll version information.

No comments:

Post a Comment