Life-Cycle Chaos

Ok, so I’ll try to explain what it is that I’m trying to achieve first off:

I have a C++ dynamic library (call it “CLib” for ref) that implements a communication protocol (be it whatever) to a server.

That C++ library has a wrapper class written in C# (call it “Wrapper” for ref) that uses [DllImport] to import the Install(), Uninstall(), NotifyMe(IntPtr funcCallback), etc. functions.

This C# wrapper is then used in a Unity script (“UnityScript”), but it’s giving me all sorts of headaches… I’m having problems specifically with the life-cycle of this Unity script; it seems to be constructed/finalized all over the place, and then sometimes on a finalize it decides not to destroy the “Wrapper” that it owns!?

All of this I can get working flawlessly in a C# console app where I have control over class creation/destruction, but without a) proper debugging tools and b) any idea of what’s going on internally, I’m at a complete loss as to what is going on.

We have the same issue. We’re using a .jar file through JNI magic and one of the expectations is that onPostExecute(…) will be called for one of our AsyncTask instances, from the UI thread (which is a Unity3dPlayer activity, handled by Unity).

It’s never called and we’re not sure why.