Skip to main content

[archive] Can I call a static C# method from AcuCOBOL ?

  • July 15, 2009
  • 3 replies
  • 0 views

[Migrated content. Thread originally posted on 14 July 2009]

Hi,
I have a question. Is it possible to call a static method in C# ? Obviously, when I code something like :

CREATE "@assembly"
NAMESPACE IS "MyNamespace"
CLASS-NAME IS "Myclass"
HANDLE IS hHandle.

MODIFY hHandle "MyMethod" (wsParm1, wsParms).

i get : "constructor on type 'MyNamespace.Myclass' not found" from AcuCOBOL v81. Is there a different syntax for static methods ? I can't find it in the documentation.

Thanks,
- Peter -

3 replies

[Migrated content. Thread originally posted on 14 July 2009]

Hi,
I have a question. Is it possible to call a static method in C# ? Obviously, when I code something like :

CREATE "@assembly"
NAMESPACE IS "MyNamespace"
CLASS-NAME IS "Myclass"
HANDLE IS hHandle.

MODIFY hHandle "MyMethod" (wsParm1, wsParms).

i get : "constructor on type 'MyNamespace.Myclass' not found" from AcuCOBOL v81. Is there a different syntax for static methods ? I can't find it in the documentation.

Thanks,
- Peter -
Unfortunately not, here is a quote from MSDN documentation on C# static methods:


    • A static constructor does not take access modifiers or have parameters.
    • A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
    • A static constructor cannot be called directly.
    • The user has no control on when the static constructor is executed in the program.
    • A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.
    • Static constructors are also useful when creating wrapper classes for unmanaged code, when the constructor can call the LoadLibrary method.
    Just to emphasize it, the restriction applies to any language, even C# apps using that object, not ACUCOBOL-GT exclusively.

[Migrated content. Thread originally posted on 14 July 2009]

Hi,
I have a question. Is it possible to call a static method in C# ? Obviously, when I code something like :

CREATE "@assembly"
NAMESPACE IS "MyNamespace"
CLASS-NAME IS "Myclass"
HANDLE IS hHandle.

MODIFY hHandle "MyMethod" (wsParm1, wsParms).

i get : "constructor on type 'MyNamespace.Myclass' not found" from AcuCOBOL v81. Is there a different syntax for static methods ? I can't find it in the documentation.

Thanks,
- Peter -
Oke, thanks, good to know that it is not supported. I will change my class to a regular one (that needs to be instantiated). That works like a charm.

[Migrated content. Thread originally posted on 14 July 2009]

Hi,
I have a question. Is it possible to call a static method in C# ? Obviously, when I code something like :

CREATE "@assembly"
NAMESPACE IS "MyNamespace"
CLASS-NAME IS "Myclass"
HANDLE IS hHandle.

MODIFY hHandle "MyMethod" (wsParm1, wsParms).

i get : "constructor on type 'MyNamespace.Myclass' not found" from AcuCOBOL v81. Is there a different syntax for static methods ? I can't find it in the documentation.

Thanks,
- Peter -
Oke, thanks, good to know that it is not supported. I will change my class to a regular one (that needs to be instantiated). That works like a charm.