<br><font size=2 face="sans-serif">Are you sure you are instantiating an
instance of the class and referring to the correct one?  Take a look
at the sample code in the NetTest, which runs through much of the functionality
of shapelib including dbf read/writes.</font>
<br><font size=2 face="sans-serif"><br>
</font><font size=1 face="Verdana">David Gancarz, P.E.<br>
Systems Development Manager<br>
City of Orlando<br>
400 S Orange Ave<br>
Orlando, FL 32802<br>
(407) 246-3062<br>
</font>
<hr><font size=1 face="Verdana">Florida has a very broad public records
law. As a result, any written communication created or received by City
of Orlando officials and employees will be made available to the public
and media, upon request, unless otherwise exempt. Under Florida law, email
addresses are public records. If you do not want your email address released
in response to a public records request, do not send electronic mail to
this office. Instead, contact our office by phone or in writing.</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>C S <usmsci@yahoo.com></b>
</font>
<br><font size=1 face="sans-serif">Sent by: shapelib-bounces@lists.maptools.org</font>
<p><font size=1 face="sans-serif">07/10/2007 03:50 PM</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
Shapelib Development <shapelib@lists.maptools.org></font></div></table>
<br>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">Shapelib Development <shapelib@lists.maptools.org></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Re: [Shapelib] C# wrapper around DBFReadIntegerAttribute.</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2><tt>David,<br>
  sorry .. the error i get is:<br>
