|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Programmatically Crawl a DLL's NamespacecHello,
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 jwgoerl***@gmail.com wrote:
> In Visual Studio, one can add in a DLL as a reference. Then, using Imports System.Reflection> 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? > 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. Excellent! Much obliged.
Chris Dunaway wrote: Show quoteHide quote > Imports System.Reflection > > Dim asm As [Assembly] = [Assembly].LoadFile("filename.dll") > > For Each t As System.Type In asm.GetTypes() > MsgBox(t.Name) > Next 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 Show quoteHide quote > jwgoerl***@gmail.com wrote: > >> 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. > 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 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 Mudhead wrote:
> If maMatch.Groups("BigGroup1").Success Then Please don't hijack the thread to ask your own question. This question> 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 should be posted in its own thread. Hello jwgoerl***@gmail.com,
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 Show quoteHide quote > 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 > |
|||||||||||||||||||||||