2013-05-06 53 views
7

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

+1

运行在自托管模式ServiceStack时,HttpContext.Current总是空值。看来MiniProfiler依赖它。 – migajek 2014-01-07 12:20:47

回答

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 
    } 
    } 
} 
+0

可以把你更详细的实施,尝试使用ctor和profiler.stop上的配置文件,但没有结果(js对话框在web中) – 2013-06-05 02:05:33

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