Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I need to create a projected coordinate system in my ArcEngine (Version 10.0) application from this .prj-file. Since I don't want to load from a file (with ISpatialReferenceFactory3.CreateESRISpatialReferenceFromPRJFile) I tried to create it with IProjectedCoordinateSystemEdit.Define:

Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
ISpatialReferenceFactory3 spatialReferenceFactory = Activator.CreateInstance(factoryType) as ISpatialReferenceFactory3;

IProjectionGEN projection = spatialReferenceFactory.CreateProjection((int)esriSRProjectionType.esriSRProjection_TransverseMercator) as IProjectionGEN;
IGeographicCoordinateSystem geographicCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCS3Type.esriSRGeoCS_ETRS1989);
ILinearUnit unit = spatialReferenceFactory.CreateUnit((int)esriSRUnitType.esriSRUnit_Meter) as ILinearUnit;

IParameter[] parameters = projection.GetDefaultParameters();
// snipped parameter setting

IProjectedCoordinateSystemEdit projectedCoordinateSystemEdit = new ProjectedCoordinateSystemClass();
object name = "ETRS_1989_UTM_Zone_32N_8stellen";
object alias = "ETRS_1989_UTM_Zone_32N_8stellen";
object abbreviation = "UTM32_8s";
object remarks = Type.Missing;
object usage = Type.Missing;
object geographicCoordinateSystemObject = geographicCoordinateSystem as object;
object unitObject = unit as object;
object projectionObject = projection as object;
object parametersObject = parameters as object;

try
{
  projectedCoordinateSystemEdit.Define(ref name, ref alias, ref abbreviation, ref remarks, ref usage, ref geographicCoordinateSystemObject, ref unitObject, ref projectionObject, ref parametersObject);
}
catch (Exception ex)
{
  Trace.WriteLine(ex.Message);
}

On the last line the whole application crashes totally (the catch block doesn't catch anything).

Any clues?

Update

I double checked it with the original sample code (first method CreateProjectedCoordinateSystem) and I get the same crash at Define.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.