<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2838" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=343072316-29032006>Visual Studio .NET
2005 doesn't like what is happening with the OGR MapInfo driver. In debug mode,
the first time that I try to create a datasource it always fails. Sometimes, if
I try again immediately (i.e. in the catch()) it will succeed. The exception
message is:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=343072316-29032006></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=343072316-29032006>System.AccessViolationException occurred<BR>
Message="Attempted to read or write protected memory. This is often an
indication that other memory is corrupt."<BR>
Source="GDALWrapper"<BR>
StackTrace:<BR> at
GDALWrapper.OGR.OgrInterop.OGR_Dr_CreateDataSource(HandleRef hDriver, String
pszName, String[]& papszOptions)<BR> at
GDALWrapper.OGR.OgrDriver.CreateDataSource(String folderName, List`1 options) in
D:\Code\online_tracking\ONAT\GDALWrapper\OGR\OgrDriver.cs:line
62<BR></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=343072316-29032006>If I compile the OGR
C# wrapper project in Release mode, it works more consistently, but still always
fails the first time.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=343072316-29032006></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=343072316-29032006>This does not happen
with CSV, ESRI drivers in debug or release.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=343072316-29032006></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=343072316-29032006>Running the
executable outside the IDE works fine as well.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=343072316-29032006></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=343072316-29032006>My test code is very
simple. Any thoughts or suggestions are welcome.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=343072316-29032006></SPAN></FONT> </DIV>
<DIV><FONT><SPAN class=343072316-29032006> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#0000ff>public</FONT>
<FONT color=#0000ff>class</FONT> <FONT
color=#008080>OgrTest</DIV></FONT></FONT></FONT>
<DIV><FONT face="Courier New" size=2>{</FONT></DIV>
<DIV><FONT color=#008000><FONT size=2><FONT face="Courier New"><SPAN
class=343072316-29032006> </SPAN>//private string driverName =
"CSV";</FONT></FONT></FONT></DIV>
<DIV><FONT color=#008000><FONT size=2><FONT face="Courier New"><SPAN
class=343072316-29032006> </SPAN>//private string driverName =
"ESRI Shapefile";</FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#0000ff><SPAN
class=343072316-29032006> </SPAN>private</FONT> <FONT
color=#0000ff>string</FONT> driverName = <FONT color=#800000>"MapInfo
File"</FONT>;</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#0000ff><SPAN
class=343072316-29032006> </SPAN>private</FONT> <FONT
color=#008080>List</FONT><<FONT color=#0000ff>string</FONT>> driverOptions
= <FONT color=#0000ff>new</FONT> <FONT color=#008080>List</FONT><<FONT
color=#0000ff>string</FONT>>();</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#0000ff><SPAN
class=343072316-29032006> </SPAN>private</FONT> <FONT
color=#0000ff>string</FONT> folderName = <FONT
color=#800000>@"D:\temp\simpletest"</FONT>;</FONT></FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#0000ff><SPAN
class=343072316-29032006> </SPAN>public</FONT> <FONT
color=#0000ff>void</FONT> Test()</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN
class=343072316-29032006> </SPAN>{</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#008080><SPAN
class=343072316-29032006>
</SPAN>OgrDriver</FONT>.OgrRegisterAll();</FONT></FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#008080><SPAN
class=343072316-29032006>
</SPAN>OgrDriver</FONT> driver = <FONT
color=#008080>OgrDriver</FONT>.GetDriverByName(driverName);</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#0000ff><SPAN
class=343072316-29032006>
</SPAN>if</FONT> (driver == <FONT color=#0000ff>null</FONT>)</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN
class=343072316-29032006>
</SPAN>{</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#0000ff><SPAN
class=343072316-29032006>
</SPAN>throw</FONT> <FONT color=#0000ff>new</FONT> <FONT
color=#008080>ArgumentOutOfRangeException</FONT>(driverName + <FONT
color=#800000>" driver not available."</FONT>);</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN
class=343072316-29032006>
</SPAN>}</FONT></FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN
class=343072316-29032006>
</SPAN>driverOptions.Add(<FONT
color=#0000ff>string</FONT>.Empty);</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#008080><SPAN
class=343072316-29032006>
</SPAN>OgrDataSource</FONT> dataSource = driver.CreateDataSource(folderName,
driverOptions);</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#0000ff><SPAN
class=343072316-29032006>
</SPAN>if</FONT> (dataSource == <FONT
color=#0000ff>null</FONT>)</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN
class=343072316-29032006>
</SPAN>{</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><FONT color=#0000ff><SPAN
class=343072316-29032006>
</SPAN>throw</FONT> <FONT color=#0000ff>new</FONT> <FONT
color=#008080>ArgumentException</FONT>(<FONT color=#800000>"Output folder
creation failed."</FONT>);</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN
class=343072316-29032006>
</SPAN>}</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN
class=343072316-29032006>
</SPAN>dataSource.Release();</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN
class=343072316-29032006> </SPAN>}</FONT></FONT></DIV>
<DIV><FONT face="Courier New" size=2>}</FONT></DIV></SPAN></FONT></BODY></HTML>