I need to pass array from Native Cobol to C# COM object. When I am passing only single string or number it's working. But with array I got error message: **Exception 65537 not trapped by the class oleexceptionmanager. Description: "Server defined OLE exception"
(80070057): The parameter is incorrect.
I think that I must somehow differently declare array in Cobol part?
Cobol code:
$SET DIRECTIVES (SBODBC.DIR) NSYMBOL"NATIONAL" $set ooctrl( p) identification division. program-id. pokus444. special-names. environment-name is environment-name environment-value is environment-value decimal-point is comma. class-control. ChkAccNum is class "$OLE$CheckAccountNumber.AccountNumbers". working-storage section. 01 ChkAccNumObj object reference. 01 accA. 05 acc pic x(34) occurs 100. 01 accR pic x(34). procedure division. main section. display "Zacatek programu" initialize accA accR move '1234567890' to acc(1) move '0987654321' to acc(2) invoke ChkAccNum "new" returning ChkAccNumObj invoke ChkAccNumObj "CheckAccount" using accA returning accR display accR exit .
C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace CheckAccountNumber
{
[Guid("A80930D1-080F-4B04-A2C3-B637428556D6")]
public interface IAccountNumbers
{
[DispId(1)]
string CheckAccount(string[] accounts);
}
[Guid("65A771A0-0DDE-440D-9A4F-C71CEAEE3DF6"),
ClassInterface(ClassInterfaceType.None)]
public class AccountNumbers : IAccountNumbers
{
public AccountNumbers()
{
}
public string CheckAccount(string[] accounts)
{
return accounts[1];
}
}
}