none
Issues with COM Interop RRS feed

  • Question

  • Hi,
    Currently facing an unusual issue. I have a .NET application accessing COM+ dlls which are configured as Server Library via Interop. They are VC++ dlls. We are explicitly calling Marshal.Releasecomobject wherever we are using COM object.

    Whenever we exit the application and log off from the server and log in and start the app, the application hangs. Only when we kill the dllhost.exe the app starts working again.

    Currently we have the COM+ components configured with admin user account as localsystem account also gave us similar problems. Not sure what needs to be done. Would appreciate if anyone can throw some light.

    Thanks
    Sai
    Monday, December 21, 2009 7:21 AM

Answers

All replies

  • Attach debugger (several times) to see where exactly is the app stuck ... (probably waiting on some lock which is held by dllhost.exe)

    -Karel
    Monday, December 21, 2009 4:47 PM
    Moderator
  • I second Karel's suggestion.

    Additionally, please note that the safest way to release COM interop objects are:

    1. Explicitly call Marshal.FinalReleaseComObject on all accessor objects. See http://support.microsoft.com/kb/317109.

    [or]

    2. Force a garbage collection as soon as the calling function is off the stack (at which point these objects are no longer rooted) and then call GC.WaitForPendingFinalizers.

            // Force a garbage collection as soon as the calling function is off
            // the stack (at which point these objects are no longer rooted) and
            // then call GC.WaitForPendingFinalizers.
            GC.Collect();
            GC.WaitForPendingFinalizers();
            // GC needs to be called twice in order to get the Finalizers called
            // - the first time in, it simply makes a list of what is to be
            // finalized, the second time in, it actually the finalizing. Only
            // then will the object do its automatic ReleaseComObject.
            GC.Collect();
            GC.WaitForPendingFinalizers();
    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, December 22, 2009 4:05 AM
    Moderator
  • Hello

    How are you? I'm writing to check the status of the issue on your side. Happy holidays!

    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, December 25, 2009 6:55 AM
    Moderator
  • Thanks for checking up on the issue. We tried calling GC Collect twice but that still didnt help. Whenever we logged off and logged in again the COM+ components would hang when the .NET application made a call via interop. Finally In the properties of COM+ components, under the advanced tab, the Server Process Shutdown we have set to “Leave Running When Idle”. This has resolved the issue. Though I am still baffled at the cause of the problem. As of now this setting seems to work though I am not too convinced as to how this setting reolved the issue.
    Friday, December 25, 2009 9:26 AM
  • I have the feeling that this issue is related to dll loader lock. Improper locking in dllmain can cause deadlock when dll loads or unloads. It seems that in this case when COM+ process unloads or loads your component, a deadlock happens.
    http://blogs.msdn.com/oldnewthing/archive/2004/01/28/63880.aspx

    The above analysis is my hypothesis. To verify it, I need to either see a hang dump of your app and dllhost.exe, or get a reproducible sample project to test locally. Do you have any special code in dllmain of the COM+ component?


    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, December 25, 2009 10:57 AM
    Moderator
  • Hello

    How are you? Could you please check out my last reply?
    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, December 29, 2009 9:13 AM
    Moderator
  • Dear Moderator(s)

    My application has been developed with ASP.Net 2.0. I need to generate a bench of excel files. So I use Microsoft.Office.Interop.Excel.Application object to generate or retrieve data from excel file. After I called that object. I already use this code to release that object.

    ExcelApplication.Quit();

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(xelSheet);

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(xelBook);

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(xelApp);

                    xelSheet = null;

                    xelBook = null;

                    xelApp = null;

                    GC.Collect();

    That application already LIVE and working smoothly since last year (2009). I face this error "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} FAILED DUE TO THE FOLLOWING ERROR:80080005." starting from last month and when I looked for the solution, All are done by same as like mine. So Please help me how to solve that issue.

     

    Thanks & Regards,

    Phyoe

    Friday, October 8, 2010 10:42 AM