Managing destructors of managed (C#) and unmanaged (C++) objects
I have a managed object in a c# dll that maintains an anonymous integer handle to an unmanaged object in a c++ dll. Inside the c++ dll, the anonymous integer is used in an std::map to retrieve an unmanaged c++ object. Through this mechanism, I can maintain a loose association between a managed and unmanaged object using an anonymous integer handle. In the finalize method (destructor) of the managed object I have a call into the unmanaged dll to delete the unmanaged object. All is well as the c# program runs, but I have a problem when the program exits. Becuase I have no control on the order of