An unhandled exception of type 'System.AccessViolationException' occurred in UnityEngine.DLL

I get this error when I come back from the purchase of an IAP (not tested as mock but as Beta). It’s correctly called my PurchaseSuccess method registered to the event of purchase successful of the Unibill plugin and in it I show an advice and I assign an advice’s texture with the image rapresenting the IAP using the usual mainTexture property…but something gets wrong and what I noticed is that a Debug.Log in OnApplicationPause is not called before, so I suspect that probably UnityEngine is not resumed correctly when the method of a successful purchase is called.

What can you suggest me to solve it?

Hi,

your callback is definitely called on another thread, so you have to use proper synchronization mechanisms to prevent race conditions. Furthermore, you cannot invoke Unity API from another thread. Probably the easiest solution would be to either set a flag in the callback that you can handle on OnApplicationPause() callback, or call into UnityPlayer.UnityApp.BeginInvoke() if you have access to it.