Celeste
Celeste

Reputation: 116

Development and debugging in Dynamics 365

I’ve upgraded a custom model to Dynamics 365, from Ax2012. I’ve created deploy-able package and imported into an on-prem environment. The machine on which I developed is different from the on-prem environment (TEST-env).

There is some functionality that is not working as it should, which I need to debug, and this is where I get stuck. I’ve been developing in Ax from version 3 to 2012. I am struggling to get comfortable and find my way in Visual Studio.

In a broad sense I guess my question is: how do I debug something as simple as a button click event on a form? Can I run the form from Visual Studio and debug it there, without having to open the Dynamics 365 website? Since my development environment and the on-prem D365 website (TEST-env) are on two different machines, is there an easy way to make changes to the code and have the TEST-env updated, or do I have to create a deployment package and import it into TEST-env for each change?

Upvotes: 0

Views: 991

Answers (2)

maguy
maguy

Reputation: 1699

Your development environment is an entirely isolated version meaning typically your database and the application all live on the same box and all the D365 services run from that one box. IIS is configured to run your instance so when you browser to D365 you are viewing your development environment.

Typical debugging involves placing break points in the code, normally if you know there is code behind a button click you want to break into you would find the form where the button is right-click and get the form name. Then open visual studio 2015 which is the exclusive IDE for development. Find the AOT explorer and paste in the form name. Then open the form once it is in the explorer, find the button and look at the methods, events of that and view the code. From there you can put break points and you just have to attach the debugger to w3wp.exe. Make sure you go into the options under the Dynamics 365 menu and find debugging and make sure to uncheck "Load symbols only for items in the solution" or your break point won't get unless it is something in your project.

The other option you have with debugging is to create what is called a runnable class in D365. You create a new class and add a void main entry and then right-click on the class from the solution explorer and select "set as startup object". Then you can just press the start button from visual studio and that class will fire. This allows you to easily debug scenarios where you are checking what a select in X++ returns or items like that. You can't run the D365 site from pressing start, only simple runnable classes.

Example of a runnable class in D365

class TestClass
{        

    public static void main(Args _args)
    {     

        Info("hello world");

    }

}

Upvotes: 0

Alex Kwitny
Alex Kwitny

Reputation: 11544

To debug, you just create a project with your objects, right click on a form and click "Set as Startup Object" then go put a breakpoint (F9) on whatever line of code, and press F5 to run.

You could connect your Test version to VSTS and do code moves that way via branch/merging.

Upvotes: 2

Related Questions