Click here to Skip to main content
15,906,467 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all,
Could you please tell me how to get the details of the dlls which are referenced in a project?
Posted

Hi,

for Runtime, You need to use reflection. Please go through with the link
Reflection (C# Programming Guide)

Regards
AR
 
Share this answer
 
v2
Comments
Anju Gowri 3-May-11 5:30am    
Sorry. I need the details on Application runtime.
Ankit Rajput 3-May-11 5:38am    
For that, You need to use Reflection.
Anju Gowri 3-May-11 5:54am    
I want the references which are inbulit ie System.Core,System.Data etc.
Hi there,

System.Reflection is your friend here. This is how you get the referenced assemblies in run-time.
C#
StringBuilder builder = new StringBuilder();

Assembly currentAssembly = Assembly.GetExecutingAssembly();
AssemblyName[] referencedAssemblies = currentAssembly.GetReferencedAssemblies();
foreach (AssemblyName assembly in referencedAssemblies)
{
    builder.AppendLine(assembly.FullName);
}

MessageBox.Show(builder.ToString());

One thing to note here is that, this list may not be exactly equal to the the list of references in the Solution Explorer of VS. There are numerous reasons for this, but the main reason is that, even though you add references to a project, they won't be used in your code. Those assemblies will not be referenced or loaded in run time, hence they won't be listed.

Hope this helps :) Regards
 
Share this answer
 
v2
Here is another example for you

C#
Assembly a = Assembly.LoadFrom("c:\\COPYPROT.exe");
           Type[] types = a.GetTypes();
           foreach (Type typ in types)
           {
               object obj;
               if (typ.Name.ToUpper() == "READENCRYPTION")
               {
                   obj = Activator.CreateInstance(typ);
                   MethodInfo mi = typ.GetMethod("EncryptFile");
                   mi.Invoke(obj, new object[] { (string)"1", (string)"2", (string)"0408" });
               }
           }


Here EncryptFile method have 3 parameters
 
Share this answer
 
See here This Might Help

http://forums.asp.net/t/995709.aspx/1[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900