0

Arranging dlls into subfolders – the Probing element

The App.config file is a wonderful thing that can be used for many reasons, not least giving a location to set and amend application level variables without having to re-compile the software. In this instance it helps us designate one or many subfolders for the application in question to look through whilst searching for bound assemblies (referenced dlls or exes).

I tend to find that when I’m writing a solution with more than a couple of supporting libraries that my application directory starts to look pretty cluttered quite quickly, and that’s before I’ve considered whether or not they’ll have their own App.config files to drag around. It’s at this point that I decided that I’d rather arrange things neatly and have the .dlls and associated files in their own folder. This can be done by implementing custom after build actions and ensuring that you’ve got your reference paths set correctly but I was ideally looking for something that gave me less to remember and didn’t mean that I’d have to be careful about what I was referencing and where – really I just wanted my .exe to look a bit further for what it needed.

Enter the ‘Probing’ element..

This is all made possible by use of the probing element (Microsoft Link). I’d like to go into more about this element but essentially you can paste the below into your App.config within the tags and the relevant assembly will search through the folders lib and dll as subfolders. This means that you can put all of your dll files in a separate subfolder!

 

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="lib;dll" />
    </assemblyBinding>
  </runtime>

JBaker

Joi is an IT Development Analyst working in London and a consummate technophile. Whilst he isn't coding he can be found reacquainting himself with his guitars, spinning poi, looking for climbing walls or chasing the latest shiny thing to cross his field of vision.

Leave a Reply

Your email address will not be published. Required fields are marked *