ExecutionEngineException trying to override IInternetSecurityManager



I'm going to try to post this without having to paste in hundreds of lines
of code.

I'm trying to override IInternetSecurityManager. I'm taking sort of a
minimalist approach and adding code as I take each step because I'm not 100%
sure about what I'm doing here.

First of all, I've created a WebBrowser class. It is defined as:

public class WebBrowser : AxSHDocVw.AxWebBrowser,
IOleClientSite,
IInternetSecurityManager,
IDocHostUIHandler,
IServiceProvider

The relevant interface definitions are listed at the bottom of this post.
The interface for IDocHostUIHandler comes from MsHtmHstInterop.dll.

Now, for every implementation, I'm doing a Debug.WriteLine() with the method
name so I can see what's getting called.

My QueryService implementation is as follows:

public void QueryService(ref Guid guidService, ref Guid riid, out object
ppvObject)
{
Debug.WriteLine("QueryService");
Guid guid1 = new Guid("79eac9ee-baf9-11ce-8c82-00aa004ba90b");
if (guidService == guid1 &&
riid == guid1)
{
ppvObject = (object) this;
return;
}
ppvObject = null;
throw new COMException("", E_NO_INTERFACE);
}

QueryService gets called a bunch of times, twice matching the
IInternetSecurityManager guid.

The only other two methods called are GetHostInfo and GetOptionKeyPath. Both
methods do:

throw new COMException("", S_OK);

None of the methods in the IInternetSecurityManager interface implementation
get called.

When I call:

_webBrowser.Navigate2(ref page, ref ob, ref ob, ref ob, ref ob);

where page is: "about:blank"

After a number of QueryService calls, the two other calls mentioned, and a
bunch more QueryService calls, the Navigate2 throws a
System.ExecutionEngineException and I'm dead in the water.

Anyone have any ideas? Thanks.


Interface definitions are below:


[ComImport,
Guid("00000118-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleClientSite
{
void SaveObject();
void GetMoniker(uint dwAssign, uint dwWhichMoniker, ref object ppmk);
void GetContainer(ref object ppContainer);
void ShowObject();
void OnShowWindow(bool fShow);
void RequestNewObjectLayout();
}

[ComImport, GuidAttribute("79EAC9EE-BAF9-11CE-8C82-00AA004BA90B")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IInternetSecurityManager
{
[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int SetSecuritySite([In] IntPtr pSite);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int GetSecuritySite([Out] IntPtr pSite);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int MapUrlToZone([In,MarshalAs(UnmanagedType.LPWStr)] string pwszUrl,
out UInt32 pdwZone, UInt32 dwFlags);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int GetSecurityId([MarshalAs(UnmanagedType.LPWStr)] string pwszUrl,
[MarshalAs(UnmanagedType.LPArray)] byte[] pbSecurityId,
ref UInt32 pcbSecurityId, uint dwReserved);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int ProcessUrlAction([In,MarshalAs(UnmanagedType.LPWStr)] string
pwszUrl,
UInt32 dwAction, out byte pPolicy, UInt32 cbPolicy,
byte pContext, UInt32 cbContext, UInt32 dwFlags,
UInt32 dwReserved);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int QueryCustomPolicy([In,MarshalAs(UnmanagedType.LPWStr)] string
pwszUrl,
ref Guid guidKey, ref byte ppPolicy, ref UInt32 pcbPolicy,
ref byte pContext, UInt32 cbContext, UInt32 dwReserved);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int SetZoneMapping(UInt32 dwZone,
[In,MarshalAs(UnmanagedType.LPWStr)] string lpszPattern,
UInt32 dwFlags);

[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int GetZoneMappings(UInt32 dwZone, out UCOMIEnumString ppenumString,
UInt32 dwFlags);
}

[ComImport, GuidAttribute("6D5140C1-7436-11CE-8034-00AA006009FA")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IServiceProvider
{
void QueryService(ref Guid guidService, ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out object ppvObject);
}




.



Relevant Pages

  • Re: ExecutionEngineException trying to override IInternetSecurityManager
    ... void QueryService(ref Guid guidService, ref Guid riid, ... out UInt32 pdwZone, UInt32 dwFlags); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: WMEncoder
    ... public Guid majortype; ... int GetLength( ... void GetStreamNumber( ... ref int pcchStreamName); ...
    (microsoft.public.windowsmedia.sdk)
  • Re: .NET and IE Favourites
    ... public enum FMTID_InternetSite: int ... , ref propertyStorage); ... public static void PrintUrlMetadata(IPropertyStorage ...
    (microsoft.public.dotnet.framework.interop)
  • .NET and IE Favourites
    ... public enum STGM: int ... , ref propertyStorage); ... ref System.Guid rfmtid, ... public void FromObject ...
    (microsoft.public.dotnet.framework.interop)
  • RE: Difference between out and ref parameters.
    ... you don't have to initialize an "out" parameter before passing it to a method ... int x = 0; ... void add ... > 'ref' parameter passes the object into the Method by Reference, ...
    (microsoft.public.dotnet.general)

Loading