【问题标题】:Problem setting class properties问题设置类属性
【发布时间】:2010-03-10 08:03:51
【问题描述】:

我在 ; 处不断收到 null 异常。以下。 ApiUsername 和 ApiPassword 有值,所以我不明白我只是设置错了还是什么。 Credentials 属性是某种类型,它具有需要设置的 Username 和 Password 属性。

所以我定义了自动属性: 公共 CustomSecurityHeaderType SoapCallCredentials { 获取;私人套装; }

然后,每当遇到此问题时,我都会收到一个 null 异常并且无法弄清楚原因。

private void SetApiCredentials()
{
    SoapCallCredentials = new CustomSecurityHeaderType
    {
        Credentials = 
        {
            Username = PayPalConfig.CurrentConfiguration.ApiUserName,
            Password = PayPalConfig.CurrentConfiguration.ApiPassword
        }
    };

    UrlEndPoint = PayPalConfig.CurrentConfiguration.ExpressCheckoutSoapApiEndPoint;
}

【问题讨论】:

  • 您的凭据声明中是否缺少new?
  • 我是这么想的,但让我再试一次。

标签: c# properties


【解决方案1】:

我认为你需要一个新的....

Credentials = new WhatEverThisTypeIs()
{
    Username = PayPalConfig.CurrentConfiguration.ApiUserName,
    Password = PayPalConfig.CurrentConfiguration.ApiPassword
}

【讨论】:

    【解决方案2】:

    来自eBay API Example

    需要先实例化凭据,例如:

    Credentials = new UserIdPasswordType()
    

    【讨论】:

      猜你喜欢
      • 2018-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多