Assembly

  • Thread starter Thread starter Jeffrey
  • Start date Start date
J

Jeffrey

hello,


how do i get an assembly for a process which is not the own process.
and i also do not want to load a new assembly.


please no answers with Load, LoadFrom or GetExecutingAssembly.


jeff
 
Jeffrey said:
how do i get an assembly for a process which is not the own process.
and i also do not want to load a new assembly.

please no answers with Load, LoadFrom or GetExecutingAssembly.

Sorry, it's not very clear what you mean. What do you actually want to
do? What do you mean by "get an assembly"? Do you mean you want to know
which assemblies have been loaded into a process?
 
yes, i want to know which assemblies have been loaded into a process.
then i will get the instances of the assemblies.

a example. please don't care about the processid . the processid is not
the problem, i want the assemblies for a process given by processid and
i am looking how to write the function GetAssemblyfromPID(pid).



//pid =ProcessID
Assembly[] asm = GetAssemblyfromPID(pid)
 
Jeffrey said:
yes, i want to know which assemblies have been loaded into a process.
then i will get the instances of the assemblies.

Right. At least the problem is clear now - unfortunately, I don't know
the answer. I don't believe there's a .NET way of doing it - you'll
need to use interop, I suspect, to find out which DLLs have been
loaded, and then find out which of those DLLs are .NET assemblies.
 
If you want to know which assemblies are loaded in a certain process you
can just get the Modules from the Process by getting a handle of the process
itself.

System.Diagnostics.Process[] Processes = System.Diagnostics.Process.GetProcesses();
System.Diagnostics.Process aspnetProcess = null;
foreach(System.Diagnostics.Process process in Processes )
{
if(process.ProcessName.Equals("aspnet_wp"))
{
aspnetProcess = process;
break;
}
}
foreach(System.Diagnostics.ProcessModule module in aspnetProcess.Modules )
{
System.Diagnostics.Debug.WriteLine(module.FileName);
}


After that you have the path, so you can do whatever you want with them.
If you dont want to load them into the current appdomain you will have to
use AssemblyName.GetAssemblyName(...). But if it fails, it is not a .NET
assembly. There are more elegant ways of doing that but i am not sure what
you are working on.


Erick Sgarbi
 
Back
Top