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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Exception was thrown because the .NET instance method DocumentFormat.OpenXml.Wordprocessing.Document.Descendants was not found during CIL generation

(0) ShareShare
ReportReport
Posted on by 278

I need to work on OpenXml to generate a word document from AX using a template. I got a sample code in C# and I have written the same code in x++ and it seems to be working fine but I am having a strange issue.

The line where we are fetching descendants (document.MainDocumentPart.Document.Descendants()), it does not execute the code, it just stops the execution. On generating CIL it gives a warning "Exception was thrown because the .NET instance method DocumentFormat.OpenXml.Wordprocessing.Document.Descendants was not found during CIL generation". I am pretty sure this is the reason the code is not executing. 

I checked the references, Document.OpenXml reference is available. Need to know what could be the possible cause for this warning. 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Srini Ramidi Profile Picture
    2 on at

    Hello,

    Can you try by restarting the AOS service and  do Tools | Caches | Refresh elements and refresh Dictionary.

    Best,

    Srini

  • Suggested answer
    Hichem.Chekebkeb Profile Picture
    3,371 on at

    Probably you are not using the same version of OpenXML assembly I am using, Did you get it from Nuget?

    1- Check point 4 in my blog post regarding the subject: 

    How to generate and populate data to Word documents using OpenXML and X++ in Dynamics 365 for Operations

    2- Check the assembly got copied here: C:\AOSService\PackagesLocalDirectory\Bin

    3- Try what Srinivas Ramidi said.

  • Vishal Jevtani Profile Picture
    278 on at

    Hi Hichem

    Brother I am using Ax 2012, and OpenXml is already referenced in AOT references. Still when I get this warning when I generate CIL and code is exiting when it executes the descendants code. I tried restarting everything.

    Is there any source where I can get latest OpenXml dll and add reference to AOT ?

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans