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)

CLR Object Error while Consuming Service in AX

(0) ShareShare
ReportReport
Posted on by 435

Hi there,

           i have created a Web Service in .Net which has two methods

1) This method returns the Employee name when you pass the Employee ID.

2) This methods will retrieve all the Employee ID's.

When i am trying to consume the service the first method is working fine, but the second method gives me error i.e:

"Object 'CLRObject' could not be created"

 


Here is the Job Code which i wrote to get all the IDs

static void om_testConsum_empIds(Args _args)
{
InteropPermission interopPermission = new InteropPermission(InteropKind::ClrInterop);
IISService.IISServiceReference1.MySqlServiceSoapClient _client;

System.Exception ex;
System.Array resutArray;
int empid;

interopPermission.assert();
try
{
_client = new IISService.IISServiceReference1.MySqlServiceSoapClient();

startLengthyOperation();
resutArray = _client.getEmployeeIDs();
endLengthyOperation();

empid = CLRInterop::getType(resutArray.GetValue(0));

info(strFmt(int2str(empid)));

}

catch(Exception::CLRError)
{
ex = CLRInterop::getLastException();
info(ex.ToString());
}

}

Can you please guide me how to consume the above method.

Thanks

Regards

*This post is locked for comments

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

    Which line of code is throwing the exception?

  • Mohammed Altaf Profile Picture
    435 on at

    Hi Martin,

    Thanks for the reply.

    this line

    empid = CLRInterop::getType(resutArray.GetValue(0));

    is throwing the exception.

    Regards

  • Martin Dráb Profile Picture
    239,634 Most Valuable Professional on at

    What's the point of your code? getType() takes a name of a type and returns a Type object. Trying to assign the object to an int variables makes no sense and I assume that getEmployeeIDs() return employee IDs and not type names.

    Don't you actually want empid = resutArray.GetValue(0)? (Assuming that resutArray is an array of int values.)

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 24

#2
Michel ROY Profile Picture

Michel ROY 14

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans