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

Announcements

No record found.

News and Announcements icon
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 174

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
    174 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,222 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 653

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 463 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 308 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans