Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Object reference not set to an instance of an object"

Status
Not open for further replies.

RileyCat

Programmer
Apr 5, 2004
124
US
I have a C++ DLL which is called from a C# GUI. I know that part of it works. Where I'm getting "stuck" is when I try to fill in some data to a class member which is a structure. I keep getting hit with ...

"Object reference not set to an instance of an object."

My class looks like this ....

class CNmsOperator
{

public:
CNmsOperator(void);

void Oper_CallOper (int oper, bool reserve) ;
void Oper_RecvOper (MSG_JOB_DATA * pOprMsg) ;

bool getOperInfo () { return (OperInfo); }

private:
OPERATOR_INFO m_OperInfoObj ;

volatile JOB_INDEX_RECORD * OperKey ;

bool OperInfo ;
// TODO: add your methods here.
};

In my CPP file I declare the following ...

static JOB_INDEX_RECORD volatile GOperKey ;

/* Class Constructor ... */

CNmsOperator::CNmsOperator(void)
{
OperKey = &GOperKey ;
}

/* And the function I'm touching OperKey ... */

void CNmsOperator::Oper_CallOper (int oper, bool reserve)
{
OperInfo = false ;

ZERO (OperKey) ;
ICN_1ST_PART(OperKey->icn) = ICN_OPERATOR_PREFIX ;
if (oper != OP_DEFAULT_NEW_DB_OP)
{
ICN_2ND_PART(OperKey->icn) = oper % 100000 ;
}
else
{
ICN_2ND_PART(OperKey->icn) = oper ;
}
OperKey->headslip = 0 ;
OperKey->record_type = J_OPERATOR_INFO ;
OperKey->piece = 0 ;
OperKey->anything = reserve ;

// TODO:
NmsMsg_ProcessSend ((JOB_INDEX_RECORD *)OperKey, NmsOper_RecvOper) ;
//NmsMsg_ProcessSend (&OperKey, NmsOper_RecvOper) ;
}


I'm getting the exception as soon as I start toughing OperKey in function Oper_CallOper.

Any ideas/suggestions/recommendations would be appreciated. I'm stumped on this one.

Thanks in advance!
 
What exactly does ZERO(OperKey) do? Your description makes it sound like OperKey is NULL, which would understandably cause some problems.
 
it means GOperKey is not initialized or some member og GOperKey is not initialized. Read more attentive the description of error to see exactly which one.

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top