Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Exception has been thrown by the target of an invocation - Purchase Order Invoice Posting

(0) ShareShare
ReportReport
Posted on by 1,630

When posting a Purchase Order Invoice, we are getting "Exception has been thrown by the target of an invocation" for random Purchase Orders/Items/Vendors.  This production environment has been live for a year and this issue just arose in the past month. 

I have been looking online and have found that this must be a common issue, as there are multiple posts and discussions but no one offers a solution or provides what fixed their specific issue.  If anyone has had this issue and can provide some guidance, it would be much appreciated.

*This post is locked for comments

  • TestBot Profile Picture
    940 on at
    RE: Exception has been thrown by the target of an invocation - Purchase Order Invoice Posting

    Hi All,

    I am facing same issue while posting project invoice proposal for sales order. in d365. how to resolve any suggestions pls

  • Suggested answer
    msmfp Profile Picture
    on at
    RE: Exception has been thrown by the target of an invocation - Purchase Order Invoice Posting

    On AX7+ this KB has also helped resolved errors surfacing like this:

    KB 4092585 Free text invoice posting doesn't create a voucher after initial validation error

  • FAC.Ansel Profile Picture
    1,630 on at
    RE: Exception has been thrown by the target of an invocation - Purchase Order Invoice Posting

    Thank you for the information.  Hopefully it will help someone with a similar situation.  In my case, the product category isn't being used.  But, the issue has either resolved itself or something someone is doing has changed, as I haven't seen the issue in months now.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Exception has been thrown by the target of an invocation - Purchase Order Invoice Posting

    Dear Ansel!

    I got the same message at the time of product receipt against PO. In my case, it was the product category missing (new category of product) in product receipt posting profile. i update that category there no error occur there after. So, you better check it as well if the product category is new or just use first time. 

    Note: My answer is based on the circumstances i faced, your circumstances might have been different than this. in such case you better focus the information note narrated in lines over this error message and resolve accordingly.

    Best of Luck!

  • FAC.Ansel Profile Picture
    1,630 on at
    RE: Exception has been thrown by the target of an invocation - Purchase Order Invoice Posting

    Anas, Thanks for the info!  In this case, we can get in to AX and everything else is working.  The frequency of the issue has drastically reduced, now it is maybe once a month or two.  Still haven't figured out what triggers the issue.

  • Community Member Profile Picture
    on at
    RE: Exception has been thrown by the target of an invocation - Purchase Order Invoice Posting

    I got the same error when I tried to open AX and found our that AX cannot reach the database since the login account for the AOS is locked, after unlocking the account everything worked fine.

  • Martin Dráb Profile Picture
    233,731 Most Valuable Professional on at
    RE: Exception has been thrown by the target of an invocation - Purchase Order Invoice Posting

    It might mean that CIL doesn't correspond to X++ code (maybe because of a wrong code deployment). Or it may be related to something that doesn't behave the same in X++ and CIL.

    If you rule out the theory of CIL being out of sync, try reproducing the problem in a non-production environment, even if it means copying some data. Outside production, you will have more options how to extract the inner exception from TargetInvocationException (to see the actual cause).

  • FAC.Ansel Profile Picture
    1,630 on at
    RE: Exception has been thrown by the target of an invocation - Purchase Order Invoice Posting

    Martin,  Thanks for the reply.  Right now the "work around" is to uncheck  "Execute business operations in CIL", post the invoice, then go back and re-check the box.  The posting works without issue this way, which would suggest to me that something is out of sync?

  • Martin Dráb Profile Picture
    233,731 Most Valuable Professional on at
    RE: Exception has been thrown by the target of an invocation - Purchase Order Invoice Posting

    The problem is that this is a completely generic error, meaning that some method throw an exception when called via reflection. It doesn't say anything about the actual error. It may be anything.

    For testing purposes, try running the posting without Execute business operations in CIL. If the whole thing runs in X++, you should get the actual error instead of the reflection-related exception. Don't run the posting in batch, because that would use CIL anyway.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
Zain Mehmood Profile Picture

Zain Mehmood 6 Moderator

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans