Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: Cannot Retrieve Top-Level IWebBrowser2 Interface from a .NET UserControl


View products that this article applies to.

Symptoms

Previously, you could retrieve the top-level IWebBrowser2 reference in the SetClientSite method of the IOleObject interface as follows:
  1. Call the QueryInterface method on the client site for the IServiceProvider interface.
  2. Call the QueryService method for IID_IServiceProvider under the SID_STopLevelBrowser service.
  3. From the second IServiceProvider, call QueryService for IID_IWebBrowser2 in the SID_SWebBrowserApp service.
However, you cannot retrieve the top-level IWebBrowser2 interface from a default UserControl object.

↑ Back to the top


Cause

IWebBrowser2 and the other interfaces that the browser exposes are unmanaged functions. You must have unmanaged code permission to call unmanaged functions. You are not granted this permission by default for controls that run in the browser because this requires a high level of trust.

Once someone has unmanaged code permission, that person can do potentially anything that he or she wants from the control. By design, UserControl objects cannot access vulnerable information in a client's computer, and UserControl objects do not need to access this information to function.

↑ Back to the top


Resolution

To retrieve the IWebBrowser2 interface and use it from within an UserControl object, you must include a managed wrapper around IWebBrowser2 that is safe to call from controls that run in the browser. Microsoft does not currently have any wrapper classes available to accomplish this task.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


References

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
257717 HOWTO: Retrieve the Top-Level IWebBrowser2 Interface from an ActiveX Control
For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

↑ Back to the top


Keywords: KB311299, kbprb, kbcontrol

↑ Back to the top

Article Info
Article ID : 311299
Revision : 7
Created on : 2/12/2007
Published on : 2/12/2007
Exists online : False
Views : 533