System.Transactions assembly loading

81 views Asked by At

I'm trying to make a list of all referenced assemblies and assemblies in AppDomain. Every time I'm getting 25 ref.assemblies and after that - 39 assemblies in AppDomain. But if I call AppDomain.CurrentDomain.GetAssemblies() one more time, I get one more assembly - "System.Transactions". So, to make a list of all assemblies I'm using the code below:

Console.WriteLine(GetRefAssemblies().Count());
foreach (Assembly asm in GetRefAssemblies())
{
    if (!asmList.Contains(asm)) asmList.Add(asm);
    foreach (Type t in asm.GetTypes())
    {
        if (!dict.ContainsKey(t) && t.GetConstructor(Type.EmptyTypes) != null)
        {
            dict.Add(t, t.GetConstructor(Type.EmptyTypes));
        }
    }
}
Console.WriteLine(AppDomain.CurrentDomain.GetAssemblies().Count());
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
{
    if (!asmList.Contains(a)) asmList.Add(a);
    foreach (Type t in a.GetTypes())
    {
        if (!dict.ContainsKey(t) && t.GetConstructor(Type.EmptyTypes) != null)
        {
            dict.Add(t, t.GetConstructor(Type.EmptyTypes));
        }
    }
}
Console.WriteLine(AppDomain.CurrentDomain.GetAssemblies().Count());
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
{
    if (!asmList.Contains(a)) Console.WriteLine(a.FullName);
    foreach (Type t in a.GetTypes())
    {
        if (!dict.ContainsKey(t) && t.IsClass && t.GetConstructor(Type.EmptyTypes) != null)
        {
            dict.Add(t, t.GetConstructor(Type.EmptyTypes));
        }
    }
}

where GetRefAssemblies() loads and returns all Referenced assemblies. Here is a screenshot of output : [https://i.stack.imgur.com/sknC6.png]

Why System.Transactions is loading after scanning assemblies in AppDomain? How should I optimize my code ?

0

There are 0 answers