Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / XML

Visual Studio: Adding DLL References Whose Version Changes Frequently

5.00/5 (4 votes)
25 Aug 2010CPOL1 min read 32.9K  
How to add DLL References Whose Version Changes Frequently

Let's assume you have a C# project in Visual Studio. In that project, you reference an assembly (DLL) created by another of your projects. Because both projects are in active development, the version number of the referenced assembly changes frequently.

There is one easy way to solve this:

Add a reference to the project by clicking "Add Reference..." and choosing from the tab "Projects". But this has two downsides:

  1. The target project needs to be in the same solution.
  2. The target project had better be a C# project, too. If it is a C++ project, for example, you will not be able to compile the (source/referencing) project in Blend.

But there is an alternative:

Add a reference to the compiled DLL by clicking "Add Reference..." and choosing from the tab "Browse". This seems to work fine initially, until the target DLL is updated and its version number changes. Then all hell breaks loose and there is no way to fix this - from the GUI.

But under the covers, everything is pretty simple. When you add a DLL reference, the IDE creates an entry like the following in the project file (*.CSPROJ):

XML
<reference include="SomeTargetDLL, Version=1.0.0.123, 
	Culture=neutral, processorArchitecture=x86" />

As is pretty obvious once viewed in code: the reference contains a version definition tag. Remove that, and you are good. In the above example, I simplified the line to:

XML
<reference include="SomeTargetDLL" /> 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)