|zyciis| 当Assembly.LoadFile()后要删除这个dll时访问被拒绝,怎么清除Assembly对DLL的读取,多谢

|zyciis| 当Assembly.LoadFile()后要删除这个dll时访问被拒绝,如何清除Assembly对DLL的读取,谢谢
C# code

var asbDelete = System.Reflection.Assembly.LoadFile("C:\\WebRoot\\AdminUI\\Bin\\AdminUI.dll");
asbDelete = null;
var fileDelete = new System.IO.FileInfo("C:\\WebRoot\\AdminUI\\Bin\\AdminUI.dll");
fileDelete.Attributes =System.IO.FileAttributes.Normal;//这里是防止 文件只读 删除不了
fileDelete.Delete(); //这里出错,访问被拒绝



我看他的原因是因为
System.Reflection.Assembly.LoadFile("C:\\WebRoot\\AdminUI\\Bin\\AdminUI.dll");
后这个DLL已经正在使用中
所以
fileDelete.Delete(); //这里出错,访问被拒绝

但我用
asbDelete = null;
也没有办法清除读取
也找不到Assembly有Dispose的方法

那上面代码要如何改才能正常呢?

谢谢

------解决方案--------------------
改成
System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes("C:\\WebRoot\\AdminUI\\Bin\\AdminUI.dll"))

就不lock了