Send Michael Damatov an answer (C #), which is based on Herfried C. Wagner. (VB.NET) here is the C ++ / CLI version:
ref class MyClass { ref class StaticFinalizer sealed { !StaticFinalizer(); }; static initonly StaticFinalizer^ stDestr = gcnew StaticFinalizer(); } MyClass::StaticFinalizer::!StaticFinalizer() { System::Diagnostics::Debug::WriteLine("In StaticFinalizer!"); }
PS Like AppDomain.ProcessExit, this call cannot be called if the process aborts abnormally (for example, from the task manager). Another caveat is that if MyClass is shared (templated), the assumption that its static constructor and static destructor will be called no more than once per application execution is no longer valid.
ILIA BROUDNO Jul 31 '14 at 20:03 2014-07-31 20:03
source share