List Gurus, I am having an issue with COM Interop that seems to be a bug in the way imptlb creates these dlls.
Problem Description: I am creating a COM Interop for our legacy COM dlls. Some of the DLLs have dll-global pointers to other COM objects, found in a second DLL. If I create an object from DLL A through from C# (using the Interop), the loading of DLL A causes DLL B to be loaded. Now when the application exits, it calls Release() on the object I created in DLL A, making its lock count 0, and then tears down the DLLs. I am not sure at what order, but it seems that DLL B (which still has a reference count of 1) is torn down first, without a call to DllCanUnloadNow. So now DLL A has a pointer to an invalid location, and thus I get an Access Violation, when it tries to release its pointer to DLL B. So my questions are: 1. I remember Mike Woodring (I think) mentioning that the .Net run time takes some short cuts at teardown time in that not all finalizers are called, and that there exists a setting that will force all cleanup and garbage collection to be performed. Can this be a cause of this problem? 2. He also mentioned that there is an override to that behavior - Where can I find it? Is is per assembly or on the executable. 3. If this is a bug in the Interop DLL, does anyone know how to fix it? Thanks, Noam. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
