Select to view content in your preferred language

Creating a predefined geographic coordinate system issue

691
3
09-29-2011 05:28 AM
AndrewHayden1
Regular Contributor
I'm working with the VB Example of creating a predefined geographic coordinate system in VS 2008 Express and I encounter the error:

'esriSRGeoCSType' is not accessible in this context because it is 'Friend'.

I'm wondering the cause of the error and how I might go about resolving it.

Any thoughts?

    Private Sub CreateGeographicReferenceSystem()
        ' Set up the SpatialReferenceEnvironment.
        ' SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.

        Dim t As Type = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment")
        Dim obj As System.Object = Activator.CreateInstance(t)
        Dim srFact As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory = obj

        ' Use the enumeration to create an instance of the predefined object.

        Dim geographicCS As IGeographicCoordinateSystem = srFact.CreateGeographicCoordinateSystem(esriSRGeoCSType.esriSRGeoCS_NAD1983)
    End Sub
0 Kudos
3 Replies
NeilClemmons
Honored Contributor
If you don't have an Imports statement at the top of the code module for the correct library you'll have to fully qualify it just like you've done here:

Dim srFact As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory = obj
0 Kudos
AndrewHayden1
Regular Contributor
Thanks Neil, but I still don't understand. 

I've got a reference to ESRI.ArcGIS.Geometry and have an imports statement for it.  My module looks like this:

Imports ESRI.ArcGIS.Geometry

Module Module1

    Private Sub CreateGeographicReferenceSystem()
        ' Set up the SpatialReferenceEnvironment.
        ' SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.

        Dim t As Type = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment")
        Dim obj As System.Object = Activator.CreateInstance(t)
        Dim srFact As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory = obj

        ' Use the enumeration to create an instance of the predefined object.

        Dim geographicCS As IGeographicCoordinateSystem = srFact.CreateGeographicCoordinateSystem(esriSRGeoCSType.esriSRGeoCS_NAD1983)
    End Sub

End Module
0 Kudos
AndrewHayden1
Regular Contributor
Okay, I see replacing

this:
Dim geographicCS As IGeographicCoordinateSystem = srFact.CreateGeographicCoordinateSystem(esriSRGeoCSType.esriSRGeoCS_NAD1983)


with this:
Dim geographicCS As IGeographicCoordinateSystem = srFact.CreateGeographicCoordinateSystem(ESRI.ArcGIS.Geometry.esriSRGeoCSType.esriSRGeoCS_NAD1983)


does the trick.  Thought, if I have the imports statement, I'm not entirely clear why.
0 Kudos