none
Exception at IPersistMoniker.Load RRS feed

  • Question

  • Hi,

     

    I am trying to use com interop to render a web page using mshtml. I get “Attempted to read or write protected memory. This is often an indication that other memory is corrupt.” at IPersistMoniker.Load. Here is my code,

     

    object objhtmlDoc;

                  uint hResult = CoCreateInstance(ref IId_Clsids.CLSID_HTMLDocument, null, CLSCTX_INPROC_SERVER, ref IId_Clsids.IID_IHTMLDocument2, out objhtmlDoc);

                  System.Runtime.InteropServices.ComTypes.IConnectionPointContainer pCPC = (System.Runtime.InteropServices.ComTypes.IConnectionPointContainer)objhtmlDoc;

                  System.Runtime.InteropServices.ComTypes.IConnectionPoint m_pCP;

                  pCPC.FindConnectionPoint(ref IId_Clsids.IID_IPropertyNotifySink, out m_pCP);

                  m_pCP.Advise(this, out m_dwCookie);

                  ((IUnknown)pCPC).Release();

                  string url = "www.asdf.com";

                  IMoniker pMk;             

                  CreateURLMonikerEx(null, url, out pMk, URL_MK_UNIFORM);             

                  IBindCtx pBCtx;

                  CreateBindCtx(0, out pBCtx);

                  IPersistMoniker pPMk = (IPersistMoniker)objhtmlDoc;

                  pPMk.Load(0, pMk, pBCtx, STGM_READ);   //<- I get exception here

     

     

    Interface definition of IPersistMoniker is:

    [ComImport, ComVisible(true),

    Guid("79eac9c9-baf9-11ce-8c82-00aa004ba90b"),

    InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]

            public interface IPersistMoniker

            {

                void GetClassID(

                    [In, Out] ref Guid pClassID);

     

                [return: MarshalAs(UnmanagedType.I4)]

                [PreserveSig]

                int IsDirty();

     

                void Load([In] bool fFullyAvailable,

                    [In, MarshalAs(UnmanagedType.Interface)] IMoniker pmk,

                    [In, MarshalAs(UnmanagedType.Interface)] Object pbc,

                    [In, MarshalAs(UnmanagedType.U4)] uint grfMode);

     

                void SaveCompleted(

                    [In, MarshalAs(UnmanagedType.Interface)] IMoniker pmk,

                    [In, MarshalAs(UnmanagedType.Interface)] Object pbc);

     

                [return: MarshalAs(UnmanagedType.Interface)]

                IMoniker GetCurMoniker();

            }

     

    I tried various combinations of parameter list for IPersistMoniker.Load to make this work, for example by passing pmk and/or pbc  as reference but nothing seems to be working. I would appreciate if anybody could tell me how to fix this error.

     

    Thursday, October 21, 2010 10:32 PM

All replies

  • From a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with us. Visit this link to see the various support options that are available to better meet your needs:  http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone.
    --Trevor H.
    Send files to Hotmail.com: "MS_TREVORH"
    Check out the Microsoft CTS TFS BLOG: blogs.msdn.com/b/dstfs
    Friday, October 29, 2010 7:47 PM
    Moderator