WatiN and COM Errors: Enable IE Protected Mode for Local Intranet Zone

When we first started building up our web test suite using Watin, we quickly started getting this error:

System.Runtime.InteropServices.COMException : The interface is unknown.

If you tell IE to use Protected Mode even for Local Intranet sites, these errors don’t happen.

We weren’t the first to have this problem. The accepted solution seems to be: run Visual Studio as Administrator (see answers here and here and here).

We did; it worked.

But other than some grumblings about UAC potentially interfering with Watin’s usage of COM to control IE, there didn’t seem to be much of an explanation for what was going wrong, nor why running VS as Administrator fixed the problem.

To add to our confusion, we could use Watin extensively against public websites, such as Google’s search page, without ever encountering COM errors.

Internet Explorer has separate security settings for its Intranet and Internet zones. Typically, the Intranet settings are less restrictive, the idea being that you trust local network sites more and would prefer not to be bothered by popups, file access restrictions, and other paranoid warnings. On our machines, we noticed that the Enable Protected Mode checkbox is checked for the Internet zone, but UNchecked for the Local Intranet zone.

On a hunch, we enabled Protected Mode for Intranet sites (Tools -> Internet Options -> Security -> Local intranet) and closed all running instances of IE… the COM errors vanished and our Watin tests ran successfully.

…and we’re still not sure what the real problem is. We’re just happy we’re not stuck running Visual Studio as Administrator without understanding why.

The Watin FAQ mentions Protected Mode but only in the context of deactivating it, the implication being that Watin won’t work when Protected Mode is enabled. That post refers specifically to Windows Vista, however, and things may be different for Windows 7 and IE 8.

We’re using the following versions of aforementioned software tools:

  • Watin 2.0.2
  • Visual Studio 2010
  • Windows 7 Professional
  • Internet Explorer 8


  • Chris says:

    Thank you so much! That was driving me nuts!

  • Bobo says:

    We got such same huge pain with our tests, forced by domain security policy to play with a lot of security settings.
    And there are more with IE9 now.

  • Comments are closed.