シナリオ:ソリューションに存在する実行時にアセンブリをロードしたい。
ベロコードはCuurentAppDomainに存在しないため、機能しません。
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
また、参照されているアセンブリを検索する場合も、参照されていないため見つかりません。したがって、以下のコードも機能しません。
public static IEnumerable<Assembly> GetAssemblies()
{
var list = new List<string>();
var stack = new Stack<Assembly>();
stack.Push(Assembly.GetEntryAssembly());
do
{
var asm = stack.Pop();
yield return asm;
foreach (var reference in asm.GetReferencedAssemblies())
if (!list.Contains(reference.FullName))
{
stack.Push(Assembly.Load(reference));
list.Add(reference.FullName);
}
}
while (stack.Count > 0);
}
何か提案はありますか?