Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Visual Studio DLL Problem in BATCH ax 2012

Posted on by

Hi i have a problem

i created a visual studio project embemded in my AOT. This project generate a DLL that i use into a method in a server side class.

This is my project. Configurated with .net framework 3.5

pastedimage1592933015677v1.pngpastedimage1592933136062v2.png

This is my class configurated to Server side. In the Method ConsultarDocumentosResponse i call the DLL generated by my visual studio project

pastedimage1592933456912v4.png

When i call this method via form work perfect but this same method i called using a batch class and i got this error  

pastedimage1592937446344v5.png

then i restart the aos and got these error

pastedimage1592938635586v1.png

The error information say that my method ConsultarDocumentosResponse  has and error, but i compiled and cil but doesnt get and error. 

pastedimage1592939396476v1.png

In my method i have and errror message but in the batch error log doesnt appear, that mean for me that the DLL is no detected on execution time because this method use entities that are into the dll before mentioned (entities like MaintFacturacionElectronica35.Model.RespuestaAutorizacion)

I dont know what i can do for solve this problem

I see that my DLL is correctly copied in the paths 

AOS -> C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\VSAssemblies
Client -> C:\Users\jmiranda\AppData\Local\Microsoft\Dynamics Ax\VSAssemblies{AE1C9722-F088-48FE-8D33-D113EAB64F1F}

but doesnt appear in C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin maybe this mean something that i am not seeing

I tried restarting AOS, no make any diference

I tried compiling AOT and CIL FULL, no errors were detected

Regards

  • RE: Visual Studio DLL Problem in BATCH ax 2012

    I did what you recommended and I detected that when I get the value of the property get_FechaAutorizacionConvert (), property that returns a DateTime, it generates an error at runtime. I find it strange since I discovered that it happens to me when the answer object returns me data types like System.Int32, System.Int64, System.DateTime. With the data type System.String it did not happen to me so all my properties had to change them to that type of data.

    pastedimage1593112727557v1.png

    pastedimage1593112515402v1.png

    In the image you can see all my data types changed to string.

    This solved my problem but I still find it curious and weird.

    Thanks for your help and time, I will mark your last answer as the correct one.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: Visual Studio DLL Problem in BATCH ax 2012

    Okay, so it's not the call of the DLL - is about the CIL generated from X++.

    Regarding your assumptions, consider testing if they're true. For example, comment out all code in ConsultarDocumentosResponse(), compile X++ and CIL and try again the process in CIL (it may be a batch, but also synchronous code called via SysOperation controller, for example). Then add a reference to a type in your library (no method calls) and repeat the process. Tests like this often reveals where exactly things go wrong - and it's often not what one expects.

    Also, continue the job of verifying that all references (and their references etc.) can be loaded (they are reachable from AOS, they can run in a 64-bit process etc.). The Assembly Binding Log Viewer might help a lot. By the way, you verified that your DLL is on both server and client, but are the files identical?

    Compilation runs on client while you're executing things on server. Therefore the fact that it compiles doesn't necessarily mean much.

  • RE: Visual Studio DLL Problem in BATCH ax 2012

    The code fails because in the first lines of my job method I have a reference to an entity inside the DLL, so I think Ax is not detecting my DLL and generates an error as soon as the method is going to be executed. Even when debugging don't enter the called method.

  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: Visual Studio DLL Problem in BATCH ax 2012

    Hmm, I thought you said that it fails when your X++ code calls a method defined in a C# library. But that's not what the highlighted line does, is it? It calls a method in the same X++ class.

    If this is really the place where the exception is called (and not somewhere inside ConsultarDocumentosResponse()), then it's a different problem. You don't have a problem with calling the DLL - your code fails even before that.

  • RE: Visual Studio DLL Problem in BATCH ax 2012

    Sorry, it's all a bit unclear to me. What are the screenshots suppose to show?
    - Show the line where the executing stop beacuse the call to the method handle an error

    Are you saying that you have a problem with debugging, or that an attempt to call the method throws an exception?
    - Yes, the call of the method throws an exceptopn but even the 1rst line doesnt executed

    Are you able to debug your X++ code in batch, or do you have a problem with debugging in general?
    -Yes, i debug the batch job for detect the error but it doesnt show me any value information

    Where is the line of X++ code calling the method and what's the declaration of the method?
    - The calling line is in red, the attached line. At the end of the code i have an try catch and is where the exception is controled

    pastedimage1593011870050v1.png

  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: Visual Studio DLL Problem in BATCH ax 2012

    Sorry, it's all a bit unclear to me. What are the screenshots suppose to show?

    Are you saying that you have a problem with debugging, or that an attempt to call the method throws an exception?

    Are you able to debug your X++ code in batch, or do you have a problem with debugging in general?

    Where is the line of X++ code calling the method and what's the declaration of the method?

  • RE: Visual Studio DLL Problem in BATCH ax 2012

    Yes,

    I debug the job but it never goes into the ConsultarDocumentosResponse method which implements de dll objects

    pastedimage1593010689895v1.png

    pastedimage1593010767883v2.png

    Any suggestions in debug time?

  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: Visual Studio DLL Problem in BATCH ax 2012

    Hmm, so what if you try to debug the code - both X++ and C#? It should at least confirm or invalidate the theory that the assembly can't be loaded.

  • RE: Visual Studio DLL Problem in BATCH ax 2012

    yes i got them in my server path

    pastedimage1593004984398v1.png

  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: Visual Studio DLL Problem in BATCH ax 2012

    I think the warning can be ignored unless you actually use from ManagedInterop.

    I see you refer to Newtonsoft.Json and RestSharp on client. Do you have them on server as well?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans