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 :
Microsoft Dynamics AX (Archived)

CLRObject static method invocation error

(0) ShareShare
ReportReport
Posted on by 916

Hello,

I created a runBaseBatch classe where i export data to csv file. It work fine on interactive mode. On the others side not work en batch mode.

TextIO.JPG

any help in this regard

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,961 Most Valuable Professional on at

    First of all, fix the way how you're testing your code. You claim it works fine in the interactive mode, but it the condition isInBatch() caused the code to be skipped, therefore you didn't test anything. Remove the condition, make sure that the class runs on server and try it again. Next time, use the debugger to make sure that the code you're trying to debug actually runs.

    If you reproduce the error, catch the CLRException and look at its type, message and so on. Knowing what error you get is the first step to fixing it.

    By the way, please make sure you set the version tag correctly (you had AX 2009 in the title and AX 2012 in the version tag).

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Please give readwrite permissoin to the file and give a try.

    Thanks,

    Chaitanya Golla

  • ALAhmed Profile Picture
    916 on at

    Hello Martin , i posted only a part of the code .No you can find all my code i updated the request

  • Martin Dráb Profile Picture
    237,961 Most Valuable Professional on at

    I see you still have two different pieces of logic, depending on whether the code runs in batch or not. Why? Maintaining and testing the same things twice looks like a waste of time to me.

    You probably don't realize that you can use common logic for both. It's exactly what you I would do.

    If you insist on having two different ways, you must learn how to debug batch jobs, because you make it impossible for yourself to debug it interactivelly (see Step-by-Step Checklist for Debugging Batch Jobs in Dynamics Ax). But I wouldn't bother; I would use the same logic.

    I also believe that you don't realize that your WinAPI code will run on client, while the batch will run on a batch server, i.e. a completely different computer. Also, it will use a different user (the AOS service account).

    And you try/catch clause doesn't cover all code. Fix it, catch the CLRException and look at it, as I told you before.

  • Community Member Profile Picture
    on at

    I have same problem.

    The code works on server side. When I'm trying to invoke this code:

    1. System.Array array;
    2. str sTmp = "<some data>";
    3. array = System.Convert::FromBase64String(sTmp);

    on line3 i get an error:

    ClrObject static method invocation error.

    I think the problem with CAS system.Also I don't know how to solve it.

    I tryied to use 

    1. // Enable CLR interop on a server method.
    2. new InteropPermission(InteropKind::ClrInterop).assert();

    but this don't work. Anybody solve this problem?

  • Martin Dráb Profile Picture
    237,961 Most Valuable Professional on at

    I don't dare guessing what the exception might be. Instead of guessing, I would catch the CLR exception look at its details, such as the InnerException.

    If the problem was in CAS, it would fail even before making the call. Your case looks different - FromBase64String() gets called but it throws an exception. And finding what exception it is was is the crucial step.

    The most likely explanation is that sTmp isn't actually a Base64 string.

  • Community Member Profile Picture
    on at

    I wrapped the code to try...catch construction and catch a detailed error. In my case, the Base64 string wasn't correct. I generated a Base64 string the app Notepad++ and generate a string without a padding symbol. I just added to the end of Base64 string the symbol '=' and solve my problem.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans