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

Error CLR object cannot be marshaled to Microsoft Dynamics anytype

(0) ShareShare
ReportReport
Posted on by 3,020

Hi all,

While calling c# code from AX, getting above mentioned error.

we are getting data from oracle db & passing to AX.

got this error for the field "attribute3", even tried with System.Convert::ToString()not worked.

Find the screenshot and please advise.

1464.XPP.PNG C_2300_.PNG

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    Hi Krishna,

    Could please confirm that attribute3 is not equal to "Null" ? Otherwise you need to check it explicitly before assignment.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Try to wrap the C# call into CLRInterop::getAnyTypeForObject(), then that return value could be assigned to an AX primitive/type.

  • krishna.rao@dax Profile Picture
    3,020 on at

    @ievgen:

    ATTRIBUTE1 ATTRIBUTE2              ATTRIBUTE3 ATTRIBUTE4                 PAYROLL_ID

    NULL             2017/07/29 00:00:00 NULL          PAYROLL_29-JUL-2017 162

    @Vilmos:

    could you please suggest or share any link how to do this with CLRInterop::getAnyTypeForObject()

    Thanks

  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at

    lmgtfy.com

    Wrap it around your C# call, then you could assign it to your local AX variable in X++. Just like in the documentation for the function.

  • Mea_ Profile Picture
    60,286 on at

    But what actually stops you from checking that its not null before doing assignment ?

  • krishna.rao@dax Profile Picture
    3,020 on at

    Hi ievgen,

    how to check whether it is  null in AX.

    if (!extRow.get_PAYROLLINTERFACEID())// is it correct.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    You already have the solution above, why do you want to complicate it by checking for null value for the C# return type?

    Converting it to AX anytype using the CLRInterop class will give you an AX null value for value assignment if it is empty, or the actual value if it has any provided.

  • Verified answer
    Mea_ Profile Picture
    60,286 on at
    if (ClrInterop::isNull(myObject))
    {
        ...
    }
  • krishna.rao@dax Profile Picture
    3,020 on at

    How to assign array buffer from C# to AX table buffer.

    You could find in very first reply (attachment)

    1. Here I am assigning Array field values to variables

    2. Assigning variable values to table fields. (table.Field1 = "variable";

    Is there is a  way to assign directly array buffer to AX table buffer?

    (like AXTable = ArrayBuffer).

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

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans