如何检查已加载的程序集是否是有效的.NET程序集?我目前有这段代码,但非托管的DLL会抛出BadImageFormatException异常。
string[] filepaths = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.AllDirectories);
List<Type> potentialEffects = new List<Type>();
foreach (string filepath in filepaths)
{
Assembly a = Assembly.LoadFile(filepath);
potentialEffects.AddRange(a.GetTypes());
}