From System.Diagnostics.ProcessModule to System.Reflection.Module?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I'm trying to determine the classes loaded into a non-local process
running on a distant .NET server. On that distant server, I can get the list
of processes and iterating through that list I can get a
System.Diagnostics.ProcessModule instance for each process. But I can't
figure out how I can use the .NET framework to get the list of
System.Reflection.Module instances from a System.Diagnostics.ProcessModule
instance.

I believe this information is available via the Windows API, but I am not
(yet) a Windows API programmer.

Thanks for the help.
 
GlobalBruce said:
Hi. I'm trying to determine the classes loaded into a non-local process
running on a distant .NET server. On that distant server, I can get the
list
of processes and iterating through that list I can get a
System.Diagnostics.ProcessModule instance for each process. But I can't
figure out how I can use the .NET framework to get the list of
System.Reflection.Module instances from a System.Diagnostics.ProcessModule
instance.

I believe this information is available via the Windows API, but I am not
(yet) a Windows API programmer.

No, this information is not in the Windows API.

System.Diagnostics.ProcessModule corresponds to System.Reflection.Assembly
(A System.Reflection.Assembly is a container for one or more
System.Reflection.Module instances.)

So to get this information you need to load the assembly. You can use the
name of the ProcessModule to figure out the name of the assembly and load
it.

Dim mm As System.Diagnostics.ProcessModule
Dim a As System.Reflection.Assembly =
System.Reflection.Assembly.LoadFrom(mm.FileName)

Remember, you'll be unable to unload this assembly once it's loaded, so you
may want to do this in a new AppDomain.

David
 
Hi David --

Thanks for the reply. I have a follow-up question. The
System.Diagnostics.ProcessModule instance I have represents a process running
on a distant server. I want to know the classes running in that server's
ProcessModule instance, so I can browse them via Reflection to get some data.
If I create a System.Reflection.Assembly instance on my computer, how can I
load the classes from the files/GAC on the distant server?

Thanks for the information.

- Bruce
 
GlobalBruce said:
Hi David --

Thanks for the reply. I have a follow-up question. The
System.Diagnostics.ProcessModule instance I have represents a process
running
on a distant server. I want to know the classes running in that server's
ProcessModule instance, so I can browse them via Reflection to get some
data.
If I create a System.Reflection.Assembly instance on my computer, how can
I
load the classes from the files/GAC on the distant server?

Thanks for the information.

You'll have to access the file system of the remote computer. If you have
an administrator account, and no other connection to the server you can
access the administrative shares like

\\server\c$\someFolder\abc.dll

But this won't work if you already have an SMB session on that server unsing
a different account. That, plus there's no guaranee that the admin shares
exist, plus the need to locate and load dependant assemblies, etc, make it
pretty dicey that you can get this to work.

David
 
Thanks, David.

David Browne said:
You'll have to access the file system of the remote computer. If you have
an administrator account, and no other connection to the server you can
access the administrative shares like

\\server\c$\someFolder\abc.dll

But this won't work if you already have an SMB session on that server unsing
a different account. That, plus there's no guaranee that the admin shares
exist, plus the need to locate and load dependant assemblies, etc, make it
pretty dicey that you can get this to work.

David
 
Back
Top