title: Assembly file renaming and Assembly.LoadFile
body: <p>So here is the situation:</p>
  
  <p>I have an assembly called Lib1.dll. For some reason (not relevant to the question) I had to rename the assembly file name to Lib1New.dll, now while trying to load the renamed assembly using Assembly.LoadFile I noticed that the CLR tries to load the Lib1.dll as well. </p>
  
  <p>If Lib1.dll is found in the search path it gets loaded in the address space. The application works fine irrespective of whether Lib1.dll was found or not. (The problem is that if Lib1.dll is found the file gets locked and can't be deleted by other processes).</p>
  
  <p><img src="https://i.stack.imgur.com/xtn0X.png" alt="enter image description here"></p>
  
  <p>I don't understand why the LoadFile searches and loads Lib1.dll. LoadFile is supposed to load the contents of an assembly file on the specified location, why is it searching for files. </p>
  
  <p>MSDN documentation for LoadFile:</p>
  
  <blockquote>
    <p>Use the LoadFile method to load and examine assemblies that have the same identity, but are located in different paths. LoadFile does not load files into the LoadFrom context, and does not resolve dependencies using the load path, as the LoadFrom method does. LoadFile is useful in this limited scenario because LoadFrom cannot be used to load assemblies that have the same identities but different paths; it will load only the first such assembly.</p>
  </blockquote>