COM Callable Wrapper and .NET Object Lifetime

I have a C # .NET assembly that is being called from a C ++ COM client. When the client process explicitly frees the COM object, the CCW release is an internal reference, which makes the .NET object suitable for garbage collection.

What if a .NET object has a static constructor that opens a log file? Is there an elegant solution to close a log file without an explicit request from a client?

TIA.

+3
source share
2 answers

After some testing using AppDomain.ProcessExit, EventHandler seems like a good choice to close the log file.

+1
source

COM-, . (, FileStream), GC Finalizer GC , CCW GC (s.)

-Oisin

0

Source: https://habr.com/ru/post/1729576/


All Articles