0

I have an asp.net application based with webpages and now we try to upgrade with angularjs.

I have a webservice :

 [WebMethod]
    public void UpdateUnapprovedNames(string nameId, string BU, string strToChecksum)
    { 
        //Update approved names
        string error = "";
        int newChecksum = 0;
        try
        {
            PaymentDALC paymentDALC = new PaymentDALC();
            string userId= (string)Session["USERID"];
            newChecksum = gpi.Classes.validation.getCheckSum(strToChecksum + "Y");
            var ds1 = gpi.Classes.dbfunctions.UpdateApprovedNames(nameId, newChecksum, userId, userId, BU);
            UpdateUnApprovedPaymentsForName(nameId, BU);
        }
        catch (Exception ex)
        {
            error = ex.Message;
        }

        Context.Response.Write(js.Serialize(error));
    }

And the Angularjs launch the $http method, and when enter into the webservice, in visualstudio the :

PaymentDALC paymentDALC = PaymentDALC();

go to the catch sentence and the error is:

"Object reference not set to an instance of an object."

On this webmethod I have other class that can Access.. for example the gpi.Classes.dbfunctions.UpdateApproveNames can be reached. the class construction it's:

using System;
using System.Text;
using System.Data;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Web;
using System.Collections;
using System.ServiceModel;
using System.Collections.Generic;
using Ace.GPI.Classes;
using Ace.GPI.Classe.ACHValidation;




namespace gpi.Classes
{
    /// <summary>
    /// Summary description for validation.
    /// </summary>
    public class validation
    {
        string b = "";
        public static bool accBool;
        public static bool bankBool;
        private const int seed = 33;

But the other is:

using System;
using System.Configuration;
using System.Collections;
using System.Data;
using System.Text;
using System.Collections.Specialized;
using ACE.ApplicationBlocks.DB2Data;
using IBM.Data.DB2;
using System.Web.Mail;
using System.Data.Odbc;
using System.Xml;
using System.Web;
using System.Data.OleDb;
using System.Linq;

namespace gpi
{

    /// <summary>
    /// The PaymentDALC performs all database access related to Payment and PaymentQueue
    /// </summary>
    public class PaymentDALC : BaseDALC
    {


        static string DB_ENCRYPTION_KEY = ((ConfigPortal)HttpContext.Current.Session["PortalConfiguration"]).DBEncryptionKey;//Def 730
        public PaymentDALC()
            : base()
        {
        }

It's some trouble with the inherits?... or the constructor? or why can't instanciate this class? Since the intellisense don't show any error.

Thank you for your help.

  • `((ConfigPortal)HttpContext.Current.Session["PortalConfiguration"]).DBEncryptionKey` seems suspect to me. If there's no PortalConfiguration object, this won't work. – ProgrammingLlama Jun 20 '18 at 02:22
  • I've find an answer. Since the other object uses the Session to obtain data, then the web method need to be declared as: [WebMethod(EnableSession = true)] – Miguel Juarez Jun 22 '18 at 04:06

0 Answers0