I have three dlls ProjBL.dll , ProjDL.dll and ProjMC.dll.
ProjBL.dll is Business object dll
ProjDL.dll is Data Access layer method dll
ProjMC.dll is Master Class dll contains Properties
ProjDL.dll depends on ProjMC.dll and ProjBL.dll depends on ProjDL.dll
I have load ProjBL.dll in Memory using Assembly.Load() method from folder on D: drive with specified folder.
Currently it gives error that "One of dependent Assembly not found"
The Method Used is as below
DirectoryInfo dllDirectory = new DirectoryInfo(folderPath);
FileInfo[] dllFiles = dllDirectory.GetFiles("*.dll");
int dllCount = dllFiles.Length;
FileStream fs = null;
if (dllCount > 0)
{
long streamLength = 0;
for (int fileCount = 0; fileCount < 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;