I have the following code:

Code:
// Get all of the children components from this m_Component object
_variant_t componentChildren = pComponent->GetChildren();
The returned variant contains a SafeArray of IDispatch pointers. I have verified that the count of the SafeArray is correct, but the IDispatch pointers are all NULL.

I extract the array elements like below:

Code:
if ((componentChildren.vt == VT_EMPTY) || (V_VT(&componentChildren) == VT_NULL)) // Error - array is empty or null
	return 0;       

SAFEARRAY* psa = V_ARRAY(&componentChildren);
HRESULT hres = SafeArrayAccessData(psa, (void **)pChildren); 
long highIndex;

SafeArrayGetUBound(psa, 1, &highIndex); // Get index number of highest array element

// The array range is from 0 to highIndex

long childrenCount = highIndex + 1;  // Actual # of array elements is highIndex + 1

if(pChildren)
{
	// Recursively traverse the children
	for (int i = 0; i < childrenCount; i++) // For each child component
	{
		TraverseChildren(RecurseLevel, pChildren[i]);
	}
}
The pChildren[i] causes an access violation error.

What could be the probable reasons for this. Please help I am stuck in this.