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)

Class running batch consuming a webservice (Ax 2012)

(0) ShareShare
ReportReport
Posted on by 150

Hi

I have a class (extends RunBaseBatch) syncing data between Ax and one of our own old system.

We have designed it by letting Ax consuming a webservice from the old system via a Visual Studio Project (generating the model to Ax). This is, as i understand, the classic way to do it in Ax 2012.

If I design a Job to use the class, it all runs as intended if I run it by hand.

If I set up a Batch job, it throws an exception as soon as it starts to consume the webservice. It runs perfectly if no webservice is consumed. I have compiled full CIL, so that shouldn't be the problem.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an...

Sample of code:

ClrObject clientType;
TestWCFProxy.CMSWCFProxy                                        _client;

...

new InteropPermission(InteropKind::ClrInterop).assert();

...

clientType = CLRInterop::getType("TestWCFProxy.CMSWCFProxy");
_client = AifUtil::CreateServiceClient(clientType);

Have you got any ideas of what I'm doing wrong? Is there any way to debug the Class running af Batch job?

Best regards
Lars Vistrup Skov

*This post is locked for comments

I have the same question (0)
  • Lars Vistrup Skov Profile Picture
    150 on at

    Hi

    I have an update for this. It seems like Ax can't find the assembly/dll when running server side/batch.

    The code breaks when I reach this line:

    clientType = CLRInterop::getType("TestWCFProxy.CMSWCFProxy");

    Test sync ran: Microsoft.Dynamics.Ax.Xpp.InfoException: Exception of type 'Microsoft.Dynamics.Ax.Xpp.InfoException' was thrown.

      at Microsoft.Dynamics.Ax.MSIL.Interop.throwException(Int32 ExceptionValue)

      at Microsoft.Dynamics.Ax.MSIL.Interop.ThrowAssemblyReferrenceError(String clrTypeName)

      at Microsoft.Dynamics.Ax.Xpp.CLRInterop.getType(String _clrTypeName)

    I have made an reference to the dll i AOT/References and have put the dll into the AOS' bin-folder.

    Best regards

    Lars Vistrup Skov

  • 640579632b5c4e6780a624c4771b6f93 Profile Picture
    4,730 on at
  • 640579632b5c4e6780a624c4771b6f93 Profile Picture
    4,730 on at
  • Lars Vistrup Skov Profile Picture
    150 on at

    Hi Huzaifa

    That's for your links, but it didn't bring any new to me...

    The issue is, when the code tries to access object types residing in the dll when running server side /AOS:

    clientType = CLRInterop::getType("TestWCFProxy.CMSWCFProxy");

    So I need to find out, why the code breaks when trying to access elements from the VS project.

    - Lars

  • Lars Vistrup Skov Profile Picture
    150 on at

    Hi

    I might have come a little bit closer to the problem...

    I found comments online saying that AifUtil::createServiceClient() (and possible CLRInterop::getType()) doesn't run on AOS because of some problem resolving the right VSAssemblies path.

    Does this ring a bell to any of you?

    - Lars

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