G
Guest
Hi,
What are the recommended practices on how to use the __crt_dll_initialize()
and __crt_dll_terminate() calls described at
http://support.microsoft.com/?id=814472 in order to circumvent the mixed-dll
bug ?
I implemented the ManagedWrapper class, as described in the kb. Calling init
before anything else, then calling terminate after anything else will of
course work.
What I try to achieve is hide these details to the end-user of my library,
so they don't have to call anything at all, I'll take care of the details.
- Is it a good approach to have a static constructor for the library that
would call init ?
- Is it wrong to call init several times ?
- What could happen if for some reason __crt_dll_terminate is not called ?
- What's the best mechanism to ensure that __crt_dll_terminate will be
called ? (atexit of some sort ? creating a special object and keep a
reference on it in the main mixed classes I have, then relying on Dispose
call to call__crt_dll_terminate ?)
- If an application mixes several mixed-mode dll which follow this
mechanism, will call to __crt_dll_terminate in one dll break things for other
libraries still in use ? (I especially have contexts for which I have to
dynamically load dlls like plugins, then close them, at runtime, while other
plugins still do their job)
Best regards
Thibaut
What are the recommended practices on how to use the __crt_dll_initialize()
and __crt_dll_terminate() calls described at
http://support.microsoft.com/?id=814472 in order to circumvent the mixed-dll
bug ?
I implemented the ManagedWrapper class, as described in the kb. Calling init
before anything else, then calling terminate after anything else will of
course work.
What I try to achieve is hide these details to the end-user of my library,
so they don't have to call anything at all, I'll take care of the details.
- Is it a good approach to have a static constructor for the library that
would call init ?
- Is it wrong to call init several times ?
- What could happen if for some reason __crt_dll_terminate is not called ?
- What's the best mechanism to ensure that __crt_dll_terminate will be
called ? (atexit of some sort ? creating a special object and keep a
reference on it in the main mixed classes I have, then relying on Dispose
call to call__crt_dll_terminate ?)
- If an application mixes several mixed-mode dll which follow this
mechanism, will call to __crt_dll_terminate in one dll break things for other
libraries still in use ? (I especially have contexts for which I have to
dynamically load dlls like plugins, then close them, at runtime, while other
plugins still do their job)
Best regards
Thibaut