views:

4447

answers:

3

I am currently developing a .NET application, which consists of 20 projects. Some of those projects are compiled using .NET 3.5, some others are still .NET 2.0 projects (so far no problem).

The problem is that if I include an external component I always get the following warning:

"Found conflicts between different versions of the same dependent assembly".

What exactly does this warning mean and is there maybe a possibility to exclude this warning (like using #pragma disable in the source- code files)?

+11  A: 

Basically this happens when the assemblies you're referencing have "Copy Local" set to "True", meaning that a copy of the DLL is placed in the bin folder along with your exe.

Since Visual Studio will copy all of the dependencies of a referenced assembly as well, it's possible to end up with two different builds of the same assembly being referred to. This is more likely to happen if your projects are in separate solutions, and can therefore be compiled separately.

The way I've gotten around it is to set Copy Local to False for references in assembly projects. Only do it for executables/web applications where you need the assembly for the finished product to run.

Hope that makes sense!

Matt Hamilton
+2  A: 

This actually depends on your external component. When you reference an external component in a .NET application it generates a GUID to identify that component. This error occurs when the external component referenced by one of your projects has the same name and but different version as another such component in another assembly.

This sometimes happens when you use "Browse" to find references and add the wrong version of the assembly, or you have a different version of the component in your code repository as the one you installed in the local machine.

Do try to find which projects have these conflicts, remove the components from the reference list, then add them again making sure that you're pointing to the same file.

Jon Limjap
+6  A: 

This warning means that two projects reference the same assembly (e.g. System.Windows.Forms) but the two project require different versions. You have a few options:

  1. Recompile all projects to use the same versions (e.g. move all to .Net 3.5). This is the preferred option because all code is running with the versions of dependencies they were compiled with.

  2. Add a binding redirect. This will suppress the warning. However, your .Net 2.0 projects will (at runtime) be bound to the .Net 3.5 versions of dependent assemblies such as System.Windows.Forms. You can quickly add a binding redirect by double-clicking on error in Visual Studio.

  3. Use CopyLocal=true. I'm not sure if this will suppress the warning. It will, like option 2 above, mean that all projects will use the .Net 3.5 version of System.Windows.Forms.

Here is a utility to identify the offending reference(s):

http://www.brianlow.com/index.php/2010/01/25/find-conflicting-assembly-references/

Brian
+1 for the link to the utility. Mod this up.
Neil Whitaker