web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

(0) ShareShare
ReportReport
Posted on by 844

Not able to dynamically create AOT Node (class) in CLR session

Dear Experts,

I need to create a class dynamically using code. I searched and found
working code from here: kashperuk.blogspot.com/.../today-i-
want-to-write-about-using-class.html

I have used sysOperations framework to call a form, get parameters and build class according to that. The code how ever does not run and give error as follows when I call it
from sysOperations framework.

Stack trace: Invalid attempt to call <className>.<methodName> running in CIL on the client.

I felt lucky and did nothing but marked the class (runOn property) and the method (server modifier after public) as Server .

This successfull changed the error, but this time, it provides a partial leading error as follows.

"Unable to save Class <classNameProvided>"
"Unable to create node"
"Microsoft.Dynamics.AX.Xpp.ErrorException: Exception of type 'Microsoft.Dynamics.AX.Xpp.ErrorException' was thrown. At ...."

stackTrace_5F00_UnableToSaveCreateNode.txt

Is it related to rights ? CLR session cannot add items to AOT ? There has to be something like that since from a job, this code is
working fine and I can create as many classes I want. When my sysOperation class calls the same, it gives the
unable to save node unable to create errors.

Can some1 help me regarding this. Or should I quit using sysOperations and arrange my work another way in code ?

*This post is locked for comments

