Dynamically list all System types in VB.Net

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.
 
R

rowe_newsgroups

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
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top