<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
h2
        {mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:18.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Hello,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I’ve recently moved my project from .net 1.1 to .net
2.0<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I’ve tested this code on 1.1, but there are some added
restrictions and stuff that just won’t compile in 2.0. <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>This is the C# wrapper that I’m using<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<h2><b><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>“</span></font></b><font
size=3><span style='font-size:12.0pt'>Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.”</span></font><o:p></o:p></h2>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>public</span></font> <font color=blue><span
style='color:blue'>static</span></font> <font color=blue><span
style='color:blue'>int</span></font> LLtoUTM(<font color=blue><span
style='color:blue'>int</span></font> datumIn, <font color=blue><span
style='color:blue'>int</span></font> datumOut, <font color=blue><span
style='color:blue'>double</span></font> p_lat, <font color=blue><span
style='color:blue'>double</span></font> p_lon,<font color=blue><span
style='color:blue'>ref</span></font> <font color=blue><span style='color:blue'>double</span></font>
UTMNorthing,<font color=blue><span style='color:blue'>ref</span></font> <font
color=blue><span style='color:blue'>double</span></font> UTMEasting,<font
color=blue><span style='color:blue'>ref</span></font> <font color=blue><span
style='color:blue'>int</span></font> UTMZone)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>int</span></font> errno;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=green><span style='color:green'>//This is the formula for calculating
which Zone a point is in at a particular lat/long<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>int</span></font> ZoneNumber = <font
color=teal><span style='color:teal'>Convert</span></font>.ToInt32((p_lon + 180)
/ 6) + 1;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>double</span></font>[] x = <font
color=blue><span style='color:blue'>new</span></font> <font color=blue><span
style='color:blue'>double</span></font>[1];<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>double</span></font>[] y = <font
color=blue><span style='color:blue'>new</span></font> <font color=blue><span
style='color:blue'>double</span></font>[1];<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>double</span></font>[] z = <font
color=blue><span style='color:blue'>new</span></font> <font color=blue><span
style='color:blue'>double</span></font>[1];<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> y[0] =
p_lat*<font color=teal><span style='color:teal'>proj_api</span></font>.<font
color=teal><span style='color:teal'>Proj</span></font>.DEG_TO_RAD;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> x[0] =
p_lon*<font color=teal><span style='color:teal'>proj_api</span></font>.<font
color=teal><span style='color:teal'>Proj</span></font>.DEG_TO_RAD;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> z[0] =
0.0;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=teal><span style='color:teal'>IntPtr</span></font> src0= <font
color=teal><span style='color:teal'>proj_api</span></font>.<font color=teal><span
style='color:teal'>Proj</span></font>.pj_init_plus(<font color=maroon><span
style='color:maroon'>"+proj_api.Proj=latlong +datum=NAD27"</span></font>);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=teal><span style='color:teal'>IntPtr</span></font> src1 = <font
color=teal><span style='color:teal'>proj_api</span></font>.<font color=teal><span
style='color:teal'>Proj</span></font>.pj_init_plus(<font color=maroon><span
style='color:maroon'>"+proj_api.Proj=latlong +datum=NAD83"</span></font>);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=teal><span style='color:teal'>IntPtr</span></font> dst0 = <font
color=teal><span style='color:teal'>proj_api</span></font>.<font color=teal><span
style='color:teal'>Proj</span></font>.pj_init_plus(<font color=maroon><span
style='color:maroon'>"+proj_api.Proj=utm +zone="</span></font> +
ZoneNumber + <font color=maroon><span style='color:maroon'>"
+datum=NAD27"</span></font>);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=teal><span style='color:teal'>IntPtr</span></font> dst1 = <font
color=teal><span style='color:teal'>proj_api</span></font>.<font color=teal><span
style='color:teal'>Proj</span></font>.pj_init_plus(<font color=maroon><span
style='color:maroon'>"+proj_api.Proj=utm +zone="</span></font> +
ZoneNumber + <font color=maroon><span style='color:maroon'>"
+datum=NAD83"</span></font>);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=green><span style='color:green'>//This nice little bit of code below is
designed to execute pj_transfrom (the proj_api.Proj lib all around function)<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=green><span style='color:green'>//with the correct parameters so that a
datumshift to the correct datum is included.<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>if</span></font>(datumIn==0)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>if</span></font>(datumOut==0)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> errno
= <font color=teal><span style='color:teal'>proj_api</span></font>.<font
color=teal><span style='color:teal'>Proj</span></font>.pj_transform(src0, dst0,
1, 1, x, y, z);<font color=green><span style='color:green'>//NAD27-NAD83<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>else<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> errno
= <font color=teal><span style='color:teal'>proj_api</span></font>.<font
color=teal><span style='color:teal'>Proj</span></font>.pj_transform(src0, dst1,
1, 1, x, y, z);<font color=green><span style='color:green'>//NAD27-NAD27<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>else<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>if</span></font>(datumOut==0)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> errno
= <font color=teal><span style='color:teal'>proj_api</span></font>.<font
color=teal><span style='color:teal'>Proj</span></font>.pj_transform(src1, dst0,
1, 1, x, y, z);<font color=green><span style='color:green'>//NAD83-NAD27<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>else<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>ERROR THROWN HERE ->
errno = <font color=teal><span style='color:teal'>proj_api</span></font>.<font
color=teal><span style='color:teal'>Proj</span></font>.pj_transform(src1, dst1,
1, 1, x, y, z); <font color=green><span style='color:green'>//NAD83-NAD83<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=teal><span style='color:teal'>proj_api</span></font>.<font color=teal><span
style='color:teal'>Proj</span></font>.pj_free(dst1);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=teal><span style='color:teal'>proj_api</span></font>.<font color=teal><span
style='color:teal'>Proj</span></font>.pj_free(src1);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=teal><span style='color:teal'>proj_api</span></font>.<font color=teal><span
style='color:teal'>Proj</span></font>.pj_free(dst0);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=teal><span style='color:teal'>proj_api</span></font>.<font color=teal><span
style='color:teal'>Proj</span></font>.pj_free(src0);<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> UTMNorthing
= y[0];<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> UTMEasting
= x[0];<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> UTMZone =
ZoneNumber;<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'> <font
color=blue><span style='color:blue'>return</span></font> errno; <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'> }<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<h2><b><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>“</span></font></b><font
size=3><span style='font-size:12.0pt'>Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.”</span></font><o:p></o:p></h2>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>Any help would be appretiated.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><br>
Thanks!<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>-Scott<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </o:p></span></font></p>
</div>
</body>
</html>