English 中文(简体)
Debugging in Dynamics AX
原标题:

I m facing some troubles still while learning, so I guess it tends to get worse once I play with the big kids: warnings in dynamics aren t as precise and informative as VS s, there are no mouse-over tips, and exceptions to show me exactly where I ve got it wrong. I m just too used to Visual Studio, it s intellisense and all the tools (dynamics is quite new when compared to Visual Studio)

More than solving simple code issues, i d like to learn how to solve upcomming ones i might have in code not written by me or anything else i d solve in 3 minutes in Visual Studio, as well as tips on how to survive in dynamics ax without all the Visual Studio tools.

最佳回答

The code editor in Dynamics AX has some intellisense, typing the name of a table or class variable followed by . or :: will give you a list of fields or methods available for that item. After you type the ( to start a method call, a tooltip pops up with parameters available on that method. When starting a new line, you can right click and List Tables, List Classes, List Types, etc. Most of those commands are also available via Shortcut Keys. Note that the intellisense only works if all the code in the method up to the location of your cursor is syntactically correct.

Make sure you have updated the cross reference in your development environment (Tools/Development tools/Cross-reference/Periodic/Update). With an updated cross reference, you can right click an any table, field, class, method, extended data type, or enum in the AOT and choose Add-Ins/Cross-reference/Used by to see where that item is used in the system.

You can also use Tools/Development tools/Code explorer to view the source to the application with all types, variables, and methods turned into hyperlinks so you can click to go right to the definition of that item.

Another useful tool is Application hierarchy tree, available either under Tools/Development tools, or on the right click Add-Ins menu. This will show you the class hierarchy, so you can easily see, for example, that SalesFormLetter derives from FormLetter, which derives from RunBaseBatch.

In the editor, you can highlight text and right click to Lookup Properties/Methods or Lookup Definition.

If you are trying to track down where in the system a particular infolog message is generated there are two strategies to use:

  1. Set a breakpoint on the first line of the method Info.add(). Then when you run the code generating the message, you will pop into the debugger as soon as the infolog is generated. You can then look at the stack trace in the debugger to see where the code is that generated the message.

  2. Run Tools/Development tools/Label/Label editor and search for the text of the message. Select the Label ID of the message, then click Used by to see where that message is used in the system.

问题回答

There is also http://www.axassist.com/ which extends intellisense and many other extensions

What these guys said already is very interesting and helpful.

I d like to add that within AX in real life you are probably working with multiple contexts. e.g. Code running in the client, code running in server, code running in p-code and in IL, COM integrations, Enterprise portal and so on.

My point is, if you want to figure something out through debugging, you must first understand where the code(s) you d like to debug is running.

Knowing that is important because you might have to allow debugging or give permissions in multiple places.

Examples:

  • Windows AD debugging users (add yourself)
  • Allow debugging on client
  • Allow it on server
  • Disable IL if you want to use MorphX, otherwise attach the process in VS.
  • Allow World Wide Web Publishing Service to interact with desktop for EP.

One last thing, you are starting to work with ax right now, perhaps you will need to work with AX7(Dynamics 365 for Operations). This version of the system works only with visual studio. It is still x++, but you have a lot of the things VS provides you.

Take a look on EditorScripts Class,On AX Editor you can use it by right click and choose "Scripts". It is a kind of intellisense that can make by your self, for example: here is my in-line comment whenever I type "mycom" and press "tab"

public void template_flow_mycom(Editor editor)
    {
        xppSource   xppSource   = new xppSource(editor.columnNo());
        int         currentline = editor.currentLineNo();
        int         currentcol = editor.columnNo();

        Source      template = "//Partner comment "+date2str(today(),123,2,1,3,1,4, DateFlags::FormatAll )+" at "+time2str(timenow(), 1, 1)+" by MAX - Begin
";
        template+=strRep(" ", currentcol)+ "
";
        template+=strRep(" ", currentcol)+ "//Partner comment "+date2str(today(),123,2,1,3,1,4, DateFlags::FormatAll )+" at "+time2str(timenow(), 1, 1)+" by MAX - End
";

        editor.insertLines(template);
        //move cursor to the empty line between the comments
        editor.gotoLine(currentline+2);
        editor.gotoCol(currentcol+4);
    }




相关问题
building .net applications without Visual Studio

I m interested to hear about people working with building .net applications using MSBuild, NAnt or similar tools. What are you using, why are you using it instead of the VS IDE? I like to use ...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Visual Studio 2010 Beta 2: Can I print in color?

I have to turn in a hard copy of some code with an assignment. Is there any way in Visual Studio 2010 to print C# source code with syntax highlighting? PS: The assignment is solving a math problem, ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

热门标签