我创建了一个名为'ProcessManipulator'的新控制台应用程序,并引用了一个名为“ CarLibrary.dll”的私有程序集(我在ProcessManipulator之前创建了它),然后通过将CarLibrary与ProcessManipulator关联起来添加了引用,并添加了using CarLibrary;
并开始在内部使用CarLibrary的类型。然后运行控制台应用程序
下面是我用来探查托管当前进程的每个模块的功能:
static void Main(string[] args)
{
Car c = new Car(); // Car type is from CarLibrary
c.Run();
Console.WriteLine("***** Enter PID of process to investigate *****");
Console.Write("PID: ");
string pID = Console.ReadLine();
int theProcID = int.Parse(pID);
EnumModsForPid(theProcID);
Console.ReadLine();
}
static void EnumModsForPid(int pID)
{
Process theProc = null;
try
{
theProc = Process.GetProcessById(pID);
}
catch (ArgumentException ex)
{
Console.WriteLine(ex.Message);
return;
}
Console.WriteLine("Here are the loaded modules for: {0}", theProc.ProcessName);
ProcessModuleCollection theMods = theProc.Modules;
foreach (ProcessModule pm in theMods)
{
string info = $"-> Mod Name: {pm.ModuleName}";
Console.WriteLine(info);
}
Console.WriteLine("************************************\n");
}
所以我键入了当前进程的ID(在任务管理器中检查ProcessManipulator的PID),令我惊讶的是,我没有看到CarLibrary.dll
,为什么它没有出现在列表中?