SNMP程序 release版本的有关问题

SNMP程序 release版本的问题
我的程序很奇怪,在VC编译下,debug版本没有问题。但是release版本总是在第二次接受数据的时候,发生崩溃,不知道为什么?

CSnmp::CSnmp()
{
nMajorVersion=new   unsigned   long;
nMinorVersion=new   unsigned   long;
nLevel=new   unsigned   long;
nTranslateMode=new   unsigned   long;
nRetransmitMode=new   unsigned   long;
if(SnmpStartup(nMajorVersion,nMinorVersion,nLevel,nTranslateMode,
nRetransmitMode)!=SNMPAPI_SUCCESS)
{
AfxMessageBox( "initilization   failure ");
}
if(SnmpSetTranslateMode(SNMPAPI_UNTRANSLATED_V2)   !=   SNMPAPI_SUCCESS)
AfxMessageBox( "SetTranslateMode   failure ");
if(SnmpSetRetransmitMode(SNMPAPI_ON)   !=   SNMPAPI_SUCCESS)
AfxMessageBox( "SetRetransmitMode   failure ");
sessionID=FALSE;
}

CSnmp::~CSnmp()
{
if(nRetransmitMode!=NULL)
delete   nRetransmitMode;
if(nTranslateMode!=NULL)
delete   nTranslateMode;
if(nLevel!=NULL)
delete   nLevel;
if(nMinorVersion!=NULL)
delete   nMinorVersion;
if(nMajorVersion!=NULL)
delete   nMajorVersion;
if(session!=NULL)
SnmpClose(session);
SnmpCleanup();
}

CSnmp::CreateSession(HWND   hWnd,UINT   wMsg)
{
if((session=SnmpCreateSession(hWnd,wMsg,NULL,NULL))==SNMPAPI_FAILURE)
AfxMessageBox( "CreateSession   failure ");
}

CSnmp::CreateVbl(LPCSTR   name,smiLPVALUE   pvalue)
{
smiOID   pOid;
if(SnmpStrToOid(name,&pOid)==SNMPAPI_FAILURE)
{
AfxMessageBox( "CreateVbl   failure ");
}
m_hvbl=SnmpCreateVbl(session,&pOid,pvalue);
if(m_hvbl==SNMPAPI_FAILURE)
{
AfxMessageBox( "CreateVbl   failure ");
}
if(SnmpFreeDescriptor(SNMP_SYNTAX_OID,(smiLPOPAQUE)&pOid)   !=   SNMPAPI_SUCCESS)      
AfxMessageBox( "freedescriptor       failure ");  
}

CSnmp::SetVbl(LPCSTR   name)
{
smiOID   pOid;
if(SnmpStrToOid(name,&pOid)==SNMPAPI_FAILURE)
{AfxMessageBox( "SetVbl   failure--oid ");
//dwErr=SnmpGetLastError(session);
}
if(SnmpSetVb(m_hvbl,0,&pOid,NULL)==SNMPAPI_FAILURE)
{AfxMessageBox( "SetVbl   failure ");
//dwErr=SnmpGetLastError(session);
}
if(SnmpFreeDescriptor(SNMP_SYNTAX_OID,(smiLPOPAQUE)&pOid)   !=   SNMPAPI_SUCCESS)      
AfxMessageBox( "freedescriptor       failure ");  
}


CSnmp::CreatePdu(smiINT   PDU_type,smiINT32   request_id,
  smiINT   error_status,smiINT   error_index)
{
m_hpdu=SnmpCreatePdu(session,PDU_type,request_id,error_status,error_index,m_hvbl);
if(m_hpdu==SNMPAPI_FAILURE)
{
AfxMessageBox( "CreatePdu   failure ");
}
else   if   (error_status   >   0)
{
              AfxMessageBox( "Error:   error_status=%d,   error_index=%d\n ",error_status,   error_index);
        }
}

CSnmp::Send(LPCSTR   address,const   char   *   community)
{
// oldMemState.Checkpoint();
HSNMP_ENTITY   hAgent;
if((hAgent=SnmpStrToEntity(session,address))==SNMPAPI_FAILURE)
AfxMessageBox( "SendMsg   failure--entity ");
smiOCTETS   contextName;
contextName.ptr=(unsigned   char   *)community;