Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

C# Project deployed and working but does not compile in AOT without error

Posted on by 500

I have a data import routine in a C# project based on a post here by goshoom.

The original code has been working fine and already been committed to the CUS layer and I am working in USR layer making changes to import new data points.

Visual Studio compilation and deployment to AX is working fine. Also I am pulling through new data points as intended in my updated routine so functionally I have no issues either.

However, when compiling my AX Project that contains the Visual Studio C Sharp project I get the following error (truncated by AX compiler). 

"CS1061: 'NS.MyDataContext' does not contain a definition for 'Personnel_Posts' and no extension method 'Personnel_Posts' accepting a first argument of type 'NS.MyDataContext' could be found (are you missing a using directive or an assembl"

My C# code contains a .dbml file which auto-generates Linq-to-SQL classes to access another SQL database. In a custom C# class, I use the data context class to connect to this data source. This class is where the error is being detected (even though it is working!)

The specific table "Personnel_Posts" is the only update to the .dbml file and generated classes.

So far I have tried AOS restart, .auc client files deletion under AppData\Local and clearing the AX caches.

Hope someone can help.

*This post is locked for comments

  • _MGP Profile Picture
    _MGP 500 on at
    RE: C# Project deployed and working but does not compile in AOT without error

    I've solved the compilation problem by:-

    1. opening up AX in the CUS layer and then editing the VS solution
    2. while the VS solution open, delete the AOT object that represents this Visual studio c# Project
    3. then re-add the VS Project into the AOT from Visual Studio and re-add the C# project to the AX Project and re-compile.
    4. After an incremental CIL compile that crashed the AOS, after the AOS was re-started, the report worked and the AX Project still compiled.
  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: C# Project deployed and working but does not compile in AOT without error

    Where do you execute your code? If it runs on server (and it works), while X++ compilation fails (which happens on client), maybe you have one version on AOS and another on client.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans