Object reference not set to an instance of an object

Hi Team,
can anyone help me what could be the issue here

i am getting this" object reference not set to an instance of an object" error in my DP class. i have created the contract class. regardless of data provided in report dialog or not, in dp it is throwing me error.
if data are passed in report dialog, i can see the return data in my contract class while debugging.
but still i am getting the error.
contract class:
[DataMemberAttribute(‘Product Type’),
SysOperationLabelAttribute(literalStr(“Product Type”))]
public ItemId parmProductType(ItemId _productType = productType)
{
productType = _productType;

    return productType;
}

[DataMemberAttribute('Account Number'),
     SysOperationLabelAttribute(literalStr("Account Number"))]
public CustAccount parmCustAccount(CustAccount _accountNumber = accountNumber)
{
    accountNumber = _accountNumber;

    return accountNumber;
}

Dp Class:
contract = this.parmDataContract() as AAMAasAudtReportContract;
qbds = this.parmQuery().dataSourceTable(tableNum(projTable));

    if(contract.parmProductType())
    {       qbds.addRange(fieldNum(projTable,AAMProductType)).value(queryValue(contract.parmProductType())) ;
    }
    if(contract.parmCustAccount() )
    {qbds.addRange(fieldNum(projTable,CustAccount)).value(queryValue(contract.parmCustAccount()));
    }

thankx in advance.

The error suggests that contract contains null. You can verify it in debugger.
If your code to assign the value is this:
contract = this.parmDataContract() as AAMAasAudtReportContract;
then there are two possible explanations:

  1. parmDataContract() returns null
  2. parmDataContract() retruns a value, but the data type of the value isn’t AAMAasAudtReportContract.

Please use use the debugger to find out what happens in your particular case. We can’t say that just by looking at your code snippets.

i have debugged the code
In dp class parmDataContract() returns a null value.
In contract it is returning the value which I am passing in report.
contract = this.parmDataContract() as AAMAasAudtReportContract; in this particular piece of code it is returning null. is there any specific reason why it is returning null.

Yes, there is a reason. You wrote it down here:

If parmDataContract() returns null, then your statement assigns null to contract.

Unfortunately it’s not clear to me what you mean by this:

Thank you so much . I found out the reason. there was something wrong with my contract class variable assignment .