Get Application Path of offending DLL from Exception
We currently have a simple Log class that can take 开发者_JAVA百科in an exception. In our business logic if we happen to need a try/catch around a specific set of code, we log the exception and then rethrow it. The problem is that our Log class is in a common dll and when it writes the log I want to be able to also grab the path of the offending code (e.g. "D:\application\libraries"). Is there a simple way to do this without always having to pass in the executing assembly path to the logger each time?
Edit: Forgot to mention we're using C# 4.0.
Have you tried with Assembly.GetCallingAssembly()
inside your log method?
精彩评论