Skip to main content

Posts

Showing posts from December, 2012

getting the list of class from dll in asp.net c# using Reflection

Reflection provides object(of type Type) that describe assemblies modules and types. so we can use  reflection to get the info about the assemblies i.e we can access  all types of objects in the dll.here I am going to demonstrate the use of Type and LoadFile to to get the name of the classes in the dll. demo code : using System; using System.Collections; using System.Reflection; namespace Zeewon.Tests {     public class GetClassInDll     {         public GetClassInDll()         {         }         //string dllname is the path of the dll //as LoadFile takes the absolute path the absolute path should be provided as parameter         public ArrayList GetClassName(string dllName)         {             Assembly assem = null;             try             {                 assem = Assembly.LoadFile(dllName);             }             catch (Exception ex)             {                 throw ex;             }             Type[] allType = assem.GetTypes();             ArrayList arrLis