Use of ISpatialReferenceFactory4.GetAreaNames

Discussion created by OlafE on Aug 27, 2012
Latest reply on Aug 28, 2012 by OlafE
I tried to use the function ISpatialReferenceFactory4.GetAreaNames to get a List of all spatialreferences. The result of the function is as PropertySet with the names of SpatialReferences as key and the SpatialReferences itself as value. My problem is that i can't cast the value from Object to ISpatialReference.

   pSpatialReferenceFactory4 = New SpatialReferenceEnvironment
   pPropertySet = pSpatialReferenceFactory4.GetAreaNames(esriCoordinateSystemFilter.esriFilterHCS, "", False, True)

   pPropertySet.GetAllProperties(pNames, pValues)
   pSpatialReference = ctype(pValues(0),ISpatialReference) --> Error

What is wrong with my Code?