0

在某些 asp.net 网页上重定向时,远程服务器上出现错误。

在日志文件中:

 <error date="2013-01-25T18:40:09" module="E24PublicPortal" login="-">
    <message>-</message>
    <exception>
      <Message Type="System.Web.HttpUnhandledException">Exception of type 'System.Web.HttpUnhandledException' was thrown.</Message>
      <InnerMessage Type="System.NullReferenceException">Object reference not set to an instance of an object.</InnerMessage>
      <Source>System.WebBoolean HandleError(System.Exception)</Source>
      <StackTrace>   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.vehicleinsurancepayment_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\2babcf5b\7311d315\App_Web_kvw1yfpt.2.cs:line 0
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)</StackTrace>
    </exception>
  </error>
  <error date="2013-01-25T18:40:09" module="E24PublicPortal" login="-">
    <message>-</message>
    <exception>
      <Message Type="System.NullReferenceException">Object reference not set to an instance of an object.</Message>
      <Source>koduLibsInt32 GetDRInt(System.Data.DataRow, System.String)</Source>
      <StackTrace>   at kodu.Libs.Utils.GetDRInt(DataRow row, String name)
   at kodu.Libs.DBFile.FillFromDataRow(DBFile file, DataRow rowFile)
   at kodu.Libs.DBFile.Load(Int32 kind, Int32 type, Int32 channelId, Int32 langId)
   at kodu.Libs.EmailTemplate.Load()
   at kodu.Portal.VehicleInsurancePayment.GetEmailText(PolicyOrder po, EmailTemplates template)
   at kodu.Portal.VehicleInsurancePayment.SendPaymentFailEmail()
   at kodu.Portal.VehicleInsurancePayment.Page_Load(Object sender, EventArgs e)
   at kodu.Portal.Code.E24Page.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)</StackTrace>
    </exception>
  </error>

在本地机器上它工作得很好。如果我从 temp 中删除 App_Web_kvw1yfpt.2.cs,也会不断收到错误消息。有什么建议么 ?

谢谢

Kodu.Libs.Utils.GetDRInt(..) 的代码:

public static int GetDRInt(DataRow row, string name)
        {
            return row[name] != DBNull.Value ? (int)row[name] : -1;
        }
4

1 回答 1

0

我将函数设为:

public static int GetDRInt(DataRow row, string name)
{
    Debug.Assert(name != null, "Name must have a value");

    if(row == null || row[name] == null || row[name] == DBNull.Value)
       return -1
    else
       return (int)row[name];
}

并检查所有可能的空案例。

于 2013-01-25T17:19:50.663 回答