There’s one little feature that you must have totally forgotten in the .Net framework, but it is great.

We can tell our apps to download automatically some DLL we would expect to be in the GAC and that are not. This is one freaking great feature. Instead of forcing your users to install the librairies in their GAC or including the libraries with your applications, you can specify the URL(s) of the DLL(s) your software application depends on. When you launch your program, the .Net framework program will download them automatically if they’re not already in the GAC download cache.

You just have to add something like that in the file “yourapp.exe.config” in the same directory of your “yourapp.exe” application.

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity
          name="Lib"
          publicKeyToken="9b52b2ba78ecf379"
          culture="" />
        <codeBase version="1.0.0.0" href="http://www.yourserver.com/dw-assemblies/Lib.dll" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

This avoids to :

  • Install something in the GAC
  • Package the required assembly with your software
  • Download or copy the required assemblys for each of your software
  • Clean your old assemblys once your don’t require them

You can see the content of your download cache by typing :

gacutil.exe /ldl

And you can clear your download cache by typing :

gacutil.exe /cdl