You're using the HARN PCS which probably isn't the VA State Plane that you want. Since you're needing to project your coordinates into the PCS of the map, then just get the spatial reference of the map instead of creating it using the spatial reference environment. This will make your code work no matter what spatial reference the map is in. You'll still need to create the GCS according to whatever system your input coordinates are in. Unless, of course, you're getting those from a feature class or something that also has a spatial reference (in which case, just get the SR from that instead of creating it). As for your error, try using SpatialReferenceEnvironment (without the Class on the end).
Thanks for all the comments, feedback and help.
I removed 'Class' from SpatialReferenceEnvironment and receive another COM exception:
Retrieving the COM class factory for component with CLSID {7B5B7020-C4F6-11D1-BC92-0000F875BCCE} failed due to the following error: 80040111 ClassFactory cannot supply requested class (Exception from HRESULT: 0x80040111 (CLASS_E_CLASSNOTAVAILABLE)).
I'm not a COM developer, so this is a little foreign to me.
A bit more on the map I am using. I was handed a MXD file that has Virginia's map data (Danville area), and in order to track across the US, ESRI's North America Street Map data was also added. The map as previously indicated should be projected in the Virginia State Plane. I did change by PCS to esriSRProjCSType.esriSRProjCS_NAD1983SPCS_VASouthFT, but as I mentioned, I get the error mentioned above.
If I can get past that error, that would be great. Is there something I have to do to put a wrapper around Arc Objects COM object?
Thanks for the help.
Bob
Hi Bob,
I tell people that I'm barely a programmer (I do enough for testing, but it sure isn't 'elegant') so I can't tell if you're using VB6 or VB.Net code, or maybe something else.
For VB6, try
Dim pSpatRefFact As SpatialReferenceEnvironment
Set pSpatRefFact = New SpatialReferenceEnvironment
and you also need to use
Set pGCS = pSpatRefFact.CreateGeographicCoordinateSystem(enum)
For VB.Net, try
Dim t As Type = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment")
Dim obj As System.Object = Activator.CreateInstance(t)
Dim pSpatRefFact As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory3 = obj
Melita
I have similar problem when I tried to migrate my 9.3 C# code to 10.0.
I got error message for
ISpatialReferenceFactory spatialReferenceFactory2 = new SpatialReferenceEnvironmentClass();
the error message is "Retrieving the COM class factory for component with CLSID {7B5B7020-C4F6-11D1-BC92-0000F875BCCE} failed due to the following error: 80040111."
Then I tried to use activator so I revised the code to following:
// Set up the SpatialReferenceEnvironment.
// SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
System.Object object1 = Activator.CreateInstance(factoryType);
ISpatialReferenceFactory2 spatialReferenceFactory2 = object1 as ISpatialReferenceFactory2;
However, I still got the same error message.
Can anyone help on this one?
Thanks a lot.
Wei
Hi Wei,
Another post with a similar issue said that he needed to add this:
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine);
(or other licensing information).
Melita
Hi,
I'm trying also to migrate my code from v9.3 (where it runs fine) to v10 but without any success. The error I'm getting is the same to what the other folks report here: "Retrieving the COM class factory for component with CLSID {7B5B7020-C4F6-11D1-BC92-0000F875BCCE} failed due to the following error: 80040111". I have followed all the instructions posted on the ESRI website about the migration. My code uses only the ArcGIS engine and debugging completes with no errors (C#, VS2008SP1). The binding to the appropriate ArcGIS runtime works fine, the license initialization the same but when I try to create a new instance of the SpatialReferenceEnvironment I get the exception above. In case you are wondering, the ArcGIS Migration Code Analyzer doesn't throw any errors when I test my projects (only a warning that I have to change the target CPU to x86). Can somebody help?
Thanks
K.