Object reference not set to an instance of an object.
Hej,jeg er endnu ikke så hård ud i VB.NET, men har alligevel kastet mig ud i at bruge E-conomics API.
Det betyder at jeg har en masse udfordringer med tydning af diverse fejlmeddelser i Visual Studio.
Den seneste er følgende "Object reference not set to an instance of an object."
Den bliver udskrevet i en tekstboks hvor jeg forsøger at udskrive resultatet.
Koden er som følger:
**************************
Imports Economic.Api.Client
Imports Economic.Api.Data
Imports Economic.Api.Exceptions
Imports Economic.Api
Public Class frmLog
Private Sub btnGetOrders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetOrders.Click
EcoConnect()
Try
'Connecting
Dim ConnectMessage2 As String = EcoConnect()
'Gets all accounts
Dim Accounts As IAccount() = wsEco.Account.GetAll()
If (Accounts.Length = 0) Then Throw New Exception("No accounts exists")
Me.txtOutput.Text += "Number of Accounts: " + Accounts.Length.ToString & vbCrLf
Dim accData As IAccountData() = wsEco.AccountData.GetDataArray(Accounts)
If (accData.Length = 0) Then Throw New Exception("No accountdata exists")
For Each ac As IAccountData In accData
Me.txtOutput.Text = ac.Number + " " + ac.Name + vbCrLf
Next
Catch ex As Exception
Me.txtOutput.Text = ex.Message
End Try
EcoDisconnect()
End Sub
End Class
**************************