我有以下方法应该检索加载的本地(在 bin 文件夹中)程序集的列表:
static IEnumerable<Assembly> GetLocalAssemblies()
{
Assembly callingAssembly = Assembly.GetCallingAssembly();
string path = new Uri(Path.GetDirectoryName(callingAssembly.CodeBase)).AbsolutePath;
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
return assemblies.Where(x => !x.IsDynamic && new Uri(x.CodeBase).AbsolutePath.Contains(path)).ToList();
}
但是,程序集列表缺少我需要的几个程序集。我需要的程序集是托管的(c# .net 4),在项目中被引用,并且存在于 bin 文件夹中。
为什么应用程序启动时 bin 文件夹中的二进制文件没有被扫入 AppDomain?