Roy Osherove

View Original

The amazing CLR runtime re-appearing trick

[Update: Joseph cooney alerted me to the fact that this is probably cause by Windows File Protection, and he was totally right. Coolness! Here's a very good article about this subject.]
 
Here's a CLR party trick for you:
  • if you have .Net 1.1 installed on your machine
  • Go to the location of your mscorlib.dll file (usually c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll)
  • Rename or move mscorlib.dll to some place where it will not be found
  • Try to run a program that uses .net 1.1
  • Your app will load and work just fine
  • Look at the original location of the file you just renamed/moved
  • Automagically - mscorlib.dll will be there, as if you never touched it, restored by some unknown force in the matrix.
Note: this only works for the .Net 1.1 runtime. Try the same stunt with mscorlib.dll version 1.0 and your app won't load.
 
I do wonder what is the process behind this. Anyone have any clue?