次のコードを使用して、AIF=(Application Integration Framework) を使用して AX 2012 =(Microsoft Dynamics AX) の顧客レコードの複数の住所をインポートしています。2 つの住所を持つ顧客レコードを使用して、このコードをテストしています。コードが最初に実行されるとき (最初のループ) は問題なく実行されますが、2 回目のラウンドでは失敗し、範囲外の配列エラーが発生します。以下のコードを見て、このエラーの原因について何か提案はありますか?
index = 0;
AxdEntity_DirPartyPostalAddressView[] array = new AxdEntity_DirPartyPostalAddressView[index];
foreach (DataRow row2 in row.GetChildRows("HdrLine"))
{
AxdEntity_DirPartyPostalAddressView address =
new AxdEntity_DirPartyPostalAddressView
{
LocationName = row2["AXDirPartyPostalAddress_LocationName"].ToString(),
Street = row2["AXDirPartyPostalAddress_Street"].ToString(),
City = row2["AXDirPartyPostalAddress_City"].ToString(),
State = row2["AXDirPartyPostalAddress_State"].ToString(),
CountryRegionId = row2["AXDirPartyPostalAddress_Country"].ToString(),
ZipCode = row2["AXDirPartyPostalAddress_zipcode"].ToString(),
Roles = row2["AXDirPartyPostalAddress_AddRoles"].ToString()
};
Array.Resize<AxdEntity_DirPartyPostalAddressView>(ref array, index + 1);
array[index] = address;
custTable.DirParty[index].DirPartyPostalAddressView =
new AxdEntity_DirPartyPostalAddressView [] { array[index] };
index++;
}