c# - 仅在运行时才实例化其他类的 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()
{
}
继承有问题吗?...还是构造函数?或者为什么不能实例化这个类?由于智能感知不会显示任何错误。
谢谢您的帮助。
解决方案
推荐阅读
- python - 将@Risk 中的 Log Normal 和 Log Normal 截断模拟转换为 Python
- excel - 将单元格引用为索引的公式不起作用
- azure - 为什么 Azure Cosmos DB 需要这么长时间才能删除?
- jquery - 如何遍历按对象属性排序的对象数组?
- c++ - ESP8266 不响应 AT 命令
- ruby-on-rails - 如何使用表单在数据库中添加列?
- mongodb - 无法在 Mongo Explorer 中添加服务器(Atlas 集群)
- ios - 谷歌 GMSGeocoder 总是给我空子位置
- parsing - Haskell Parsec、MegaParsec 或 Happy 的简单 C 语法
- python - Python openpyxl数据框数据写入excel并清除工作表内容