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)

Error while executing sysoperation in batch process

(0) ShareShare
ReportReport
Posted on by 252

Hi,

I have created a sys operation framework functionality. The process works fine when the class is executed in UI through menu item. But when the same is executed as a batch job I am getting the below error in the execution log.

Error executing code: Wrong argument types for comparison.

But still the process is getting completed successfully. I have tried with full CIL generation and clearing the user data as well, but the error persist. Could anyone please provide a suggestion on this.

Thanks!

*This post is locked for comments

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

    Debug the batch in Visual Studio, and see on which line does it raise the error, from where you should be able to figure out the root cause.

  • Suren_G Profile Picture
    252 on at

    Hi Vilmos,

    I have debugged in visual studio and found that the issue is with a webservice request part. The same works fine in x++. Below is the code sample at which it goes to CLR error. It goes to error at "xml = commProxy.sendRequest(xml);"

    Any suggestion please!

    void execute()

    {

       TMSCommProxy        commProxy = this.getTMSCommProxy();

       container           con;

       XML                 xml;

       TMSTransaction      transaction;

       con = this.sendTransaction();

       xml = conPeek(con, 2);

       if (!manualApportionment)

       {

           xml = commProxy.sendRequest(xml);

       }

       ttsbegin;

       transaction = TMSTransaction::find(conPeek(con, 1), true);

       transaction.ResponseData = xml;

       transaction.write();

       ttscommit;

       this.readXML(xml);

    }

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

    Look at which type is expected and returned from sendRequest() and use the same types in for the parameter and at the left side of the assignment.

    I think the difference is between running in X++ and CIL, not about a batch. Try running it with the synchronous execution mode with "Execute business operations in CIL" enabled. If it's the case, it will make your debugging easier.

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

    The error message is pretty clear about this, you are trying to feed managed code return value into an AX object, and it cannot cast properly as mentioned by Martin.

    Check the return type, System.Xml is not the same as Xml - one is a .Net object, the other one is X++.

  • Suren_G Profile Picture
    252 on at

    Hi,

    On further debugging I found that the web service method accepts and returns 'String'. Below is the code where the error is trigerred.

    ret = tmsService.ExecuteTransaction(_xml);

    Below is the syntax

    String ExecuteTransaction(String _xml)

    The variable 'ret' was declared as "Xml     ret;" before and I have changed it to "str   ret" as the webservice method returns string. But still I am getting the same error.

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

    Didn't you forget to generate CIL?

    How is ExecuteTransaction() related to TMSCommProxy.sendRequest()?

    By the way, types used by the web service and the proxy class may be different, depending on how the proxy is generated. You want to verify types used by the method you're calling (TMSCommProxy.sendRequest() in this case), not types used by the web service.

  • Suren_G Profile Picture
    252 on at

    Hi Martin,

    I have generated incremental CIL.

    ExecuteTransaction() is called inside TMSCommProxy.sendRequest(). The sendRequest() expects and returns 'str'. I tried by changing the 'XML xml' to 'str xml' in execute() so that the string value is retrieved and assigned to a string variable. But that is not causing any issue. The issue arises in ret = tmsService.ExecuteTransaction(_xml) only.

    Thanks!

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

    If I understand it correctly, you're saying that the problem isn't in the code you showed us. You have some failing code inside sendRequest(), where you're using wrong types when calling tmsService.ExecuteTransaction().

    The approach to solving the problem is the same - checking which types should be used and do it. If you're unable to solve it, show us the implementation of sendRequest() and share information collected while debugging.

  • Suren_G Profile Picture
    252 on at

    Hi Martin,

    Below is the implementation of sendRequest()

    str sendRequest(XML _xml)

    {

       str                 ret;

       System.Exception    ex;

       Microsoft.Dynamics.Ax.Tms.API.TmsService tmsService = new Microsoft.Dynamics.Ax.Tms.API.TmsService();

       perm.assert();

       try

       {

          ret = tmsService.ExecuteTransaction(_xml);

       }

       catch (Exception::CLRError)

       {

           // BP Deviation Documented

           ex = ClrInterop::getLastException();

           if (ex != null)

           {

               ex = ex.get_InnerException();

           }

       }

       catch (Exception::Internal)

       {

           // BP Deviation Documented

           ex = ClrInterop::getLastException();

           if (ex != null)

           {

               ex = ex.get_InnerException();

           }

       }

       if (ex != null)

       {

           TMSErrorLog::createLogEntry(ex);

           throw error(ex.get_Message());

       }

       CodeAccessPermission::revertAssert();

       return ret;

    }

    Below are the errors that I am getting in the Visual studio while debugging

    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

    'Ax32Serv.exe' (CLR v4.0.30319: X++ IL App Domain): Loaded 'Microsoft.GeneratedCode'.

    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

    'Ax32Serv.exe' (CLR v4.0.30319: X++ IL App Domain): Loaded 'Microsoft.GeneratedCode'.

    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

    'Ax32Serv.exe' (CLR v4.0.30319: X++ IL App Domain): Loaded 'Microsoft.GeneratedCode'.

    A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll

    A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll

    A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll

    A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll

    A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll

    'Ax32Serv.exe' (CLR v4.0.30319: X++ IL App Domain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.SqlXml\v4.0_4.0.0.0__b77a5c561934e089\System.Data.SqlXml.dll'. Cannot find or open the PDB file.

    A first chance exception of type 'System.FormatException' occurred in mscorlib.dll

    A first chance exception of type 'System.FormatException' occurred in mscorlib.dll

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

    What exactly did you seen when you debugged your code? Does it step into the catch (Exception::CLRError) block? If so, what's the type, message and call stack of the exception?

    By the way, the content of catch (Exception::Internal) block looks suspicious. It tries to work a CLR exception.

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