I'm having the same problem. I have a list of tabs in the tap panel and when selecting (strange is that first selection works, but not the second time) some of them I get the above error.

How exactly should apply the above code? Where should I put it?