<div dir="ltr"><div>Hi List,</div><div><br></div>We use GDAL v3+ in our Open Source mapping application MapWinGIS.<div>We build using VS2019 on Windows and we use the files from GisInternals.</div><div><br></div><div>We have a GeoProjection class which in turn calls some/most OGRSpatialReference methods.</div><div>When calling OGRSpatialReference.importFromESRI() compiled for Win32 we have no issues.</div><div>When calling the same code compiled for Win64 we get this exception:</div><div><font face="monospace">Exception thrown at 0x00007FFD93074839 (gdal304.dll) 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF</font></div><div><br></div><div>We also implement the very similar method importFromWkt(). This method has no issues on Win32 or Win64.</div><div><br></div><div>Here's some relevant code from GeoProjection.cpp:</div><div><font face="monospace">STDMETHODIMP CGeoProjection::ImportFromESRI(const BSTR proj, VARIANT_BOOL* retVal)<br>{<br> AFX_MANAGE_STATE(AfxGetStaticModuleState())<br> USES_CONVERSION;<br><br> const CString s = OLE2A(proj);<br> const OGRErr err = ProjectionHelper::ImportFromEsri(_projection, s);<br><br> *retVal = err == OGRERR_NONE ? VARIANT_TRUE : VARIANT_FALSE;<br> if (err != OGRERR_NONE)<br> {<br> ReportOgrError(err);<br> }<br> return S_OK;<br>}</font><br></div><div><br></div><div><font face="monospace">STDMETHODIMP CGeoProjection::ImportFromWKT(const BSTR proj, VARIANT_BOOL* retVal)<br>{<br> AFX_MANAGE_STATE(AfxGetStaticModuleState())<br> USES_CONVERSION;<br><br> const CString s = OLE2A(proj);<br> const OGRErr err = ProjectionHelper::ImportFromWkt(_projection, s);<br><br> *retVal = err == OGRERR_NONE ? VARIANT_TRUE : VARIANT_FALSE;<br> if (err != OGRERR_NONE)<br> {<br> ReportOgrError(err);<br> }<br> return S_OK;<br>}</font><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><div dir="ltr">And from ProjectionHelper.cpp:</div><div dir="ltr"><font face="monospace">OGRErr ProjectionHelper::ImportFromEsri(OGRSpatialReference* sr, CString proj)<br>{<br> if (!sr) {<br> return false;<br> }<br><br> char* s = proj.GetBuffer();<br> return sr->importFromESRI(&s);<br>}</font></div><div dir="ltr"><br></div><div dir="ltr"><font face="monospace">OGRErr ProjectionHelper::ImportFromWkt(OGRSpatialReference* sr, CString proj)<br>{<br> if (!sr) {<br> return false;<br> }<br><br> char* s = proj.GetBuffer();<br> return sr->importFromWkt(&s);<br>}</font><br>
<br>We're currently upgrading from GDAL2+ to GDAL3+.</div><div dir="ltr">Users report the crash in both versions.</div><div dir="ltr"><br></div><div dir="ltr">Most likely we're not calling the <span style="font-family:monospace">importFromESRI</span> correctly.</div><div>Please advice.</div><div><br></div><div>Regards,</div><div dir="ltr"><br>Paul Meems</div><div dir="ltr"><a href="https://github.com/MapWindow/MapWinGIS">https://github.com/MapWindow/MapWinGIS</a><br></div><div dir="ltr"><br></div><div dir="ltr"><br></div></div></div></div></div></div></div></div></div></div>