【问题标题】:Find DLL name of code calling a function C#查找调用函数 C# 的代码的 DLL 名称
【发布时间】:2016-09-27 10:07:58
【问题描述】:

在我们所有项目中都包含的框架库中,我们有一个 Log 函数。

在框架中

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");
    }
}

有什么方法可以确定调用 Log.GenericLog 的 DLL 的名称吗?

【问题讨论】:

  • 异常对象返回所有信息,从哪里产生错误,可以使用堆栈跟踪显示错误的完整描述
  • Assembly.GetCallingAssembly().CodeBase ?
  • 我认为,您想要的要求可以通过Assembly Class 来解决。具体看一下这个方法。

标签: c# dll reflection


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-04
    • 2011-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多