2010-03-09 111 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()