Get assembly names in the current application domain

I want to get Assemblies Friendly Names in the Current Application Domain, and so I wrote something like this:

static void Main(string[] args)
    {
        foreach (System.Reflection.Assembly item in AppDomain.CurrentDomain.GetAssemblies())
        {
          Console.WriteLine(item.FullName);

        }
    }

But the problem is that this is the result that I got, and not what I wanted to see:

mscorlib, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e0 ApplicationDomains, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null

I actually expected these names:

alt text http://www.pixelshack.us/images/xjfkrjgwqiag9s6o76x6.png

Can someone tell me if there is something that I have accepted.

Thanks in advance.

Or were the names I was expecting not assemblies?

+3
source share
4 answers

, .

, , . "XmlDocument foo = XmlDocument()" , System.XML.

    static void Main(string[] args)
    {
        XmlDocument foo = new XmlDocument();

        foreach (System.Reflection.Assembly item in AppDomain.CurrentDomain.GetAssemblies())
        {
            Console.WriteLine(item.FullName);

        }
    }

:

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
ConsoleApplication2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+4
    foreach(var assem in AppDomain.CurrentDomain.GetAssemblies())
    {
        Console.WriteLine(assem.GetName().Name);

    }

Assembly.GetName() AssemblyName, Name. , .

0

. , , # , (exe/dll).

And for the rest of your assemblies, they will not load until they are used.

AppDomain.CurrentDomain.GetAssemblies() gives you an array of all the loaded assemblies, and this list can be very different from what you see in the visual studio project.

0
source

Use Assemly.GetName (). Name or use reflection to find AssemblyTitleAttribute and use this value.

0
source

Source: https://habr.com/ru/post/1716451/


All Articles