在自托管的控制台应用程序中使用ServiceStack Mini Profiler

7

在自托管的控制台应用程序中是否可以使用ServiceStack Mini Profiler?如果可以,我应该把分析器启用/禁用代码放在哪里?在ASP.NET托管的ServiceStack中,通常是在Application_BeginRequestApplication_EndRequest方法中。


1
当以自托管模式运行ServiceStack时,HttpContext.Current始终为空。看起来MiniProfiler依赖它。 - migajek
2个回答

0
你可以这样做:
namespace ConsoleApplication1 {
  class Program {
    static void Main(string[] args) {
      // enable here

      // your code

      // disable here
    }
  }
}

或者在构造函数和析构函数中这样写:

namespace ConsoleApplication1 {
  class Program {
    Program() {
      // enable here
    }

    ~Program(){
      // disable here
    }

    static void Main(string[] args) {
      // your code
    }
  }
}

你能提供更详细的实现吗?尝试在构造函数上使用profiler.start,在dispose上使用profiler.stop,但没有输出结果(就像Web中的js对话框)。 - Anton Hasan

0
public abstract class MyHostBase : AppSelfHostBase
{
    this.GlobalRequestFilters.Add(OnBeginOfRequest);
    this.GlobalResponseFilters.Add(OnEnfOfRequest);
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接