I have the same question (0)
  • Maqk Profile Picture
    844 on at
    RE: Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

    Yes Anton

    This is what me and Jonathan has finally figured out. We are using wrong tear to execute the right code. I will make it simpler now :D

    Thanks all buddies

  • Maqk Profile Picture
    844 on at
    RE: Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

    Dear Jonathan,

    Thanks for making corrections. This is why I  posted the issue here man, so that people, experts, gurus can share their knowledge. Yes I agree with you that sysOperations is not fit for the job required.

    Thanks for sharing the worthy links as well. I will study them surely.

    Thanks again for all your time and guidance.

  • Verified answer
    Anton Venter Profile Picture
    20,273 Super User 2025 Season 2 on at
    RE: Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

    Hi Abdul, my suggestion would be not to use the SysOperation framework for this purpose. It seems like adding classes to the AOT can only happen on the client tier and the SysOperation framework does not support client side code.

  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at
    RE: Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

    Hi Abdul.

    I'm by no means an expert on this, but I think your issue is that you are probably trying to perform operations in CIL that aren't allowed or very unusual, such as creating new code... I would imagine this is more the exception than the rule.

    I hope somebody with a bit more knowledge than myself can comment on the sysOperations controller, but things like SSRS classes are in fact "external" as they are exposed as services to the SSRS server and other integration platforms.  Business operations I would expect also make use of this for performance enhancment. (axinternals.blogspot.com/.../performance-comparison-of-x-compiled.html)

    I wouldn't use this framework unless there is a specific reason.

    In regards to accessing X++ from AX have a look at this MSDN article: msdn.microsoft.com/.../gg889200.aspx

  • Maqk Profile Picture
    844 on at
    RE: Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

    sysOperations is not only for use from external apps, or correct me if I am wrong. My understanding is, sysOperations is for seperations of concerns, and for MVC implementation. Just like it is the base for ssrsReporting and business operations framework.

    Anyway thats not what the point of the post is. My limitation is not sysOperations, I can quit that. But that is why I implemented in the first place, to explore further and see how it goes, and this is where it has stuck.

    Probably the finest conclusion of my problem I can draw at this point is

    How to run x++ code while in IL mode, and perhaps that is not possible only for the reason that X++ gives errors and exceptions on call backs to X++ interpreted code.

    I can put my question the other way round for reader's ease:

    1.) How to call back from IL (CLR mode, IL method) to X++ code ?

                                                     OR

    Is it possible to call X++ interpreted code while in a CLR session.

    Also

    2.) Is it possible to make a controller class run in X++ interpreted mode and avoid running in CLR ?

    I might sound strange, or stupid, but these are questions that arise from the scenario I am having at my place. I hope some one can really answer these questions

  • Jonathan  Halland Profile Picture
    11,310 on at
    RE: Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

    Hi Abdul. Why are you using th sysoperations framework if your development application is inside ax.

  • Maqk Profile Picture
    844 on at
    RE: Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

    Thanks again dear

    But I could not understand what you mean by saying "Incorporate this too in AX" "x++ development outside AX". My code is executing from X++ (Not external dotnet application). However I implemented sysOperations framework to provide UI to end user (dev in our case)

    Secondly I have provided InteropPermission permissions, but same result, no effect.

  • Jonathan  Halland Profile Picture
    11,310 on at
    RE: Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

    Hi Abdul

    My suggestion would be to incorporate this development tool into AX itself as generating new code will influence the very services  and assemblies (CIL) that you are trying to generate it from. You may also be by-passing or contravening licencing rules of AX by doing X++ development outside of AX.

    That said you could also experiement around Interop Permissions to execute your code.

  • Maqk Profile Picture
    844 on at
    RE: Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

    Thanks Jonathan,

    Q1) You can think of my scenario as a development utility that asks dev for secific parameters and generate code for it.

    Q2) Stack trace for the 2nd error is as follows (no stack trace for error 1 as it is resolved after adding server modifier to method)

    Microsoft.Dynamics.Ax.Xpp.ErrorException: Exception of type 'Microsoft.Dynamics.Ax.Xpp.ErrorException' was thrown.   at Microsoft.Dynamics.Ax.MSIL.Interop.throwException(Int32 ExceptionValue)   at Microsoft.Dynamics.Ax.MSIL.cqlClassIL.callReturn(Int32 rc, interpret* ip)   at Microsoft.Dynamics.Ax.MSIL.cqlClassIL.Call(IntPtr c, String methodName, Object[] parameters, Type[] types, Object[] varargs, Type[] varargsTypes)   at Microsoft.Dynamics.Ax.Xpp.XppObjectBase.Call(String methodName, Object[] parameters, Type[] types, Object[] varargs)   at Dynamics.Ax.Application.TreeNode.Aotadd(String name)   at Dynamics.Ax.Application.ClassBuild.new(String _name, Boolean _allowExisting, Boolean ) in ClassBuild.new.xpp:line 8   at Dynamics.Ax.Application.ClassBuild..ctor(String _name, Boolean _allowExisting, Boolean )   at Dynamics.Ax.Application.ClassBuild..ctor(String _name, Boolean _allowExisting)   at Dynamics.Ax.Application.MaqClassGen.makeClass(Object[] _params) in MaqClassGen.makeClass.xpp:line 42   at Dynamics.Ax.Application.MaqkXppAdv_sysOps2Logic.makeClass(Object[] _params) in MaqkXppAdv_sysOps2Logic.makeClass.xpp:line 7   at MaqkXppAdv_sysOps2Logic::makeClass(Object[] )   at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)   at Dynamics.Ax.Application.SysDictClass.invokeStaticMethod(Object[] _params) in SysDictClass.invokeStaticMethod.xpp:line 26   at Dynamics.Ax.Application.SysDictClass.invokeStaticMethodIL(String _className, String _methodName, Object[] _params, Boolean _ignoreTtsLevel, Boolean ) in SysDictClass.invokeStaticMethodIL.xpp:line 39   at Dynamics.Ax.Application.SysDictClass.invokeStaticMethodIL(String _className, String _methodName, Object[] _params)   at Dynamics.Ax.Application.MaqkXppAdv_sysOps2Logic.Generatecontrollerclass() in MaqkXppAdv_sysOps2Logic.generateControllerClass.xpp:line 12   at Dynamics.Ax.Application.MaqkXppAdv_sysOps2Logic.Generatessrsreportitems() in MaqkXppAdv_sysOps2Logic.generateSSRSReportItems.xpp:line 7   at Dynamics.Ax.Application.MaqkXppAdv_sysOps2Logic.Startaotitemsgeneration(MaqkXppAdv_sysOps2Contract _contract) in MaqkXppAdv_sysOps2Logic.startAOTItemsGeneration.xpp:line 15   at MaqkXppAdv_sysOps2Logic::startAOTItemsGeneration(Object , Object[] )   at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeInstanceCall(Object instance, String MethodName, Object[] parameters)   at Dynamics.Ax.Application.SysOperationServiceController.Runoperation(Boolean _async) in SysOperationServiceController.runOperation.xpp:line 88   at Dynamics.Ax.Application.SysOperationServiceController.runServiceOperation(Object[] parameters) in SysOperationServiceController.runServiceOperation.xpp:line 22   at SysOperationServiceController::runServiceOperation(Object[] )   at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)   at Dynamics.Ax.Application.SysDictClass.invokeStaticMethod(Object[] _params) in SysDictClass.invokeStaticMethod.xpp:line 26   at SysDictClass::invokeStaticMethod(Object[] )   at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)   at Microsoft.Dynamics.Ax.Xpp.PredefinedFunctions.runAsInvoke(String className, String staticMethodName, Object[] parms, Object[]& exportInfolog)

  • Jonathan  Halland Profile Picture
    11,310 on at
    RE: Unable to dynamically create AOT Node (class) using sysOperations [CLR session]

    Hi Abdul, My first question is what is your business case for trying to create Classes in AX through code executed under CIL? It seems strange and dangerous that you'd want such a dynamic class creation functionality. There is certainly reasons for creating code from code, but it would normally be under more controlled circumstances.

    Secondly could you put the full error message that you are recieving into the post? There seems to be a partial stack trace that hasn't been included.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Rahul Shah Profile Picture

Rahul Shah 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans