程序运行时出现0x00405cf6 处未处理的异常: 0xC0000005: 读取位置 0x00000000 时发生访问冲突我单步调试 跳到COMUTIL.H中的如下代码段里。inline _variant_t::_variant_t(IDispatch* pSrc, bool fAddRef) throw(){V_VT(this) = VT_DISPATCH;V_DISPATCH(this) = pSrc;
// Need the AddRef() as VariantClear() calls Release(), unless fAddRef// false indicates we're taking ownership//if (fAddRef) {V_DISPATCH(this)->AddRef();(跳到这一句)}}是什么错误,求指教!

解决方案 »

  1.   

    好象是_variant_t这个类型的变量没有初始化或这个类型的值是NULL,你往回找到这个类型的变量
      

  2.   

    每次只要调用这个函数就会出现那样的错误,这个函数是我照书上写的。没有_variant_t类型的变量啊!_RecordsetPtr& ADOConn::GetRecordSet(_bstr_t bstrSQL)
     {
     try
     {
     //if (m_pConnection==NULL)
    //  OnInitADOConn();
     m_pRecordset.CreateInstance(__uuidof(Recordset));
     m_pRecordset->Open(bstrSQL,(_variant_t)m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
     }
    catch(_com_error e)
    {   AfxMessageBox(e.Description());
     
    }
     return m_pRecordset;
     }
     
      

  3.   

    AddRef()给这个接口指针的计数加1IDispatch* pSrc这个是不是有问题啊?