2016-11-18 57 views
0
FlightClient.ConnectPoint_FlightClient f = new ConnectPoint_FlightClient(); 
     f.Open(); 
     CarrierCode[] code = new CarrierCode[2]; 
     code[0].AccessibleCarrierCode = "0M"; 

FlightClient是我引用名,當我試圖用「AccessibleCarrierCode」方法,我得到這個error.I認爲它的安全性,因爲,我有安全令牌我,但我不知道如何使用它..試圖訪問一個Web服務

類型的異常「System.NullReferenceException」發生在 App_Web_e1jujnbd.dll但在用戶代碼中沒有處理

其他信息:未將對象引用設置爲一個 對象的實例。

+0

更新對象是不能夠訪問web服務的問題,像下面@Damith' – Marcin

回答

2

您還沒有初始化數組項,默認爲null,當您訪問null對象的屬性時,它將會發生異常。做如下

CarrierCode[] code = new CarrierCode[2]; 
code[0] = new CarrierCode(); 
code[0].AccessibleCarrierCode = "0M"; 
//if you need to access code[1] then initialize it before access 

如果你有很多的項目,然後

for(int i = 0; i < code.Length; i++) 
{ 
    code[i] = new CarrierCode(); 
} 
//now you can set values of any item in the array 
+0

FlightClient.ConnectPoint_FlightClient F =新ConnectPoint_FlightClient說() ; f.Open(); CarrierCode [] code = new CarrierCode [2]; code [0] = new CarrierCode(); code [0] .AccessibleCarrierCode =「OM」; TransactionInfo infotran = new TransactionInfo(); infotran.CarrierCodes = code; RetrieveAirportRoutes rout = new RetrieveAirportRoutes(); rout.ClientIPAddress =「192.168.10.11」; rout.CarrierCodes = code; var vr = f.RetrieveAirportRoutes(rout); Response.Write(vr.Routes.Count());'我得到零爲什麼? –

+0

可能是如何執行該服務。抱歉,我無法讀懂您的想法,或者我無法訪問您的電腦,也不知道您撥打的服務。 – Damith

+0

我可以寄給你關於這個文件,請幫助我。我被困在這個這麼久.. –