代码之家  ›  专栏  ›  技术社区  ›  willem

如何使应用程序池崩溃?

  •  15
  • willem  · 技术社区  · 14 年前

    我们的ASP.NET 2 Web应用程序处理异常非常优雅。我们在应用程序错误中捕获全局asax中的异常。从那里我们记录异常,并向用户显示一条友好的消息。

    但是,今天早上我们部署了最新版本的站点。它运行了半个小时没问题,但随后应用程序池崩溃了。在我们恢复前一版本之前,站点没有恢复。

    如何使应用程序池崩溃并跳过正常的异常处理程序?我试图复制这个问题,但目前还没有运气。


    更新 :我们找到了解决方案。我们的一页正在截屏另一页。但是URL配置不正确,页面最终被截屏 它本身 无限,从而导致堆栈溢出异常。

    4 回复  |  直到 14 年前
        1
  •  13
  •   Aristos    14 年前

    我看到的和“池崩溃”最常见的错误是循环调用。

    public string sMyText
    {
       get {return sMyText;}
       set {sMyText = value;}
    } 
    

    打电话给smytext…

        2
  •  11
  •   Rob Levine    14 年前

    为了做到这一点,您需要做的就是从 在请求上下文之外 .

    例如,在另一个线程上引发的某些异常应该这样做:

    protected void Page_Load(object sender, EventArgs e)
    {
       // Create a thread to throw an exception
       var thread = new Thread(() => { throw new ArgumentException(); });
    
       // Start the thread to throw the exception
       thread.Start();
    
       // Wait a short while to give the thread time to start and throw
       Thread.Sleep(50);
    }
    

    可以找到更多信息 here in the MS Knowledge Base

        3
  •  4
  •   BritishDeveloper    14 年前

    亚里士多德的回答是好的。我也看到过在页面生命周期中,当有人将overriden方法从OnInit更改为OnLoad而不更改基调用时,它也会在整个生命周期中循环:即

    protected override void OnLoad(EventArgs e)
    {
      //some other most likely rubbish code
      base.OnInit(e);
    }
    
        4
  •  1
  •   David M    14 年前

    你可以试着扔一个 ThreadAbortException .