Array Problems in C#

Hi all,

I was trying to call a natural sub program (which has some array parameters) from C# . Every time I call the subprogram - my application crashes and shows the following error :

Exception of type ‘SoftwareAG.EntireX.NETWrapper.Runtime.XException’ was thrown

I am giving my Natural IDL below

Program ‘X_HEADS’ Is
Define Data Parameter
1 HEAD_CODE (N2/99)
1 HEAD_NAME (A60/99)
1 HEAD_ACT (A1/99)
End-Define

I changed the parameters in My Workbench only out

Program ‘X_HEADS’ Is
Define Data Parameter
1 HEAD_CODE (N2/99) Out

	1 HEAD_NAME 	(A60/99) 	Out

	1 HEAD_ACT 	(A1/99) 	Out

End-Define

My C# Stab is given below

[color=“blue”]#region * * * P L E A S E D O N O T M O D I F Y * * *
/***************************************************************************
** Module name : x_heads.cs
** Description : Client Stub File for .NET (7.2.1.50)
**
** * * * P L E A S E D O N O T M O D I F Y * * *
**
** Author : Generated by Software AG EntireX IDL Compiler
** Template : csharp_client.tpl for C#
** Platform : .NET-able Platforms
** Usage :
*/
#endregion
#region parameters
/

** IDL File : x_heads
** Broker : ETB175
** Service : RPC/SRV1/CALLNAT
***************************************************************************/
#endregion
#region required namespaces
using System;
using System.Text;
using System.Runtime.InteropServices;
using SoftwareAG.EntireX.NETWrapper.Runtime;
#endregion

#region AssemblyInfo
#if USE_ASSEMBLY_INFO
using System.Reflection ;
[assembly: AssemblyTitle(“EntireX .NET Wrapper Client”)]
[assembly: AssemblyDescription(“EntireX .NET Wrapper Client”)]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany(“Software AG”)]
[assembly: AssemblyProduct(“EntireX Communicator”)]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion(“1.0.*”)]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
#endif
#endregion

namespace Test.Lib.x_heads
{
[EntireXVersion(“7.2.1.50”)]
[Library(“ENTIRE_X”)]
[Broker(“ETB175”)]
[Service(“RPC/SRV1/CALLNAT”)]
public class ENTIRE_X : ServiceHolder
{
#region Constructor(s) etc for LIBRARY ‘ENTIRE_X’

public ENTIRE_X() : base() {}
public ENTIRE_X(Broker broker) : base ( broker ) {}
public ENTIRE_X(Service service) : base ( service ) {}

#endregion
#region Method/Function for LIBRARY ‘ENTIRE_X’ PROGRAM ‘X_HEADS’

[Program("X_HEADS")]
public void X_HEADS(
  [SendAs(IdlType.N, preDecimal=2, postDecimal=0, Dim=99f)][Out] out decimal[] HEAD_CODE,
  [SendAs(IdlType.A, Length=60f, Dim=99f, Trim=true)][Out] out string[] HEAD_NAME,
  [SendAs(IdlType.A1, Length=1f, Dim=99f)][Out] out char[] HEAD_ACT
)


{
  HEAD_CODE = new decimal[99];
  HEAD_NAME = new string[99] ;
  HEAD_ACT = new char[99] ;
  service.Send
   (
    this.GetType().GetMethod("X_HEADS"),
    HEAD_CODE,
    HEAD_NAME,
    HEAD_ACT
  );
}

#endregion
}
}

[/color]

My Client Application code is given below

        Test.Lib.x_heads.ENTIRE_X et = new Test.Lib.x_heads.ENTIRE_X();

        decimal[] a = new decimal[99];
        string[] b = new string[99];
        char[] c = new char[99];
       et.X_HEADS(out a, out b, out c);
       foreach (String  y in b)
           Console.WriteLine(y);

       
        Console.ReadLine();

I have been trying to make use of arrays of natural for a long time in .Net. however, I was never successful.

I would really appreciate if there is anyone to assist me. Other issue is it possible to consume a collection of class from natural to C# ?

looking forward for reply…

Moshtaq
Consultant, Government of Swaziland.

Have you tried putting the client call in a try/catch block to trap the actual error code and message?

http://servline24.softwareag.com/SecuredServices/document/java/exx72150/rpc_dnet/reference.htm#XException

Have you turned on the TRACE in the Natural RPC Server to see if the call is reaching the server?

http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat424mf/rpc/oper.htm#oper_Defining_the_Trace_File

Hi diglus,

I did run try - and tracing problems . but I could not trace anything at Natural. However, in my C# tracing I found - the application crashes when it fetching data.

in this application, I have 46 records to get from mainframe - however, in the array, our mainframe programmers had created 99 dimension at Natural side. Interestingly, I found in C#, at 46th record application crashes.

Does it means - EntireX does not support a bigger container of arrays ? or How can I set up unbound array at the natural and receive in C#.

Just to know - does EntireX support object level communication - for example if I have a collection of classes in the Natural - can I get same in C#.

You are reporting an EntireX Wrapper exception but have not indicated what the error is. Simply stating that it crashes is not helpful. What are the Xception’s errorCode and Message values?

Are you using TRACE=3 on the Natural RPC Server? If so, it will show the actual data blocks being transferred and allow you to verify that the right data types are being put in the corresponding data elements.

Mainframe Natural does not support classes, so there is no concept of including them in EntireX.