I am confused with load assembly in AppDomain

  • Thread starter Thread starter Pab
  • Start date Start date
P

Pab

Hello,

I am confused with load assembly in AppDomain. I created ASP Web
application, same business logic is realized in custom DLLs, and I need to
load ones in my application. If I use ‘Load(assmblyRef)’ method of AppDomain
class, assembly is loaded but DLL file locked. I try to read DLL in byte[]
array and load assembly calling Load(byte[]) method. All are pretty, but in
contrast to calling Load(assmblyRef)’ method, calling Load(byte[]) method
results in assembly is loaded in domain each time (GetAssymles() method
brings assembly array which contains same versions of loading assembly). Can
anybody suggest approach how I can load custom dlls in application not
blocking DLL file.
 
Hi,
Seems it managed code one looks like:
protected Assembly CreateAssembly(string filename)
{
System.IO.FileStream fs = new System.IO.FileStream(filename,
System.IO.FileMode.Open);
byte[] buffer = new byte[(int)fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
Assembly asm = this.AppDomain.Load(buffer);
return asm;
}
 
Back
Top