<br>
"Additional information: Object reference not set to<br>
an instance of an object."<br>
<br>
thanks..<br>
<br>
Chad<br>
--- David.Gancarz@ci.orlando.fl.us wrote:<br>
<br>
> There is an existing c# wrapper on the shapelib site<br>
> which you can use <br>
> directly, or use for comparison to your own code.<br>
> <br>
> David Gancarz, P.E.<br>
> Systems Development Manager<br>
> City of Orlando<br>
> 400 S Orange Ave<br>
> Orlando, FL 32802<br>
> (407) 246-3062<br>
> Florida has a very broad public records law. As a<br>
> result, any written <br>
> communication created or received by City of Orlando<br>
> officials and <br>
> employees will be made available to the public and<br>
> media, upon request, <br>
> unless otherwise exempt. Under Florida law, email<br>
> addresses are public <br>
> records. If you do not want your email address<br>
> released in response to a <br>
> public records request, do not send electronic mail<br>
> to this office. <br>
> Instead, contact our office by phone or in writing.<br>
> <br>
> <br>
> <br>
> C S <usmsci@yahoo.com> <br>
> Sent by: shapelib-bounces@lists.maptools.org<br>
> 07/09/2007 03:52 PM<br>
> Please respond to<br>
> Shapelib Development <shapelib@lists.maptools.org><br>
> <br>
> <br>
> To<br>
> shapelib@lists.maptools.org<br>
> cc<br>
> <br>
> Subject<br>
> [Shapelib] C# wrapper around<br>
> DBFReadIntegerAttribute.<br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
> hi all! <br>
> <br>
> i hope someone somewhere out there is or has tried<br>
> to<br>
> to do some C# stuff around the C API. <br>
> <br>
> i wrote a C++ program to read a SHP and DBF file and<br>
> get the attributes from a certain column and then<br>
> tried the same thing using a basic C# wrapper. most<br>
> things seem to work fine but DBFRead**Attribute<br>
> stuff<br>
> just doesnt seem to work.  here is my code for<br>
> re-writing the DBF struct(not headers in C#) and my<br>
> extern statement. <br>
> <br>
> [StructLayout(LayoutKind.Sequential)]<br>
>                  public
struct DBFInfo<br>
>                  {<br>
>                    
             public IntPtr   fp;<br>
>                    
             public int    
<br>
> nRecords;<br>
>                    
             public int    
    <br>
>     nRecordLength;<br>
>                    
             public int    
    <br>
>     nHeaderLength;<br>
>                    
             public int    
    <br>
>     nFields;<br>
>                    
             public IntPtr    
 <br>
>     panFieldOffset;<br>
>                    
             public IntPtr    
 <br>
>     panFieldSize;<br>
>                    
             public IntPtr    
 <br>
>     panFieldDecimals;<br>
>                    
             public string  <br>
> pachFieldType;<br>
>                    
             public string  <br>
> pszHeader;<br>
>                    
             public int    
    <br>
>     nCurrentRecord;<br>
>                    
             public int<br>
> bCurrentRecordModified;<br>
>                    
             public string  <br>
> pszCurrentRecord;<br>
>                    
             public int    
    <br>
>     bNoHeader;<br>
>                    
             public int    
<br>
> nBufSize;<br>
>                  };<br>
> <br>
> [DllImport("shapelib.dll", EntryPoint =<br>
> "DBFReadIntegerAttribute")]<br>
> public static extern int<br>
> DBFReadIntegerAttribute(DBFInfo myDBFHandle, int<br>
> shape, int field);<br>
> <br>
> i am using the shapelib.dll from the folder<br>
> shapelib(vc7.1) that i downloaded. i am using by the<br>
> way Visual Studio .NET 2003(does this make any<br>
> difference?).<br>
> <br>
> then in a function i try to call this function to<br>
> get<br>
> the values in a loop of all the fields. <br>
> /**************************************************<br>
> //in some function:<br>
> <br>
> int shape_total = 0;<br>
> int *width = null<br>
> int *decimals = null;<br>
> int total_matches = 0;<br>
> string fieldName = "";<br>
> <br>
> public static unsafe int population(IntPtr SPtr,<br>
> IntPtr DPtr, SHPInfo Shandle, DBFInfo Dhandle)<br>
> {<br>
>  for(int i = 0; i < Dhandle.nFields; i++)<br>
>  {<br>
>   outfile.Write(DBFGetFieldInfo(Dhandle, i+1, out<br>
> fieldName, out width, out decimals)); <br>
>   outfile.Write(" name: ");<br>
>   outfile.WriteLine(fieldName);<br>
>  }<br>
> }<br>
> <br>
> in my output for every field i am always getting<br>
> FTInvalid and fieldName is always blank. upon<br>
> debugging and looking at my local watches right<br>
> after<br>
> i do the first DBFGetFieldInfo call here are the<br>
> list<br>
> of watches under Dhandle and their values, with<br>
> their<br>
> types: <br>
> <br>
> bCurrentRecordModified           0  
            int<br>
> bNoHeader                0
              int<br>
> fp               268766432  
            int<br>
> nBufSize                 0
              int<br>
> nCurrentRecord           -1    
         int<br>
> nFields          101      
      int<br>
> nHeaderLength            3265  
         int<br>
> nRecordLength            926  
          int<br>
> nRecords                 28
             int<br>
> pachFieldType<br>
><br>
"NNNNNNCCNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNýýýý"<br>
> string<br>
> panFieldDecimals              
  48530680           <br>
>     int <br>
> panFieldOffset           48521256<br>
> int <br>
> panFieldSize             48530232  
             int<br>
> pszCurrentRecord<br>
><br>
"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍýýýý"<br>
> string<br>
> pszHeader                "AREA"
         string<br>
> <br>
> the number of fields, records, the header string and<br>
> record length are all correct and match up well the<br>
> C++ output i am getting in the watches their. but<br>
> notice nCurrentRecord is -1 and the decimals, offset<br>
> and pszCurrentRecord are showing crazy stuff. the<br>
> pszCurrent record in the visual studio debugging<br>
> tool<br>
> is nice enough to show you ALL the fields values..in<br>
> C++ its correct, in C# i get these weird 'I'<br>
> characters. maybe because nCurrentRecord is -1<br>
> somehow? <br>
> <br>
> i am at my wits end. the SHP functions work just<br>
> fine.<br>
> <br>
> <br>
> is there anything i could try? can anyone offer any<br>
> pointers? <br>
> <br>
> <br>
> <br>
>  <br>
><br>
____________________________________________________________________________________<br>
> Building a website is a piece of cake. Yahoo! Small<br>
> Business gives you all <br>
> the tools to get online.<br>
> http://smallbusiness.yahoo.com/webhosting <br>
> _______________________________________________<br>
> Shapelib mailing list<br>
> Shapelib@lists.maptools.org<br>
> http://lists.maptools.org/mailman/listinfo/shapelib<br>
> <br>
> > _______________________________________________<br>
> Shapelib mailing list<br>
> Shapelib@lists.maptools.org<br>
> http://lists.maptools.org/mailman/listinfo/shapelib<br>
> <br>
<br>
<br>
<br>
      ____________________________________________________________________________________<br>
Park yourself in front of a world of choices in alternative vehicles. Visit
the Yahoo! Auto Green Center.<br>
http://autos.yahoo.com/green_center/ <br>
_______________________________________________<br>
Shapelib mailing list<br>
Shapelib@lists.maptools.org<br>
http://lists.maptools.org/mailman/listinfo/shapelib<br>
</tt></font>
<br>