I am using a delegate which calls an unmanaged function pointer. This causes the Garbage Collector to collect it before it is used, as described in the CallbackOnCollectedDe
You didn't read it correctly. You must do this:
...change your code to keep a reference to that delegate on the managed side for the lifetime of the marshaled unmanaged function pointer.
In other words, just store a reference to the delegate instance in your class and make sure the class object survives long enough. Use a static if you really have to.