DLL Hell and Version Policy
page 6 of 10
by Anuj Sahu
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 43593/ 75

Version Policy

Assembly manifest records information about the version of each dependency it was built against. However, as stated in the above example where the developer of APP2 may wish to run with a different version of a dependency at run time. The .NET Framework enables this flexibility in version binding through version policies.

Assembly Version Numbers

The parts of the version number are major, minor, build and revision. As a developer you are free to change any portion of this number as you see fit.

One typical convention is as follows.

Major or minor: Changes to the major or minor portion of the version number indicate an incompatible change. Under this convention then, version 2.0.0.0 would be considered incompatible with version 1.0.0.0.

Build: The Build number is typically used to distinguish between daily builds or smaller compatible releases.

Revision: Changes to the revision number are typically reserved for an incremental build needed to fix a particular bug. You will sometimes hear this referred to as the "emergency bug fix" number in that the revision is what is often changed when a fix to a specific bug is shipped to a customer.

Default Version Policy

The CLR determines which version of the dependency to load when it comes across a reference to that assembly in code. The default version policy in .NET is simple, the caller gets the exact version with which the application was built and tested against.

Custom Version Policy

This is the section we have been talking so long where the author does not want the CLR to load the default version and redirects the CLR to the other version defined by the Author.

Version policies are stated in XML files and are simply a request to load one version of an assembly instead of another.

Example 3

The following version policy directs the CLR to load version 2.0.0.0 instead of version 1.0.0.0 of an assembly called app1.engine.

Listing 1

<configuration>
  <runtime>
    <assemblyBinding
       xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
         <assemblyIdentity
            name=" app1.engine" 
            publicKeyToken="ebf6b2ff4d0a08aa" />
         <bindingRedirect oldVersion="1.0.0.0"
          newVersion="2.0.0.0"/>
       </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

This is just a simple XML file. The name of this file is policy.1.0.app1.engine.config. Just place the file exactly where app1.engine.dll exists, in case of shared assembly it may be GAC.

Example 4

You can also redirect from a range of versions to another version. For example, the following policy redirects all versions from 1.0.0.0 through 5.0.0.0 of app1.engine to version 7.0.0.1.

Listing 2

<configuration>
  <runtime>
    <assemblyBinding
       xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
         <assemblyIdentity
            name=" app1.engine" 
            publicKeyToken="ebf6b2ff4d0a08aa" />
         <bindingRedirect oldVersion="1.0.0.0-5.0.0.0"
          newVersion="7.0.0.1"/>
       </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

This file is also similar to above example.


View Entire Article

User Comments

Title: Chirag   
Name: Chirag
Date: 2007-02-19 6:47:21 AM
Comment:
Really Nice article.

You can find another vay of assembly binding at,

http://chiragrdarji.blogspot.com
http://chiragrdarji.wordpress.com
Title: GOOD   
Name: SHAKTI PRASAD SAHOO
Date: 2007-01-07 8:48:54 AM
Comment:
IT IS A GOOD TOPIC.
Title: Nice   
Name: Joydip
Date: 2007-01-05 4:56:14 AM
Comment:
Hi,

This is a nice article. The concepts are well explained. Good work. Keep it up. Please find my blog at:--

http://aspadvice.com/blogs/joydip/

-Joydip

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-26 11:56:23 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search