Programmatically Crawl a DLL's Namespacec

J

jwgoerlich

Hello,

In Visual Studio, one can add in a DLL as a reference. Then, using
Object Browser, one can open and browse thru the DLL's namespace and
look at its objects and functions.

Is there a way to do this programmatically? That is, to point to a
specific DLL and return its namespace as a string?

Thanks in advance,

J Wolfgang Goerlich
 
C

Chris Dunaway

In Visual Studio, one can add in a DLL as a reference. Then, using
Object Browser, one can open and browse thru the DLL's namespace and
look at its objects and functions.

Is there a way to do this programmatically? That is, to point to a
specific DLL and return its namespace as a string?

Imports System.Reflection

Dim asm As [Assembly] = [Assembly].LoadFile("filename.dll")

For Each t As System.Type In asm.GetTypes()
MsgBox(t.Name)
Next

This should give you a push in the right direction.
 
G

GhostInAK

Hello Chris,

In addition to Chris's comments... DLLs do not have a namespace. An assembly
can participate in one or more namespaces. However a single namespace is
not constrained to a single assembly.

Also, I would suggest loading the assembly into it's own AppDomain.. AppDomains
can be unloaded. Individual assembies can not.

-Boo
In Visual Studio, one can add in a DLL as a reference. Then, using
Object Browser, one can open and browse thru the DLL's namespace and
look at its objects and functions.

Is there a way to do this programmatically? That is, to point to a
specific DLL and return its namespace as a string?
Imports System.Reflection

Dim asm As [Assembly] = [Assembly].LoadFile("filename.dll")

For Each t As System.Type In asm.GetTypes()
MsgBox(t.Name)
Next
This should give you a push in the right direction.
 
J

jwgoerlich

Alright, I have [Assembly].LoadFile("filename.dll") working. Have not
yet figured out how to do the same in AppDomain, that will come.

Now, Assembly.LoadFile works for .Net Framework DLLs. But, this does
not work for other Win32 DLLs. Netapi32, for instance, which I know
contains the DsGetDcName command. When I try to load it as an Assembly,
I get:

System.BadImageFormatException: An attempt was made to load a program
with an incorrect format.

Any suggestions?

J Wolfgang Goerlich
 
M

Mudhead

If maMatch.Groups("BigGroup1").Success Then
value1 = maMatch.Groups("value1").ToString
value2 = maMatch.Groups("value2").ToString
Debug.WriteLine(value1)
Debug.WriteLine(value2)
ElseIf maMatch.Groups("BigGroup2").Success Then
value1 = maMatch.Groups("value1").ToString
Debug.WriteLine(value1)
End If
 
G

GhostInAK

Hello (e-mail address removed),

Native Win32 dlls will not ever contain .Net namespaces. In fact, there
is no concept of a namespace at all in native dlls.

If you want to interrogate native dlls look at the Win32 functions: LoadLibrary,
FreeLibrary, and their cohorts.

-Boo
 
C

Chris Dunaway

Mudhead said:
If maMatch.Groups("BigGroup1").Success Then
value1 = maMatch.Groups("value1").ToString
value2 = maMatch.Groups("value2").ToString
Debug.WriteLine(value1)
Debug.WriteLine(value2)
ElseIf maMatch.Groups("BigGroup2").Success Then
value1 = maMatch.Groups("value1").ToString
Debug.WriteLine(value1)
End If

Please don't hijack the thread to ask your own question. This question
should be posted in its own thread.
 

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