用Assembly 调用到的dll文件后,这个文件就一直被占用,怎么解决?
Roior 2005-05-08 04:12:07 像如下代码, 如果程序中调用了这个函数,那么e:\Script.dll这个文件一直被占用着,请问如何释放这文件,使 e:\Script.dll这个文件能被修改或被删除呢?
有办法没有?
public string[] getScript(string[] Paras)
{
string[] script;
FileInfo file=new FileInfo(Path.Combine (Application.StartupPath,@"e:\Script.dll"));
if(file.Exists)
{
try
{
Assembly ass=Assembly.LoadFrom(file.FullName);
Type[] type=ass.GetTypes();
foreach(Type t in type)
{
if(t.Name=="ReportScript")
{
MethodInfo m=t.GetMethod("Run");
if(m!=null)
{
object o=Activator.CreateInstance(t);
script=(string[])m.Invoke(o,new object[]{Paras});
return script;
}
else
{
MessageBox.Show("装载出错!");
return null;
}
......