web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Calling C# function in main class gives invalid token error

(0) ShareShare
ReportReport
Posted on by 172

Just like in topic. Why I can't use a C# function directly in main method? I can create a function inside my class and call from there the c# function without any problem.

I get Invalid token '(' exception.

class KSeF_createSessionToken
{
    SRM_EDI_KSeF.Helper helper = new SRM_EDI_KSeF.Helper();
    
    public static void main(Args _args)
    {
        KSeF_createSessionToken initSessionToken = new KSeF_createSessionToken();
        
        initSessionToken.helper.prepareInitToken(token, challenge, timestamp, xmlFileName);
        initSessionToken.helper.prepareInitToken();
        initSessionToken.helper.prepareInitToken("q","w","e","r");
        
    }

I have the same question (0)
  • nunomaia Profile Picture
    25 Moderator on at

    you can use.

    But where are declared token, challenge, timestamp, xmlFileName variables ?

  • RadekM Profile Picture
    172 on at

    In the same main method I cut out most code.

    All data is inside the main method and I try to call a c# library.

    It's just I don't understand why the error is invalid token in this case.

  • nunomaia Profile Picture
    25 Moderator on at

    I would say, it's a invalid value somewhere in you code.

    Take into consideration that var SRM_EDI_KSeF.Helper helper is an instance var and main is static    

  • Suggested answer
    Komi Siabi Profile Picture
    13,109 Most Valuable Professional on at

    Hello RadekM ,

    I believe your method prepareInitToken is static in your C# library.

    Kindly try this.

    SRM_EDI_KSeF.Helper::prepareInitToken(token, challenge, timestamp, xmlFileName);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans