0

Getting error on remote server while redirected on certain asp.net web page.

In log file :

 <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>

In local machine it works just fine. Also keep getting the error if i delete App_Web_kvw1yfpt.2.cs from temp. Any suggestions ?

Thanks

Code for Kodu.Libs.Utils.GetDRInt(..):

public static int GetDRInt(DataRow row, string name)
        {
            return row[name] != DBNull.Value ? (int)row[name] : -1;
        }
Joonas Püüa
  • 370
  • 3
  • 5
  • 18
  • Can you add the code for `kodu.Libs.Utils.GetDRInt(DataRow row, String name)`? – Shai Cohen Jan 25 '13 at 17:04
  • The local machine and server are aimed at the same database? – Andrew Walters Jan 25 '13 at 17:15
  • It looks like `row` itself is null. Although you are checking if a specific column in the row is null, if the row itself is null it will throw the `System.NullReferenceException` error. I see you are new to SO, so just FYI, if you add code to your question in repsonse to a comment, make sure to add your own comment with the poster's tag so he/she is informed of the update. Like so: @ShaiCohen. – Shai Cohen Jan 25 '13 at 17:16
  • oh dam, no they are not one is aimed to *_dev another to *_beta - didn't notice that. – Joonas Püüa Jan 25 '13 at 17:18
  • okei, thanks for tip . Will do it in future @ShaiCohen – Joonas Püüa Jan 25 '13 at 17:27

1 Answers1

0

I will make the function as:

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];
}

and check all the possible null cases.

Aristos
  • 66,005
  • 16
  • 114
  • 150
  • Okei thanks. Will update that accordingly. Will try to check some ideas for now, will let you know if I'm able to fix it or not. – Joonas Püüa Jan 25 '13 at 17:26
  • Repaired several methods (added more null checks) and was able to find real problem behind it (Missing values in Database). Thanks – Joonas Püüa Jan 25 '13 at 19:05