retreiving namespace using Reflection | Beginners

  • Thread starter Thread starter Erland
  • Start date Start date
E

Erland

Hi,

I want to retreive different namespaces available within an Assembly
using Reflection. Is this possible? Can i retreive a namespace within
an Assembly using " Type " ?

My question is how can we retreive a namespace from an Assembly? For
example, i can see different namespaces with " mscorlib" assembly then
how can retreive namespaces within mscorlib?
Pardon my ignorance and please enlighten me.
Thanks in advance.
-Erland
 
take a look here
http://msdn2.microsoft.com/en-us/library/system.reflection.assembly.gettypes.aspx

you can get name of returned types' FullName property (as you know it
will start with Namespace) you can perform custom parsing to get what
you need

this is the code for getting all types in executing assembly - you must
have windows forms applciation with TextBox called textBox1 (Multiline
property is set to true)
System.Reflection.Assembly asm = Assembly.GetExecutingAssembly();

Type[] types = asm.GetTypes();
for (int i = 0; i < types.GetLength(0); i++)
{
textBox1.Text = string.Format("{0}{1}{2}",
textBox1.Text, types.FullName, Environment.NewLine);

}

I hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com
 
Back
Top