Ohad's Blog

Lets talk about .net !

Mirror at:
blogs.microsoft.co.il

News

         Ohad Israeli's Facebook profile

Grab this badge here!

C# Code Snippts

Favorite Blogs

Israeli .Net Bloggers

How to overcome the CLR fusion limitation

There are cases where you would be interested to load an assembly from a different directory then the root dir of your .net application. When you’ll try to do so you will face with the limitation of the fusion process (assembly loading process) – this limitation limits you to load assemblies from underneath the root dir of your application in order to guard your app from dll hell.

In order to overcome this limitation you can use the old plain Unix trick… create a symbolic link to the file… there is a small utility called mklink which lets you create symbolic link to a directory or a file.The process of making it work is to put the assembly in directory of your choice and then create the symlink at the place where the assembly is being expected to be.Its possible later on to replace the symlink with other symlink thus redirect the app to a different assembly without changing the app itself.

If you are interested in redirecting a bunch of assemblies it is also possible to declare a probing directory via the app.config file and create a symbolic link of this directory thus redirecting all the probing calls to a different directory outside of the root path of the app.

While playing with the fusion process its worth to remind people of the fusion log viewer tool(fuslogvw.exe) which will enable you to have an insight view of what and where the clr is looking for its assemblies.


The mklink command is used to create a symbolic link. It is natively available in Windows 2008+. It has the following command line syntax:

mklink [[/D] | [/H] | [/J]] link target
  • /D – Creates a directory symbolic link. Default is a file symbolic link.
  • /H – Creates a hard link instead of a symbolic link.
  • /J – Creates a Directory Junction.
  • link – Specifies the new symbolic link name.
  • target – Specifies the path (relative or absolute) that the new link refers to.

Mklink / Junction

Documentation for NTFS symbolic links on MSDN

CreateSymbolicLink function in the Win32 API

Link Shell Extension, which presents a graphical interface for creating hard and symbolic links as well as directory junctions

Symlink accessible driver for 2000/XP/2003,

Comments

No Comments