我的程序有一个pluginManager模块,它可以加载DLL文件并运行DLL的方法,但我需要先阅读DLL属性Assembly.LoadFile().我该怎么办?
我读了关于Assembly文档,他们读了属性之后Assembly.LoadFile(),你知道Assembly没有UnLoad()方法,所以我必须在LoadFile()之前读取属性

private void ImprotZip(string path)
{
/*
1?create tempDir, uppackage to tempDir
2?Load Plugin DLL, Load plugin dependent lib DLL
*/
string tempDirectory = CreateRuntimeDirectory(path);
string[] dllFiles = Directory.GetFiles(tempDirectory);
///Load DlL
foreach(string dll in dllFiles)
{
ImprotDll(dll, false);
}
string libPath = string.Format("{0}\\lib\\", tempDirectory);
if (!Directory.Exists(libPath))
return;
string[] dlls = Directory.GetFiles(libPath);
///Load plugin dependent lib DLL
foreach(string dll in dlls)
{
try
{
//filtering same DLL
//if(Dll.properties.AssemblyProduct != "something")
//continue;
Assembly.LoadFile(dll);
}
catch(Exception e)
{ …Run Code Online (Sandbox Code Playgroud)