在最近的壓力和容量測試中,我們意識到30分鐘後,所有用途都會從網站斷開連接。事件記錄後,我們注意到應用程序池崩潰。做一些谷歌調查,顯然在大多數原因這是由於未處理的例外。IIS6應用程序池崩潰
所以當應用程序崩潰,顯示以下異常詳細信息:
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中拋出新的異常...這看起來不正確?如果在此時拋出這個錯誤,誰和什麼會處理這個錯誤?
OKay我可以看到,它不會真的提出一個新的frameworkException,因爲它將打破「FuseFarm.FrameworkException」的情況......但仍然不知道如何解決這個問題。 – FaNIX
異常在需要跨AppDomain邊界時序列化。運行時正試圖爲您序列化它。由於這個原因,所有異常都必須實現'ISerializable'和一個序列化構造器。 – vcsjones
爲什麼甚至在檢查之前已經使用了對象的成員:if(currentException!= null)?無論如何? –