Exception has been thrown by the target of an invocation. Purchase order invoicing

Hi All,

I am facing a strange problem while posting a invoice for Purchase Order.

It is giving me a errr:

Posting Purchase order: PO-000047 Exception has been thrown by the target of an invocation…

Not able to understand from where these error comes.

Can anyone please help…

Aman Gupta

This a reflection-related error, i.e. some error thrown by CLR. Place a breakpoint to add() method in Info class; you should be able to catch the exception and see the call stack.


I am facing the same problem. Please can you elaborate the answer…



As I said, I think it’s a CLR exception - AX tried to call something by reflection but the called method threw an exception. To understand what failed, you should find what was called and what was the exception.

  1. Catch the exception (by catch (Exception::CLRError)). I didn’t get enough information to tell you where, but I described how to find it.
  2. Get the CLR exception and look into its InnerException property. AifUtil::getClrErrorMessage() is usually the easiest way to do that.

I am facing this error whenever I apply prepayment in a PO invoice. Is this a bug of some sort?

Hi Aman,

I have faced this myself and I changed the Default printer within Devices and Printers to another printer. Then I tried to print the report again and this time I selected the Printer Option within AX and selected my new default printer. Then the message disappeared. I also had problems printing to AX screen.

So try to work with your printers. Others are writing about remove the CIL-checkmark in the user options

Dear Michael,

I have removed the CIL-check mark from the user options, and this woks for me. (I don’t know the meaning of that)


Nitin Bagate

Yes removing “Execute Business Operations in CIL” checkbox will resolve the issue.

Go to System Administration->Users-> select the user which u logged in as → click options button → development → Execute Business Operations in CIL (Uncheck). Go ahead and post invoice. if it doesn’t effect close the application and open and post invoice.


  • Samanth

Unchecking “Execute Business Operations in CIL” means that you stopped testing whether the logic works in CIL; the problem is still there and it will occur again when the code is executed in CIL (by a non-developer user, a batch, a service operation etc.).

So what would be the solution ? Can you please suggest.

As I said before, you have to debug the code to see where the error occurs. That there is a CLR exception somewhere in order posting is not enough information.

I faced this problem before but when opening the application and reason was the administrator password was changed

Hi, I am also having the same issue on start up of client. Where has the admin password been changed? Regards, Steve

Hi, I have now the same problem and When I try to debug this I found that the reason for this error is the call to event handler.

Did any one find the solution ?

There is no universal solution for any CLR exception thrown by any event handler. Please tell us what error handler it is and what inner exception is the the invocation exception in your particular case.

Target invocation exception is just a wrapper; each person in this thread may be talking about a completely different underlying error.

Hi everybody,

I have a particular case for this generic error.
In posting phase of purchpackingslipjour i had the target invocation error.

I tryed to found the real error with a Visual Studio Debug attached to aos.

Visual Studio has stopped the execution in a customized line code of function PurchPackingSlipJournalCreate.InitHeather().
The custom istruction call Docu::copy(from,to).

In Visual Studio I saw that the execution can’t enter into this function.

To check the problem:
-I put some info() before the line code Docu::copy(…),
-one info into docu::copy(…) at the beginning of function and one at the end.

After the incremental cil, the execution ended correctly…
It seems that incremental cil solve some problem that i have with full cil Or the Incremental cil force the execution of this function without cil execution (I don’t know and I don’t understand).
What do you thik about it?

CIL compilation surely don’t force execution without CIL. It’s just generates CIL code.

Incremental CIL compilation uses the same process as the full compilation, it just doesn’t compile everything. Make sure that your full compilation completed correctly; also don’t forget that CIL compilation depends on X++ compilation.

Thank you for your answer. You have clarified some doubts I had

I’ve recently run into the same problem with prepayment invoices. By temporarily disabling the “execute business operations in CIL” checkbox, I was able to get a stack trace error indicating there was an issue copying the document handling documents from the purchase order to the invoice. After I deleted those document references from the PO, the prepayment invoice posted just fine.

Jake, thank you for the post, we have same problem when the PO has prepayment…!!