繁体   English   中英

IIS6应用程序池崩溃

[英]IIS6 Application Pool Crash

在最近的压力和容量测试中,我们意识到30分钟后,所有使用都与网站断开了连接。 事件记录后,我们注意到应用程序池崩溃。 做一些谷歌调查,显然在大多数原因,这是由于未处理的异常。

因此,当应用程序崩溃时,将显示以下异常详细信息:

An unhandled exception occurred and the process was terminated.

Application ID: DefaultDomain

Process ID: 7852

Exception: System.Runtime.Serialization.SerializationException

Message: Type 'FuseFarm.FrameworkException' in Assembly 'FuseFarm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

StackTrace:    at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeObject(Object obj, MemoryStream stm)
   at System.AppDomain.Serialize(Object o)
   at System.AppDomain.MarshalObject(Object o)

我不知道为什么要尝试序列化FrameworkException,而且在代码中也看不到这样做的位置。 但是我确实看到了代码的几个部分

new FrameworkException(exData, "ContractComposition.SubmitContract");

被调用,但未被处理。 检查global.asax.cs之后,发生了以下情况:

protected void Application_Error(object sender, EventArgs e)
{
    ILog log = LogManager.GetLogger(typeof(Global));
    string environmentName = WebConfigurationManager.AppSettings["EnvironmentName"];
    if (!String.IsNullOrEmpty(environmentName) && (environmentName == "DEMO" || environmentName == "LIVE"))
    {
        Exception currentException = Server.GetLastError().GetBaseException();
        Session["errorMessage"] = currentException.Message;
        Session["errorSource"] = currentException.Source;
        Session["errorTrace"] = currentException.StackTrace;
        log.Error(currentException.Message, currentException);
        if (currentException != null)
        {
            Session["error"] = currentException.GetType().Name;
            switch (currentException.GetType().ToString())
            {
                case "System.ApplicationException":
                case "FuseFarm.FrameworkException":
                    break;
                default:
                    new FrameworkException(currentException.Message + "\n" + currentException.StackTrace, currentException.Source, currentException);
                    break;
            }

        }
        Server.Transfer("~/error.aspx");
    }
}

在Application_Error中引发新异常...这似乎不对吗? 如果此时抛出此错误,谁来处理?

这是Serializing FrameworkException因为它试图越过AppDomain边界。

遍历AppDomain的所有对象都必须序列化,并且例外没有什么不同。

当异常未正确实现序列化时,您可以将其视为错误

我不认为您的错误处理程序是问题的根源。 考虑到堆栈跟踪,很难说-全内存转储会产生更好的信息。

最好的选择是适当地使异常可序列化

这可能无法完全解决您的问题-归根结底,您仍然会抛出异常。 希望一旦更正后,您将看到问题的真正原因。

如果在Application_Error中引发异常,则您的应用程序池将崩溃,就像您看到的一样。 根据您显示的代码,我可以得出结论,该行中提到了错误记录器:

log.Error(currentException.Message, currentException);

正在尝试序列化传递给它的异常。 currentException最终为FuseFarm.FrameworkException类型FuseFarm.FrameworkException ,错误处理程序将在该行崩溃,并且您的应用程序池将关闭。

在这种情况下,您需要将FuseFarm.FrameworkException标记为Serializable ,更改记录器以不尝试序列化对象,或者将try / catch块放入Application_error处理程序中,并根据需要对这些异常执行其他操作应用程序池继续前进。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM