I have used following method which doesnot work.
I loads individual assembly but if we combine result it doesn't work.
I think there requires linking between these assemblies and i doesn't know exact way.
================================================== ==
-
private Assembly ReadAssemblyFromMemory()
-
{
-
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;
-
}
================================================== ==
To solve this problem I have done it in another way as below method
-
private Assembly ReadTotalAssemblyFromList()
-
{
-
FileInfo fileName = new FileInfo(AssemblyPath);
-
DirectoryInfo dllDirectory = new DirectoryInfo(AssemblyPath.Replace(fileName.Name,""));
-
FileInfo[] dllFiles = dllDirectory.GetFiles("*.dll");
-
int dllCount = dllFiles.Length;
-
FileStream fs = null;
-
byte[] memory = null;
-
Assembly CombinedAssembly = null;
-
if (dllCount > 0)
-
{
-
for (int fileCount = dllCount - 1; fileCount >= 0; fileCount--)
-
{
-
if (dllFiles[fileCount].Name == fileName.Name) // Loads ProjBL.dll at last after loading ProjMC.dll and ProjDL.dll
-
{
-
fs = new FileStream(dllFiles[fileCount].FullName, FileMode.Open);
-
BinaryReader br = new BinaryReader(fs);
-
memory = br.ReadBytes(Convert.ToInt32(fs.Length));
-
assemblyUsed = Assembly.Load(memory);
-
br.Close();
-
fs.Close();
-
}
-
else // Loads ProjMC.dll and ProjDL.dll
-
{
-
fs = new FileStream(dllFiles[fileCount].FullName, FileMode.Open);
-
BinaryReader br = new BinaryReader(fs);
-
memory = br.ReadBytes(Convert.ToInt32(fs.Length));
-
assemblyUsed = Assembly.Load(memory);
-
br.Close();
-
fs.Close();
-
}
-
}
-
}
-
return assemblyUsed;
-
}
=================================================
Please provide the way to combine these Assemblies . Above two way doesn't work