Skip to main content



No record found.

Finance forum

'main' denotes a method, and cannot be reused in this context

Posted on by 570

I am new in D365 development..

i am   learning from book named (cookbook) , there is topic about creating dialog using RunBase Class .

when applying this topic gave me an error 


I copied the class to another class but same error 

Here my code

class MyDialog extends RunBase
    /// Runs the class with the specified arguments.
    /// The specified arguments.
    public static void main(Args _args)
        DialogField     fieldAccount,fieldName,fieldGroup,fieldCurrency,fieldPaymTermId,fieldPaymMode;
        CustName        CustName;
        CustGroupId     custGroupId;
        CurrencyCode    currencyCode;
        CustPaymTermId  PaymTermId;
        CustPaymMode    PaymMode;

    public container pack()
        return conNull();

    public boolean unpack(container _packedClass)
        return true;

    Object dialog()
        Dialog          dialog;
        DialogGroup     groupCustomer,groupPayment;
        DialogField     fieldAccount,fieldName,fieldGroup,fieldCurrency,fieldPaymTermId,fieldPaymMode;
        dialog = super();
        dialog.caption("Customer information");

        fieldAccount    = dialog.addField(extendedTypeStr(CustVendAC),"Customer informations");
        fieldName       = dialog.addField(extendedTypeStr(CustName),"Customer name");


        groupCustomer   = dialog.addGroup("Setup");
        fieldGroup      = dialog.addField(extendedTypeStr(CustGroupId),"Customer group Id");
        fieldCurrency   = dialog.addField(extendedTypeStr(CurrencyCode),"Customer group Id");

        groupPayment        = dialog.addGroup("Payment");
        fieldPaymTermId     = dialog.addField(extendedTypeStr(CustPaymTermId));
        fieldPaymMode       = dialog.addField(extendedTypeStr(CustPaymMode));

        return dialog;

    public static void main(Args _arge)
        MyDialog myDialog = new MyDialog();


My reference packages are : Application common - Application  Foundation - Application  Platform - Application  Suite - Calendar - Contact Person - Currency - Dimension - Directory - and Ledger .

Thank you in advance .   

  • Bala Chandra Profile Picture
    Bala Chandra 355 on at
    RE: 'main' denotes a method, and cannot be reused in this context


    Remove the first main method where only variables declared.

    There should be only one main method.

  • Ismail Mohamed Profile Picture
    Ismail Mohamed 570 on at
    RE: 'main' denotes a method, and cannot be reused in this context

    Sorry the error was there is 2 main methods

    sorry and thanks

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans