title: How to load Dependent Assembly in memory to use Assembly.Load() method
body: <p>I have three dlls ProjBL.dll , ProjDL.dll and ProjMC.dll.</p>
  
  <p>ProjBL.dll is Business object dll</p>
  
  <p>ProjDL.dll is Data Access layer method dll</p>
  
  <p>ProjMC.dll is Master Class dll contains Properties</p>
  
  <p>ProjDL.dll depends on ProjMC.dll and ProjBL.dll depends on ProjDL.dll </p>
  
  <p>I have load ProjBL.dll in Memory using Assembly.Load() method from folder on D: drive with specified folder.</p>
  
  <p>Currently it gives error that "One of dependent Assembly not found" </p>
  
  <p>The Method Used is as below</p>
  
  <pre><code>    DirectoryInfo dllDirectory = new DirectoryInfo(folderPath); 
      FileInfo[] dllFiles = dllDirectory.GetFiles("*.dll"); 
      int dllCount = dllFiles.Length; 
      FileStream fs = null;         
      if (dllCount &gt; 0) 
      { 
          long streamLength = 0; 
          for (int fileCount = 0; fileCount &lt; dllCount; fileCount++) 
          { 
              fs = new FileStream(dllFiles[fileCount].FullName, FileMode.Open); 
              streamLength += fs.Length; 
              fs.Close(); 
          } 
          byte[] memory = new byte[streamLength]; 
          byte[] memory1 = null; 
          byte[] memory2 = null; 
          byte[] memory3 = null; 
  
          fs = new FileStream(dllFiles[0].FullName, FileMode.Open); 
          BinaryReader br = new BinaryReader(fs); 
          memory1 = br.ReadBytes(Convert.ToInt32(fs.Length));  // Loads ProjMC.dll 
  
          fs = new FileStream(dllFiles[1].FullName, FileMode.Open); 
          br = new BinaryReader(fs); 
          memory2 = br.ReadBytes(Convert.ToInt32(fs.Length));  // Loads ProjDA.dll 
  
  
          fs = new FileStream(dllFiles[2].FullName, FileMode.Open); 
          br = new BinaryReader(fs); 
          memory3 = br.ReadBytes(Convert.ToInt32(fs.Length));   // Loads ProjBL.dll 
  
          fs.Close(); 
          br.Close(); 
  
          memory1.CopyTo(memory, 0); 
          memory2.CopyTo(memory, memory1.Length); 
          memory3.CopyTo(memory, (memory1.Length + memory2.Length)); 
  
          assemblyUsed = Assembly.Load(memory);   
  
      }         
      return assemblyUsed;   
  </code></pre>