首页 > 解决方案 > 仅在运行时才实例化其他类的 asp webservice 中的错误

问题描述

我有一个基于网页的 asp.net 应用程序,现在我们尝试使用 angularjs 进行升级。

我有一个网络服务:

 [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));
    }

Angularjs 启动 $http 方法,当进入 web 服务时,在 visualstudio 中:

PaymentDALC paymentDALC = PaymentDALC();

转到 catch 语句,错误是:

“你调用的对象是空的。”

在这个 webmethod 上,我有其他可以访问的类。例如,可以访问 gpi.Classes.dbfunctions.UpdateApproveNames。类结构是:

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;

但另一个是:

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()
        {
        }

继承有问题吗?...还是构造函数?或者为什么不能实例化这个类?由于智能感知不会显示任何错误。

谢谢您的帮助。

标签: c#htmlangularjsweb-servicesasp.net-webpages

解决方案


推荐阅读