none
Retrieving the COM class factory for component with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} failed due to the following error: 80070002 RRS feed

  • Question


  • Hi,

    I am developing application for system monitoring and statistics collecting. The last component I developed is IE daemon which registers information about visited hosts (a list containing host name and visit count). It seamed that everything works just fine, but know I'm keep getting an error "Retrieving the COM class factory for component with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} failed due to the following error: 80070002".

    Some important facts about the application:
    1. This applications is starting instead of shell (although later on it starts explorer)
    2. Interop.ShDocVw.dll is compiled into application and loaded dynamically
     
    How do exception is thrown
    1. Start application
    2. Close application (close from application, log off, but NOT terminate)
    3. Log off and Log in with the same user
    4. Application is started as shell (instead of explorer)
    5. Here's our exception in IEDaemon.startMonitoring() at line 1

    FAQ:
    Q: This exception is thrown because Interop.ShDocVw.dll is not found and/or failed to load from assembly.
    A: If you take a closer look you gonna notice that all event hadlers in IEDaemon constuctor are also defined in Interop.ShDocVw.dll so exception would rise there first.
    Q: Do this exception rise when application is terminated and started again?
    A: No.
    Q: Do this exception rise after restart?
    A: No.
    Q: Would it help if the method IEDaemon.stopMonitoring() would be skipped while closing?
    A: No.

    Code fragments:
    1. IEDaemon constuctor:
    1             registerHandler = new DShellWindowsEvents_WindowRegisteredEventHandler(shellWindows_WindowRegistered); 
    2             revokeHandler = new DShellWindowsEvents_WindowRevokedEventHandler(shellWindows_WindowRevoked); 
    3             navCompleteHandler = new DWebBrowserEvents2_NavigateComplete2EventHandler(ie_DocumentComplete); 
    4             navErrorHandler = new DWebBrowserEvents2_NavigateErrorEventHandler(ie_navigationError); 


    2. IEDaemon.startMonitoring()
    1                 shellWindows = new ShellWindowsClass(); 
    2                 //registering shell events listeners 
    3                 shellWindows.WindowRegistered += registerHandler; 
    4                 shellWindows.WindowRevoked += revokeHandler; 


    3. IEDaemon.stopMonitoring():
    1                 //droping shell listeners 
    2                 shellWindows.WindowRegistered -= registerHandler; 
    3                 shellWindows.WindowRevoked -= revokeHandler; 
    4  
    5                 // droping ie listeners 
    6                 int i = 1; 
    7                 foreach (InternetExplorer ie in shellWindows) 
    8                 { 
    9                     Logger.info("0: Removing handler (" + i + ")"); 
    10                     try 
    11                     { 
    12                         ie.NavigateComplete2 -= navCompleteHandler; 
    13                         ie.NavigateError -= navErrorHandler; 
    14                         while (Marshal.ReleaseComObject(ie) > 0) ; 
    15                     } 
    16                     catch (Exception e) 
    17                     { 
    18                         Logger.warning("Failed to drop IE listener. " + e.TargetSite.ToString() + ". " + e.Message.ToString()); 
    19                     } 
    20                     i++; 
    21                 } 
    22                 windowsList.Clear(); 
    23  
    24                 // make sure we drop everything. This may cause exception if reruned in the same session!!!! 
    25                 while (Marshal.ReleaseComObject(shellWindows) > 0) ; 
    26                 Marshal.FinalReleaseComObject(shellWindows); 
    27                 GC.Collect(); 
    28                 GC.WaitForPendingFinalizers(); 

    • Edited by dziastinux Tuesday, October 14, 2008 1:27 PM
    Tuesday, October 14, 2008 1:26 PM

Answers

All replies

  • Put Interop.ShDocVw.dll in the GAC.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Monday, October 20, 2008 11:16 AM
    Tuesday, October 14, 2008 8:06 PM
    Moderator
  • Hi, I was just wondering if there was any other way other than putting it in the GAC?
    When running my app from our web farm I get the same error as dziastinux Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medalsabove. Also when I dump the contents of my GAC to a text file I can't see Interop.ShDocVw.dll in there, yet my app works fine on my development machine.

    Thanks.

    lf
    Friday, October 30, 2009 4:36 PM
  • Hi,

    I am facing exactly same issue and my code is pretty similar to the above one.

    Please let me know whether placing the dll in GAC is the only solution or can something else be done?

    Also, I get this error intermittently and not always.

    Thanks.

    • Proposed as answer by zzppallas Tuesday, August 20, 2013 10:08 AM
    Monday, January 16, 2012 10:41 AM
  • Same with me.

    When in simple console app, this code works fine:

    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
                // ...
            }
        }
    }
    
    

    But when in class - it fails:

    namespace MyNamespace
    {
        internal class MyClass
        {
            public void Run()
            {
                SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
                // ...
            }
        }
        public partial class Form1 : Form
        {
            private void SomeEventHandler(...)
            {
                MyClass mc = new MyClass();
                mc.Run();
            }
        }
    }
    
    

    Or maybe app type makes difference? (console / winforms)

    Monday, January 23, 2012 10:48 AM