Class Variables, AOS Crashes, and Compile Forward in Dynamics AX 2012

by | May 10, 2018 | Development, Dynamics AX

Recently I made the transition from Dynamics AX 2009 to Dynamics AX 2012 and continue to learn all the differences between the two (I know, it’s 2018!). That being said, I was tasked with making a minor change to the dialog for project estimates which originates in the ProjControlPeriod class.

Simple. I add my new class variable, create my “parm” method, update the main method to set my new variable, and add my extra five lines in the class to perform what I need for the requirements. Done.

I open up the dialog, fill it in, click “OK” and instantly the AOS has crashed.

I restart the AOS – no need to open DEV because this is a very simple change, just going to test it real quick. Open the dialog, fill it in, click “OK”. Bang! The AOS has crashed again.

Restarting everything again.

So now it’s time to be a bit more cautious. I get everything started up, put in a breakpoint at the top of the main method of the class and off we go. Debugger starts, and I start stepping over each line. There’s where I get the value for my new variable, here’s my new parm method. I know nothing is wrong with that, so I step over and there goes the AOS again. Now I’m annoyed. That couldn’t have been right.

Restart everything again.

I look at the main method. I look at my parm method. Everything is good. Something weird’s going on, but what? I begin stepping over each line again. I get to the call to my new parm method, I step in, I get to the line where the value gets assigned and…

Restart everything again!

So what’s going on! I trace back to before I assign my new variable and start examining things. HUH? Where’s my variable? I examine my class and my variable isn’t there. I quit the debugger, look at my code, looks good, trace back to the assignment, nope no variable.

I try everything I can think of, recompile, incremental CIL, full CIL and after a few more AOS crashes I reach out to a co-worker for anything he can think of…

Compile forward

The compile forward feature in AX 2012 is something that I never needed in AX 2009. There might have been a reason, had I worked in that environment for another eight years, but it wasn’t something I’d ever needed. During development, you make your changes and save them which will perform a simple compile of the class. Compile forward, which is available by right-clicking your object and under the Add-Ins, will compile your object and anything else that references that object.

Compile forward

So, in my example, ProjControlPeriod’s construct method will actually choose one of eight other classes to instantiate that extend the ProjControlPeriod class. Even though all my code was within the ProjControlPeriod class, once one of the other classes (in my case ProjControlPeriodCreate) was instantiated, it didn’t know about my new class variable and the moment I tried to assign it is when I would lose the AOS.

A long story for what now seems such a simple thing. Hopefully, the hours of my frustration can benefit others out there.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events

april

08apr10:00 am10:30 amLicensing Preparedness for Dynamics 365 Customer Engagement

08apr12:00 pm1:00 pmMaking Project Information Management (PIM) a Priority

08apr2:00 pm2:30 pmFeatures in the Spring Release of Dynamics 365 Customer Engagement Users Can Take Advantage of Immediately

09apr11:00 am12:00 pmConfab With Stoneridge - Livestream - Portals

13apr11:30 am12:30 pmStoneridge Connect Online Keynote: Business Transformations Throughout History

14apr8:00 am5:00 pmStoneridge Connect Online - Day 1

15apr8:00 am5:00 pmStoneridge Connect Online - Day 2

15apr1:15 pm5:00 pmWhat’s New for Developers in Dynamics 365 Finance and Supply Chain Management – Online Workshop

16apr8:00 am5:00 pmStoneridge Connect Online - Day 3

22apr11:00 am12:00 pmPower BI and Reporting with Dynamics 365 Business Central

22apr2:00 pm2:30 pmNew Features for Power Apps Users

23apr11:00 am12:00 pmConfab With Stoneridge - Livestream - Internet of Things (IoT)

29apr10:00 am11:00 amStreamlining Customer Service and Enabling Your Sales Team with a Self-Service Portal

29apr12:00 pm12:30 pmUpdates to the Dynamics 365 Customer Engagement User Experience - What Technical Resources Need to Know

may

06may12:00 pm12:30 pmPower Apps Telemetry and AI Builder - Power Platform Updates

06may2:00 pm2:30 pmImprove Customer Experience with a Mobile Workforce Management Solution

07may11:00 am12:00 pmConfab With Stoneridge - Livestream - Manufacturing

13may12:00 pm1:00 pm3 Simple Sets Your Business Can Take to Embrace the Future of B2B E-Commerce

21may11:00 am12:00 pmEnterprise Asset Management and Manufacturing

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X