Getting error "assign exception has been thrown by the target of an invocation"

Hi all! Although this reply comes very late, I’m going to leave it here as it may help others who encounter such an issue in the future.

The exception in this message (although it seems vague) shows that the Assign is not the source of the exception. In this case it’s useful to have a look at the exception details; there, you can find the clue as to what happened. image

In my case (and I believe this is also what happened to others) it was this:

Cannot set column ‘XXXX’. The value violates the MaxLength limit of this column.

By default, a DataTable Column of type String has a maximum length of 100 characters. If you try to assign a string value of greater length, this is the exception thrown. The simple fix, for this case, is to increase the MaxLength property of the column to a value that can accommodate the longest string you expect to have.

Cheers,
Alex.

11 Likes