2010-03-09 162 views
1

我不断收到null异常;下面。 ApiUsername & ApiPassword具有值,因此如果我只是将此设置为错误或什么,我不会打开。 Credentials属性是一种具有需要设置的用户名和密码属性的特定类型。问题设置类属性

所以我有自动propery定义: public CustomSecurityHeaderType SoapCallCredentials {get;私人设置; }

然后,每当这个命中,我得到一个空的异常,不知道为什么。

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

    UrlEndPoint = PayPalConfig.CurrentConfiguration.ExpressCheckoutSoapApiEndPoint; 
} 
+0

是否缺少你的证书声明中有'new'吗? – 2010-03-09 23:56:22

+0

我这么认为,但让我再试一次。 – PositiveGuy 2010-03-10 23:59:31

回答

4

我想你需要一个新的....

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

eBay API Example

证书需要先实例化,如:

Credentials = new UserIdPasswordType()