COBCH1623 error when attach method

This line of code gives the error "COBCH1623: Anonymous method or method group cannot be cast to type DevExpress.XtraPrinting.CreateAreaEventHander.":

ATTACH METHOD link__CreateReportHeaderArea to link::CreateReportHeaderArea

This is the C# code that I'm converting to Visual COBOL:

      private void btnPrint_Click(object sender, EventArgs e)
            IPrintable component = gridControl1;
            PrintableComponentLinkBase link = new PrintableComponentLinkBase()
                PrintingSystemBase = new PrintingSystemBase(),
                Component = component,
            link.CreateReportHeaderArea = link_CreateReportHeaderArea;

        private void link_CreateReportHeaderArea(object sender,
        CreateAreaEventArgs e)
            string reportHeader = "Categories Report";
            e.Graph.StringFormat = new BrickStringFormat(StringAlignment.Center);
            e.Graph.Font = new Font("Tahoma", 14, FontStyle.Bold);
            RectangleF rec = new RectangleF(0, 0, e.Graph.ClientPageSize.Width, 50);
            e.Graph.DrawString(reportHeader, Color.Black, rec, BorderSide.None);

I don't get the error in C#, just COBOL, and I am not able to subscribe to the CreateReportHeaderArea event.  Any ideas on how to get this working?


  • Hi Phil,

    What does the method signature for link__CreateReportHeaderArea  look like in COBOL?

  •       method-id link_CreateReportHeaderArea final private.

          procedure division using by value sender as object e as type CreateAreaEventArgs.


          end method.

    Intellisense shows me the error even if I have this method commented out.

  • Is it just a typo that you have two consecutive underscores in the name in the ATTACH statement or is that the actual problem?


  • Here is the COBOL code I wrote for subscribing to the event:

       $set ilusing"DevExpress.XtraPrinting"

       $set ilusing"DevExpress.XtraPrinting.Links"

       $set ilusing"DevExpress.XtraPrintingLinks"




        method-id btnPrint_Click final private.

          local-storage section.

            01  link                                       type PrintableComponentLinkBase.

            01  PrintingSystemBase        type PrintingSystemBase.

            01  component                         type IPrintable.

          procedure division using by value sender as object e as type System.EventArgs.

              set component to gridControl1

              set link to new type PrintableComponentLinkBase.

              set PrintingSystemBase to new type PrintingSystemBase.

              set Component to component.

              ATTACH METHOD link__CreateReportHeaderArea to link::CreateReportHeaderArea

          end method.

  • I did have an extra underscore in my code but after removing it I still get the COBCH1623 error.

  • Please open up a support incident with Customer Care for this as we will most likely require a cutdown example.