2016-09-27 63 views
0

在包含在我們所有項目中的框架庫中,我們有一個日誌函數。查找調用函數的代碼的DLL名稱C#

在框架

public static class Log 
{ 
    GenericLog(string msg){ string caller = GETDLLNAME //implementation} 
    GenericError(string msg){ string caller = GETDLLNAME //implementation} 
} 

在其他代碼

using Framework; 

public class foo 
{ 
    public string GenerateBar() 
    { 
     Log.GenericLog("FooBar"); 
    } 
} 

有什麼方法來確定DLL的名字來自Log.GenericLog叫?

+0

異常對象返回所有的信息,從那裏產生的錯誤,你可以使用堆棧跟蹤來顯示錯誤的完整描述 –

+0

'Assembly.GetCallingAssembly()。CodeBase'? –

+0

我認爲,您希望的要求可以通過[Assembly Class]來解決(https://msdn.microsoft.com/de-de/library/system.reflection.assembly.getentryassembly(v = vs.110).aspx )。具體看看這個方法。 –

回答