Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage version dependencies in a C#/.NET Project?

Suppose you have Project A, and this has various dll dependencies, but the tree looks something like this:

Project A 
    => Project B
        => Project C
    => Project D
        => Project C
    => Project E
        => Project C, v2

Is there a way to use Project E since it relies on a newer version of Project C (dll) even though the rest of the project is using an older version of that same library?

If there is not a way, or one that would cause much gnashing of teeth, is there a forward thinking solution to preventing this from happening on future projects?

like image 278
lucidquiet Avatar asked Nov 18 '11 19:11

lucidquiet


People also ask

What are dependencies in C?

In Dependency relationships class diagrams, a dependency relationship indicates that a change to one class, the supplier, might cause a change in the other class, the consumer. The supplier is independent because a change in the consumer does not affect the supplier.


1 Answers

From a longer term solution, not sure if this will work in your environment, but we have multiple dependent projects (from frameworks to dependent systems) that we reference. We use subversion and use externals to reference the libary/source folders so that all the dependent projects reference the same version.

We also have some projects where we bring in dependent libraries that might have used an older version when it was compiled than the newer and backwards compatible shared library that the main referencing application has included, in which case we use the multiple version solution that uses the config entry.

We actually have our build process stamp in something like (where _BUILD_VERSION_ is replaced by the build process with the current build number):

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Company.DependentAssembly" publicKeyToken="8510b56c219df72e"/>
            <bindingRedirect oldVersion="1.0.0.0-99.0.0.0" newVersion="_BUILD_VERSION_"/>
        </dependentAssembly>

The same article also has a way of referencing multiple version copies of the same assemblies in a project.

like image 79
Johan Botha Avatar answered Oct 23 '22 16:10

Johan Botha