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
Hi All,
I am facing same issue while posting project invoice proposal for sales order. in d365. how to resolve any suggestions pls
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
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.
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!
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.
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.
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).
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?
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.
Mohamed Amine Mahmoudi
100
Super User 2025 Season 1
Community Member
48
Zain Mehmood
6
Moderator