Business and Technology Consulting Organization in Mumbai

Electronic Transformation Globally Technology Solution IT Consultancy Service Provider

Reflection in .net

use the namespace System.Reflection
Reflection is the feature in .Net, which enables developers to get some information about assembly/object at runtime. That information contains data of the class. It can get the names of the methods, properties, events, constructors of the class object.
Metdata information by using reflection
using System;
1:using System.Reflection;
2:
3:namespace ETG.Base.Applications.ETigers.Web.ETech.CSharp
4:{
5: public class ManifestMetadata
6: {
7: public ManifestMetadata()
8: {
9: //
10: // TODO: Add constructor logic here
11: //
12: }
13:
14:
15: public static void LoadAssemblyManifest()
16: {
17: Assembly objAsmb = Assembly.LoadFile(@"C:MyProj\\bin\\MyProj.dll");
18:
19: Console.WriteLine("\n Types");
20: Console.WriteLine("=====================");
21: Type[] Types = objAsmb.GetTypes();
22: foreach (Type oType in Types)
23: {
24: Console.WriteLine(oType.Name.ToString());
25: }
26:
27:
28: Console.WriteLine("\n Manifest");
29: Console.WriteLine("=====================");
30: string[] strManifest = objAsmb.GetManifestResourceNames();
31: foreach (string str in strManifest)
32: {
33: Console.WriteLine(str);
34: Console.WriteLine("------Manifest resource info start-------");
35: ManifestResourceInfo objMInfo = objAsmb.GetManifestResourceInfo(str);
36: Console.WriteLine(objMInfo.FileName);
37: Assembly refAsmb = objMInfo.ReferencedAssembly;
38: if (!object.Equals(refAsmb, null))
39: {
40: Console.WriteLine("Refference assembly name");
41: Console.WriteLine(refAsmb.FullName);
42: Console.WriteLine(refAsmb.Location);
43: }
44: Console.WriteLine(objMInfo.ResourceLocation);
45: Console.WriteLine("------Manifest resource info End-------");
46:
47: }
48: Console.WriteLine(objAsmb.FullName);
49: Console.Read();
50:
51: }
52: }
53:}
54:
Leave your comment.

Reduce your Dialy IT Cost, Consult with us
Stay healthy in recession

Advertisement
Sponsored by

HR Recruitment & Process Management System
Jewellery production process management software
Share
©2009 ETG Consultancy, All Rights Reserved Privacy Policy | Terms & Conditions
Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML