<div dir="ltr"><div><br></div><div>If I create a shapefile layer like so:</div><div>const char *pszShpDriverName = "ESRI Shapefile";</div><div>OGRSFDriver *poShpDriver;</div><div>poShpDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(pszShpDriverName);</div>
<div>poShpDS = poShpDriver->CreateDataSource(pszDstFilename, NULL);</div><div>poShpLayer = poShpDS->CreateLayer( "poly_out", NULL, wkbPolygon, NULL );</div><div><br></div><div><br></div><div>and close it like so:</div>
<div>OGRDataSource::DestroyDataSource(poShpDS);</div><div><br></div><div><br></div><div>I have no problems, but if I specify a projection for it from an open GeoTiff I have </div><div>as the data set "poDataset" like so:</div>
<div><br></div><div>OGRSpatialReference *poSrcSRS = new OGRSpatialReference(poDataset->GetProjectionRef());</div><div><br></div><div><br></div><div>const char *pszShpDriverName = "ESRI Shapefile";</div><div>OGRSFDriver *poShpDriver;</div>
<div>poShpDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(pszShpDriverName);</div><div>poShpDS = poShpDriver->CreateDataSource(pszDstFilename, NULL);</div><div>poShpLayer = poShpDS->CreateLayer( "poly_out", poSrcSRS, wkbPolygon, NULL );</div>
<div><br></div><div>I get this error when I go to shut my application down after using the above code be it in a dll or in a console app.</div><div><br></div><div>The error I get is:</div><div>First-chance exception at 0x7c90e4ff in TestApp.exe: 0xC0000008: An invalid handle was specified</div>
<div><br></div><div>that jumps my debugger to crt0dat.c to this method:</div><div><br></div><div>void __cdecl __crtExitProcess (</div><div> int status</div><div> )</div><div>{</div><div> __crtCorExitProcess(status);</div>
<div><br></div><div> /*</div><div> * Either mscoree.dll isn't loaded,</div><div> * or CorExitProcess isn't exported from mscoree.dll,</div><div> * or CorExitProcess returned (should never happen).</div>
<div> * Just call ExitProcess.</div><div> */</div><div><br></div><div> ExitProcess(status);</div><div>}</div><div><br></div><div><br></div><div>This only happens when I create the file using a projection and it doesn't seem to matter if I build the projection myself or get it from the GeoTiff. It seems to be the creation of the .prj file that is the problem.</div>
<div><br></div><div>I could always just create my own prj file in the same directory and spit out the WKT to it but I would rather not if I don't have to.</div><div><br></div><div>Anyone know a fix for this?</div><div>
<br></div><div>Thank You,</div><div>Andy Canfield</div></div>