当我尝试在 Quickbooks Desktop 中创建新客户时出现错误。
错误:对象引用未设置为对象的实例。
当我尝试为客户创建地址时发生错误。
Customer qbdCustomer = new Customer();
qbdCustomer.Name = txtCompany.Text;
qbdCustomer.GivenName = txtFName.Text;
qbdCustomer.FamilyName = txtLName.Text;
qbdCustomer.Address[0].Line1 = txtAddress.Text;
qbdCustomer.Address[0].Line2 = txtAddress2.Text;
qbdCustomer.Address[0].City = txtCity.Text;
qbdCustomer.Address[0].CountrySubDivisionCode = drpState.SelectedItem.Value;
qbdCustomer.Address[0].PostalCode = txtZip.Text;
qbdCustomer.Phone[0].FreeFormNumber = txtPhone.Text;
qbdCustomer.Email[0].Address = txtEmail.Text;
Customer customerAdded = (new DataServices(context)).Add(qbdCustomer);
就像我说的那样,当它到达第一个地址行时就会发生错误。Name、GivenName 和 FamilyName 字段有效,因此它必须与地址数组有关。我已经坚持了几天,任何帮助将不胜感激。