Dynamically list all System types in VB.Net

  • Thread starter Thread starter Joh
  • Start date Start date
J

Joh

Is there a way to dynamically list all System types that exist in
VB.Net? I.e. I'd like to list all types in the System namespace
programatically.
 
Is there a way to dynamically list all System types that exist in
VB.Net? I.e. I'd like to list all types in the System namespace
programatically.

I'm no expert on reflection, but I think you can load the System.dll
and use assembly.GetTypes to retrieve them. Here's a simple Console
App to demonstrate:

//////////////////////
Imports System.Reflection

Module Module1

Sub Main()
Dim assembly As Assembly = assembly.LoadFile("C:\Windows
\Microsoft.NET\Framework\v2.0.50727\System.dll")

For Each t As Type In assembly.GetTypes()
Console.WriteLine(t.ToString())
Next

Console.Read()
End Sub

End Module
//////////////////////

Thanks,

Seth Rowe
 
Is there a way to dynamically list all System types that exist in
VB.Net? I.e. I'd like to list all types in the System namespace
programatically.

Seth is right about the general idea to do this, ie to use Reflection
and call Assembly.GetTypes etc.

But you have to keep in mind that any assembly can add types to a
namespace. The System namespace isn't restricted to the System.dll
assembly (or any other). So you have to decide which assemblies you
want to look at.


Mattias
 
Back
Top