This question was raised some time ago but I never saw a satisfactory
answer.

Unmanaged static C++ objects that are built into an assembly never have
their destructors called.

This appears to be because _DllMainCRTStartup is never called with
DLL_PROCESS_DETACH for the assembly

(If the CRT heap checking is turned on, this may also manifest itself as a
bazillion heap leaks)

This appears to be a bit of a problem - could anyone shed some light on
this and comment as to whether it is a bug or a "feature"
  Thanks
     Andrew

 The following example illustrates the problem

#pragma unmanaged
class foo
{
public:
  foo() {::MessageBox(0,"You see this",0,MB_OK);}
  ~foo() {::MessageBox(0,"You dont see this",0,MB_OK);}
};
static foo aFoo;
#pragma managed

public __gc class  someManagedClass
{
public:
  void someManagedMethod() {}
};

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to