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)

DLL error - Clr Interop Marshal: Unsupported type.

(0) ShareShare
ReportReport
Posted on by

7Hi guys,

I was trying to call the dll from dynamics ax to pass string array value and processing it. Please find the below code inside the dll, when I was calling from dynamics ax I am getting error (Clr Interop Marshal: Unsupported type) in last line of the below code (SOAP client).If I remove the last line system works fine

ResponseItemMaster resItem = new ResponseItemMaster();
ItemMaster itemMaster = new ItemMaster();
ItemsHospital hospital = new ItemsHospital();
ItemsHospitalItem hospitalItem = new ItemsHospitalItem();
MasterSettingClient client = new MasterSettingClient();

Please find the below x++ code.

SCMServiceIntegration.Class1   scmServiceIntegration   =   new SCMServiceIntegration.Class1();
    System.String[]   itemMaster    =   new System.String[7]();
    InteropPermission       permission  =   new InteropPermission(InteropKind::DllInterop);
    ;
    permission.assert();
    try
    {
        itemmaster.SetValue("test2",0);
        itemMaster.SetValue("test1Description",1);
        itemMaster.SetValue("TAB",2);
        itemMaster.SetValue("testName",3);
        itemMaster.SetValue("add",4);
        itemMaster.SetValue("31080001",5);
        itemMaster.SetValue("DA01",6);
        info(CLRInterop::getAnyTypeForObject(scmServiceIntegration.createItem(itemMaster)));
    }
    catch(Exception::CLRError)
    {
        info(CLRInterop::getLastException());
    }
    CodeAccessPermission::revertAssert();

Please guide me to resolve this.

*This post is locked for comments

I have the same question (0)
  • Vilmos Kintera Profile Picture
    46,149 on at

    CLRInterop type marshal error means you are trying to put apples to bananas.

    Check the return values of methods, and make sure you are using the same type before assigning them to a variable in AX/C#.

    [View:https://msdn.microsoft.com/en-us/library/cc584291.aspx:750:50]

    [View:https://community.dynamics.com/ax/f/33/t/218173:750:50]

    [View:https://community.dynamics.com/ax/f/33/t/239398:750:50]

  • Community Member Profile Picture
    on at

    Dear Vilmos,

    Thanks for the reply. Here I don't find any error on generic data types. I can able to pass arrays and return string values without any issues.

    While debug this error throws on the .NET line where initializing the object (MasterSettingClient client = new MasterSettingClient();) . this is an system generated Soap client class in .NET. Am I doing wrong way of initializing this class.

    Same code works on windows applications. if I put it in C# class project and convert it into a dll it doesn't working. please guide me

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