How release file loaded with Assembly.LoadFrom() ?
load the file into a byte array and use Assembly.Load(byte[]) instead.
private void GenerateWebserviceAgents()
{
byte[] rawAssembly = LoadFile(webServiceAssemblyPath);
Assembly ass = Assembly.Load(rawAssembly);
if (ass == null) return;

foreach (Type t in ass.GetTypes())
{

}
}

// Loads the content of a file to a byte array.
static byte[] LoadFile(string filename)
{
FileStream fs = new FileStream(filename, FileMode.Open);
byte[] buffer = new byte[(int)fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();

return buffer;
}
private void GenerateWebserviceAgents()
{
byte[] rawAssembly = LoadFile(webServiceAssemblyPath);
Assembly ass = Assembly.Load(rawAssembly);
if (ass == null) return;
foreach (Type t in ass.GetTypes())
{

}
}
// Loads the content of a file to a byte array.
static byte[] LoadFile(string filename)
{
FileStream fs = new FileStream(filename, FileMode.Open);
byte[] buffer = new byte[(int)fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
return buffer;
}

浙公网安备 33010602011771号