簡體   English   中英

c#application:如何查看加載的程序集

[英]c# application: how to view the loaded assemblies

depends.exe工具可以遍歷可執行文件所依賴的所有dll,但是如果在運行時動態地由Assembly類加載DLL,我如何才能看到已經加載的DLL(程序集)?

作為快照:

AppDomain.CurrentDomain.GetAssemblies()

當它們發生時:

AppDomain.CurrentDomain.AssemblyLoad

就像是:

static void Main()
{
    AppDomain.CurrentDomain.AssemblyLoad += AssemblyLoad;
    LogCurrent("before");
    AnotherMethod();
    LogCurrent("after");
}
static void AnotherMethod()
{
    // to force stuff to happen
    new System.Data.SqlClient.SqlCommand().Dispose(); 
}
static void LogCurrent(string caption)
{
    foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
    {
        Console.WriteLine(caption + ": " + asm.FullName);
    }
}

static void AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
    Console.WriteLine("Loaded: " + args.LoadedAssembly.FullName);
}

假設你沒有搞亂AppDomains:

AppDomain.CurrentDomain.GetAssemblies();

你說你在尋找外部工具嗎? 嘗試使用SOS調試擴展的WinDbg; http://msdn.microsoft.com/en-us/library/bb190764.aspx

還有其他工具可能更容易使用,提供相同級別的詳細信息。 我認為JetBrains的人有一個(Resharper)

fuslogw可以幫助解決這個問題,它有一個監視所有程序集綁定的選項http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM