1. When writing a COM add-in for a host application. When the application wants to shut down, the add-in must release all references to the objects of the host application, otherwise the process doesn't shut down. (At least with the application I'm currently writing an add-in for!)
2. When using out-of-process COM servers such as Excel from another application. This tends to leave lots of "excel.exe" processes running unless you explicitly release everything.
Here is Microsoft describing how they ran into this problem when mixing COM and .NET in Visual Studio, how they solved it using Marshal.ReleaseComObject, how that itself caused other problems later when they combined it with CCW, and ... I'm not sure what their ultimate correct solution was:
I've run into this kind of problem while implementing a Windows screen reader that needs to use COM-based accessibility APIs, both in-process and out-of-process. I naively chose, some 12 years ago, to use Lua, even for the in-process component. Lua, of course, uses tracing garbage collection, not reference counting.
I guess the reason for never bumping into it was that all use cases I encountered so far, the controls were in-process and died when the application terminated.
1. When writing a COM add-in for a host application. When the application wants to shut down, the add-in must release all references to the objects of the host application, otherwise the process doesn't shut down. (At least with the application I'm currently writing an add-in for!)
2. When using out-of-process COM servers such as Excel from another application. This tends to leave lots of "excel.exe" processes running unless you explicitly release everything.
See for example: https://www.add-in-express.com/creating-addins-blog/2013/11/...
Here is Microsoft describing how they ran into this problem when mixing COM and .NET in Visual Studio, how they solved it using Marshal.ReleaseComObject, how that itself caused other problems later when they combined it with CCW, and ... I'm not sure what their ultimate correct solution was:
https://blogs.msdn.microsoft.com/vcblog/2006/09/19/mixing-de...
https://blogs.msdn.microsoft.com/visualstudio/2010/03/01/mar...
I am aware of UWP bringing COM back into fashion again, which is why I'm interested in potentially using Kotlin Native with it. :)