开发者

Get Application Path of offending DLL from Exception

开发者 https://www.devze.com 2023-01-21 14:12 出处:网络
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 re

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消