SYSK 27: What you need to know about referenced assemblies in VS2005

Visual Studio has a new property for assembly references – Specific Version.  When this property is set to True, Visual Studio 2005 will only build the client if it has access to the same version of the referenced assembly of when the reference was added; otherwise, it’ll result in a warning.

By default, Visual Studio 2005 will not keep track of the referenced assembly version. For example, suppose you browse in Visual Studio 2005 and add a reference to version of the assembly MyAssembly.dll. The reference properties will reflect the assembly version, but will not have any affinity to it. If you replace the referenced assembly on disk with version (while keeping the same friendly name or even the strong name), next time you build the client, the client-side complier will use the metadata and type definitions from version of the server assembly. The manifest of the client assembly will record as the server assembly version number, and .NET will try to provide version to the client, not version, which the client developer added a reference to. In dynamic build environments, this default behavior will allow the client developer to always be synchronized with the latest server assembly version without doing anything special about it. The default behavior works well in a client project that adds references to other projects in the same solution. Whether you change the referenced assemblies' version explicitly or let the complier do it for you, you will always get the latest assemblies for your client debug sessions.

However, you can easily run into situations where this behavior is not what you want. Imagine developing a client application against a specific version of a control, version The control is part of a framework that adds its components to the GAC when it is installed. The framework also provides a folder on the disk for you to add references to. If you install version of the framework, it will add its components to the GAC, but will also override the disk folder with the newer assemblies. Consequently, your application will not be able to use version of the control, even though it makes specific use of that version. To address this need, Visual Studio 2005 provides the Specific Version property of the assembly reference. Specific Version is set by default to False for all references. When Specific Version is set to True, Visual Studio 2005 will only build the client if it has access to the specific version of the referenced assembly. Specific Version set to True will have an affect whether the referenced assembly has a strong name or not. If Copy Local is set to true and the version number does not match, Visual Studio 2005 will not copy the referenced assembly. When trying to build the client assembly, Visual Studio 2005 will look for an assembly with a matching version. If an assembly with a matching version was not found, but the assembly has a strong name, Visual Studio 2005 will also try to look up the specific assembly version in the GAC. In this respect, the GAC on the development or build machine is actually used as a development resource, hosting side-by-side versions of component frameworks. If Visual Studio 2005 cannot find the specific version of the assembly, it displays a warning icon on the reference in the References folder, expecting the developer to resolve it.

Note that the Specific Version property is only a build-time directive, and it has no effect on the runtime version resolution of the referenced assembly.


Comments (4)

  1. Prash says:

    I got the following error when I set my referece to copy local=false

    Could not load file or assembly ‘Ifs.Fnd.Data, Version=, Culture=neutral, PublicKeyToken=ff90f512e10aef0d’ or one of its dependencies. The system cannot find the file specified

    any answer to this?

  2. Ventsislav Velev says:

    What is the corresponding compiler flag ? I’m programming in C# and building everything on the command line, so I need to know how to set/unset this feature manually.

    Thank you very much.

  3. Barry says:

    I run into issue when i reference an assembly from GAC verion 1.1.199 with Specific Version = false, but still on client machine 1.1.199 does not exist instead 1.2.0 version deployed so my project is for some reason still trying to load 1.1.199 instead of taking latest 1.2.0



    ACT! Sync

  4. Lance says:

    can you please expand on what you mean by "Specific Version set to True will have an affect whether the referenced assembly has a strong name or not." – what effect will it have?

Skip to main content