0

Hi I am developing a BHO for IE in C#. I want to open a URL in a new Tab when user click's on my extension button.

I am using IOleCommandTarget interface methods to catch the click events. But those methods don't give any object of browser that can be used to call the navigate method. So, have to try other means like the one mentioned below.

public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
        {
            try
            {
                InternetExplorer ie = null;

                SHDocVw.ShellWindows allBrowser = new SHDocVw.ShellWindows();
                int browserCount = allBrowser.Count - 1;

                while (browserCount >= 0)
                {
                    ie = allBrowser.Item(browserCount) as InternetExplorer;

                    if (ie != null && ie.FullName.ToLower().Contains("iexplore.exe"))
                    {
                      ie.Navigate2(SNXFileNames.ActivationPage, 0x1000);
                      break;
                    }

                    browserCount--;
                }            
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return 0;
        }

This method works find in development machine but in non-development machine it gives access denied error.

System.UnauthorizedAccessException: Retrieving the COM class factory fro component with CLSID{} failed due to the following error: 80070005 Access is denied.

Usama Mohsin
  • 79
  • 1
  • 2
  • 11

1 Answers1

0

What is the OS version of the non-development machine? This error is usually caused by wrong settings for access on COM component your code tries to create.

You could try to start DCOMCNFG, go to DCOM settings, select required object and allow access to it for the account your C# code runs under.

You could also try the general solution:

  1. In DCOMCNFG, right click on the My Computer and select properties.
  2. Choose the COM Securities tab.
  3. In Access Permissions, click Edit Defaults and add Network Service to it and give it Allow local access permission. Do the same for < Machine_name >\Users.
  4. In Launch and Activation Permissions, click Edit Defaults and add Network Service to it and give it Local launch and Local Activation permission. Do the same for < Machine_name >\Users.

Reference link: Retrieving the COM class factory for component failed

Yu Zhou
  • 11,532
  • 1
  • 8
  • 22