Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Like the title of this topic, I want to get name of all DLL which is reference in a C# project. Thanks for your help.
Sorry for my bad English.
Posted 16-Jun-10 6:15am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

using System;
using System.Reflection;
 
class Module1
{
 
    public static void Main()
    {
        // This variable holds the amount of indenting that
        // should be used when displaying each line of information.
        Int32 indent = 0;
        // Display information about the EXE assembly.
        Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
        Display(indent, "Assembly identity={0}", a.FullName);
        Display(indent+1, "Codebase={0}", a.CodeBase);
 
        // Display the set of assemblies our assemblies reference.

        Display(indent, "Referenced assemblies:");
        foreach (AssemblyName an in a.GetReferencedAssemblies() )
        {
             Display(indent + 1, "Name={0}, Version={1}, Culture={2}, PublicKey token={3}", an.Name, an.Version, an.CultureInfo.Name, (BitConverter.ToString (an.GetPublicKeyToken())));
        }
        Display(indent, "");
 
        // Display information about each assembly loading into this AppDomain.
        foreach (Assembly b in AppDomain.CurrentDomain.GetAssemblies())
        {
            Display(indent, "Assembly: {0}", b);
 
            // Display information about each module of this assembly.
            foreach ( Module m in b.GetModules(true) )
            {
                Display(indent+1, "Module: {0}", m.Name);
            }
 
            // Display information about each type exported from this assembly.

            indent += 1;
            foreach ( Type t in b.GetExportedTypes() )
            {
                Display(0, "");
                Display(indent, "Type: {0}", t);
 
                // For each type, show its members & their custom attributes.

                indent += 1;
                foreach (MemberInfo mi in t.GetMembers() )
                {
                    Display(indent, "Member: {0}", mi.Name);
                    DisplayAttributes(indent, mi);
 
                    // If the member is a method, display information about its parameters.

                    if (mi.MemberType==MemberTypes.Method)
                    {
                        foreach ( ParameterInfo pi in ((MethodInfo) mi).GetParameters() )
                        {
                            Display(indent+1, "Parameter: Type={0}, Name={1}", pi.ParameterType, pi.Name);
                        }
                    }
 
                    // If the member is a property, display information about the property's accessor methods.
                    if (mi.MemberType==MemberTypes.Property)
                    {
                        foreach ( MethodInfo am in ((PropertyInfo) mi).GetAccessors() )
                        {
                            Display(indent+1, "Accessor method: {0}", am);
                        }
                    }
                }
                indent -= 1;
            }
            indent -= 1;
        }
    }
 
    // Displays the custom attributes applied to the specified member.
    public static void DisplayAttributes(Int32 indent, MemberInfo mi)
    {
        // Get the set of custom attributes; if none exist, just return.
        object[] attrs = mi.GetCustomAttributes(false);
        if (attrs.Length==0) {return;}
 
        // Display the custom attributes applied to this member.
        Display(indent+1, "Attributes:");
        foreach ( object o in attrs )
        {
            Display(indent+2, "{0}", o.ToString());
        }
    }
 
    // Display a formatted string indented by the specified amount.
    public static void Display(Int32 indent, string format, params object[] param)
 
    {
        Console.Write(new string(' ', indent*2));
        Console.WriteLine(format, param);
    }
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

list of DLL in C# project? maybe need to look in (right click -> project properties -> references)
  Permalink  
Comments
Toli Cuturicu at 17-Jun-10 10:57am
   
Reason for my vote of 1
no
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

i mean get it by C# code =.=
-----------------------------
  Permalink  
Comments
Toli Cuturicu at 17-Jun-10 10:57am
   
Reason for my vote of 1
fake
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

thanks very much
-----------------------
  Permalink  
Comments
Toli Cuturicu at 17-Jun-10 10:57am
   
Reason for my vote of 1
fake

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 150
2 PIEBALDconsult 110
3 Richard MacCutchan 105
4 Sergey Alexandrovich Kryukov 104
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 17 Jun 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100