前几天还正常的代码,现在怎么不行了呢?出现断言错误:
File:occsite.cpp
Line:161
选择调试将出现未处理的异常。不过Release版还能正常部分代码如下:if (!CreateControl(CLSID_WebBrowser, NULL, 
WS_VISIBLE | WS_CHILD, rcClient, pParent, AFX_IDW_PANE_FIRST)) {
        TRACE0("Unable to create control");
        return false;
    }

    LPUNKNOWN lpUnk = GetControlUnknown();
    HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp);
    if (FAILED(hr)) {
        m_pBrowserApp = NULL;
        TRACE0("Unable to create web browser");
        return false;
    }

解决方案 »

  1.   

    先打开
    File:occsite.cpp
    Line:161
    看看是那个函数的参数有错误阿。另外,使用try ,catch
      

  2.   

    File:occsite.cpp Line:161 的内容及上下文如下:HRESULT COleControlSite::CreateControl(CWnd* pWndCtrl, REFCLSID clsid,
    LPCTSTR lpszWindowName, DWORD dwStyle, const POINT* ppt, const SIZE* psize,
       UINT nID, CFile* pPersist, BOOL bStorage, BSTR bstrLicKey)
    {
    HRESULT hr = E_FAIL;
    m_hWnd = NULL;
    CSize size; // Connect the OLE Control with its proxy CWnd object
    if (pWndCtrl != NULL)
    {
    File:occsite.cpp Line:161: ASSERT(pWndCtrl->m_pCtrlSite == NULL);
    m_pWndCtrl = pWndCtrl;
    pWndCtrl->m_pCtrlSite = this;
    }奇怪的是我的程序没有修改过,前几天还正常,现在报错;而且我的程序复制到别的机器上也正常,是不是系统环境差什么冬冬?
      

  3.   

    to  jiangsheng(蒋晟.MSMVP2004Jan):
        初始化OLE库是什么函数,AfxOleInit( )还是CoInitialize(NULL)或其它?AfxOleInit( )和CoInitialize(NULL)都没发现,不过有AFX_OLE_TRUE。
        高手见笑,我是菜鸟,刚接手别人的代码,恳请指教。    补充说明,问题中创建浏览器控件的代码是在HHCTRL.CPP文件的以下函数中:
    // Copyright (C) 1998-1999 KeyWorks Software. // This class is designed for embedding a window that displays HTML content. It
    // is modeled after the CHtmlView class, but can be used as a control and has
    // additional functionality for supporting HTML Help (.CHM and .ITS file
    // support). See hhctrl.cpp for more information........
    bool CHHCtrl::Create(CWnd* pParent, const RECT& rc, DWORD dwBtns, LPCTSTR pszHomeURL, bool fText)
    {