Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Desperate Need Of Help "Attempted To Read Or Write Protected Memory"

Reply
Thread Tools

Desperate Need Of Help "Attempted To Read Or Write Protected Memory"

 
 
humbleaptience
Guest
Posts: n/a
 
      09-07-2006
I have a web application that uses a DLL using DLLImport.

Twice I have put the application live on the net and it has been used
hundreds or thousands of time before it has been strangely brought
down.

System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt. at
ProjApi.Proj.pj_init_plus(String pjstr) at coordinate.LLtoUTM(Int32
datumIn, Int32 datumOut, Double p_lat, Double p_lon, Double&
UTMNorthing, Double& UTMEasting, Int32& UTMZone) at
coordinate.LLtoUTMZone(Double lat, Double lon, Int32 datumIn, Int32
datumOut, Int32& z, Double& n, Double& e) at
getfactory.Page_Load(Object sender, EventArgs e) at
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o,
Object t, EventArgs e) at
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender,
EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at
System.Web.UI.Control.LoadRecursive() at
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Here is my code that calls the extern method

public static int LLtoUTM(int datumIn, int datumOut, double p_lat,
double p_lon,ref double UTMNorthing,ref double UTMEasting,ref int
UTMZone)
{
int errno = 0;
//This is the formula for calculating which Zone a point is in at a
particular lat/long
int ZoneNumber = Convert.ToInt32(Math.Floor((p_lon + 180) / 6)) + 1;
double[] x = new double[1];
double[] y = new double[1];
double[] z = new double[1];
y[0] = p_lat * ProjApi.Proj.DEG_TO_RAD;
x[0] = p_lon * ProjApi.Proj.DEG_TO_RAD;
z[0] = 0.0;
IntPtr src0 = ProjApi.Proj.pj_init_plus("+proj=latlong
+datum=NAD27");
IntPtr src1 = ProjApi.Proj.pj_init_plus("+proj=latlong
+datum=NAD83");
IntPtr dst0 = ProjApi.Proj.pj_init_plus("+proj=utm +zone="
+ ZoneNumber + " +datum=NAD27");
IntPtr dst1 = ProjApi.Proj.pj_init_plus("+proj=utm +zone="
+ ZoneNumber + " +datum=NAD83");
//This nice little bit of code below is designed to execute
pj_transfrom (the proj lib all around function)
//with the correct parameters so that a datumshift to the correct
datum is included.
try
{
if (datumIn == 0)
{
if (datumOut == 0)
{
errno = ProjApi.Proj.pj_transform(src0, dst0,
1, 1, x, y, z);//NAD27-NAD83
}
else
{
errno = ProjApi.Proj.pj_transform(src0, dst1,
1, 1, x, y, z);//NAD27-NAD27
}
}
else
{
if (datumOut == 0)
{
errno = ProjApi.Proj.pj_transform(src1, dst0,
1, 1, x, y, z);//NAD83-NAD27
}
else
{
errno = ProjApi.Proj.pj_transform(src1, dst1,
1, 1, x, y, z);//NAD83-NAD83
}
}
}
catch { }

ProjApi.Proj.pj_free(dst1);
ProjApi.Proj.pj_free(src1);
ProjApi.Proj.pj_free(dst0);
ProjApi.Proj.pj_free(src0);
UTMNorthing = y[0];
UTMEasting = x[0];
UTMZone = ZoneNumber;
return errno;
}


Here is the definition and DLL import.
[DllImport("proj.dll", CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe int pj_transform(IntPtr src, IntPtr
dst,
int point_count, int point_offset,
[InAttribute, OutAttribute] double[] x,
[InAttribute, OutAttribute] double[] y,
[InAttribute, OutAttribute] double[] z);

Any help at all would be useful. I am not able to trigger this error
myself so I can't even do trial and error.

 
Reply With Quote
 
 
 
 
Winista
Guest
Posts: n/a
 
      09-07-2006
Did you develop unmanaged proj.dll? Do you source for that DLL?
That code seems to be causing some meory overwrite.

"humbleaptience" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>I have a web application that uses a DLL using DLLImport.
>
> Twice I have put the application live on the net and it has been used
> hundreds or thousands of time before it has been strangely brought
> down.
>
> System.AccessViolationException: Attempted to read or write protected
> memory. This is often an indication that other memory is corrupt. at
> ProjApi.Proj.pj_init_plus(String pjstr) at coordinate.LLtoUTM(Int32
> datumIn, Int32 datumOut, Double p_lat, Double p_lon, Double&
> UTMNorthing, Double& UTMEasting, Int32& UTMZone) at
> coordinate.LLtoUTMZone(Double lat, Double lon, Int32 datumIn, Int32
> datumOut, Int32& z, Double& n, Double& e) at
> getfactory.Page_Load(Object sender, EventArgs e) at
> System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o,
> Object t, EventArgs e) at
> System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender,
> EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at
> System.Web.UI.Control.LoadRecursive() at
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
>
> Here is my code that calls the extern method
>
> public static int LLtoUTM(int datumIn, int datumOut, double p_lat,
> double p_lon,ref double UTMNorthing,ref double UTMEasting,ref int
> UTMZone)
> {
> int errno = 0;
> //This is the formula for calculating which Zone a point is in at a
> particular lat/long
> int ZoneNumber = Convert.ToInt32(Math.Floor((p_lon + 180) / 6)) + 1;
> double[] x = new double[1];
> double[] y = new double[1];
> double[] z = new double[1];
> y[0] = p_lat * ProjApi.Proj.DEG_TO_RAD;
> x[0] = p_lon * ProjApi.Proj.DEG_TO_RAD;
> z[0] = 0.0;
> IntPtr src0 = ProjApi.Proj.pj_init_plus("+proj=latlong
> +datum=NAD27");
> IntPtr src1 = ProjApi.Proj.pj_init_plus("+proj=latlong
> +datum=NAD83");
> IntPtr dst0 = ProjApi.Proj.pj_init_plus("+proj=utm +zone="
> + ZoneNumber + " +datum=NAD27");
> IntPtr dst1 = ProjApi.Proj.pj_init_plus("+proj=utm +zone="
> + ZoneNumber + " +datum=NAD83");
> //This nice little bit of code below is designed to execute
> pj_transfrom (the proj lib all around function)
> //with the correct parameters so that a datumshift to the correct
> datum is included.
> try
> {
> if (datumIn == 0)
> {
> if (datumOut == 0)
> {
> errno = ProjApi.Proj.pj_transform(src0, dst0,
> 1, 1, x, y, z);//NAD27-NAD83
> }
> else
> {
> errno = ProjApi.Proj.pj_transform(src0, dst1,
> 1, 1, x, y, z);//NAD27-NAD27
> }
> }
> else
> {
> if (datumOut == 0)
> {
> errno = ProjApi.Proj.pj_transform(src1, dst0,
> 1, 1, x, y, z);//NAD83-NAD27
> }
> else
> {
> errno = ProjApi.Proj.pj_transform(src1, dst1,
> 1, 1, x, y, z);//NAD83-NAD83
> }
> }
> }
> catch { }
>
> ProjApi.Proj.pj_free(dst1);
> ProjApi.Proj.pj_free(src1);
> ProjApi.Proj.pj_free(dst0);
> ProjApi.Proj.pj_free(src0);
> UTMNorthing = y[0];
> UTMEasting = x[0];
> UTMZone = ZoneNumber;
> return errno;
> }
>
>
> Here is the definition and DLL import.
> [DllImport("proj.dll", CharSet = CharSet.Ansi,
> CallingConvention = CallingConvention.Cdecl)]
> public static extern unsafe int pj_transform(IntPtr src, IntPtr
> dst,
> int point_count, int point_offset,
> [InAttribute, OutAttribute] double[] x,
> [InAttribute, OutAttribute] double[] y,
> [InAttribute, OutAttribute] double[] z);
>
> Any help at all would be useful. I am not able to trigger this error
> myself so I can't even do trial and error.
>



 
Reply With Quote
 
 
 
 
humbleaptience
Guest
Posts: n/a
 
      09-07-2006
No however the DLL is used to do these same operations thousands of
time and has been around for years and there has been no mention of any
problem like this on their mailing list. We have been using this
EXACT same dll on our web site to do reprojections (classic ASP) for
years hundreds of thousands of times a day.

Winista wrote:
> Did you develop unmanaged proj.dll? Do you source for that DLL?
> That code seems to be causing some meory overwrite.
>
> "humbleaptience" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> >I have a web application that uses a DLL using DLLImport.
> >
> > Twice I have put the application live on the net and it has been used
> > hundreds or thousands of time before it has been strangely brought
> > down.
> >
> > System.AccessViolationException: Attempted to read or write protected
> > memory. This is often an indication that other memory is corrupt. at
> > ProjApi.Proj.pj_init_plus(String pjstr) at coordinate.LLtoUTM(Int32
> > datumIn, Int32 datumOut, Double p_lat, Double p_lon, Double&
> > UTMNorthing, Double& UTMEasting, Int32& UTMZone) at
> > coordinate.LLtoUTMZone(Double lat, Double lon, Int32 datumIn, Int32
> > datumOut, Int32& z, Double& n, Double& e) at
> > getfactory.Page_Load(Object sender, EventArgs e) at
> > System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o,
> > Object t, EventArgs e) at
> > System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender,
> > EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at
> > System.Web.UI.Control.LoadRecursive() at
> > System.Web.UI.Page.ProcessRequestMain(Boolean
> > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
> >
> > Here is my code that calls the extern method
> >
> > public static int LLtoUTM(int datumIn, int datumOut, double p_lat,
> > double p_lon,ref double UTMNorthing,ref double UTMEasting,ref int
> > UTMZone)
> > {
> > int errno = 0;
> > //This is the formula for calculating which Zone a point is in at a
> > particular lat/long
> > int ZoneNumber = Convert.ToInt32(Math.Floor((p_lon + 180) / 6)) + 1;
> > double[] x = new double[1];
> > double[] y = new double[1];
> > double[] z = new double[1];
> > y[0] = p_lat * ProjApi.Proj.DEG_TO_RAD;
> > x[0] = p_lon * ProjApi.Proj.DEG_TO_RAD;
> > z[0] = 0.0;
> > IntPtr src0 = ProjApi.Proj.pj_init_plus("+proj=latlong
> > +datum=NAD27");
> > IntPtr src1 = ProjApi.Proj.pj_init_plus("+proj=latlong
> > +datum=NAD83");
> > IntPtr dst0 = ProjApi.Proj.pj_init_plus("+proj=utm +zone="
> > + ZoneNumber + " +datum=NAD27");
> > IntPtr dst1 = ProjApi.Proj.pj_init_plus("+proj=utm +zone="
> > + ZoneNumber + " +datum=NAD83");
> > //This nice little bit of code below is designed to execute
> > pj_transfrom (the proj lib all around function)
> > //with the correct parameters so that a datumshift to the correct
> > datum is included.
> > try
> > {
> > if (datumIn == 0)
> > {
> > if (datumOut == 0)
> > {
> > errno = ProjApi.Proj.pj_transform(src0, dst0,
> > 1, 1, x, y, z);//NAD27-NAD83
> > }
> > else
> > {
> > errno = ProjApi.Proj.pj_transform(src0, dst1,
> > 1, 1, x, y, z);//NAD27-NAD27
> > }
> > }
> > else
> > {
> > if (datumOut == 0)
> > {
> > errno = ProjApi.Proj.pj_transform(src1, dst0,
> > 1, 1, x, y, z);//NAD83-NAD27
> > }
> > else
> > {
> > errno = ProjApi.Proj.pj_transform(src1, dst1,
> > 1, 1, x, y, z);//NAD83-NAD83
> > }
> > }
> > }
> > catch { }
> >
> > ProjApi.Proj.pj_free(dst1);
> > ProjApi.Proj.pj_free(src1);
> > ProjApi.Proj.pj_free(dst0);
> > ProjApi.Proj.pj_free(src0);
> > UTMNorthing = y[0];
> > UTMEasting = x[0];
> > UTMZone = ZoneNumber;
> > return errno;
> > }
> >
> >
> > Here is the definition and DLL import.
> > [DllImport("proj.dll", CharSet = CharSet.Ansi,
> > CallingConvention = CallingConvention.Cdecl)]
> > public static extern unsafe int pj_transform(IntPtr src, IntPtr
> > dst,
> > int point_count, int point_offset,
> > [InAttribute, OutAttribute] double[] x,
> > [InAttribute, OutAttribute] double[] y,
> > [InAttribute, OutAttribute] double[] z);
> >
> > Any help at all would be useful. I am not able to trigger this error
> > myself so I can't even do trial and error.
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iomega zip disk won't read. Need help (DESPERATE) Hockey Buff Computer Support 8 07-30-2008 12:47 PM
PLEASE Help, I Need A Crashed Disk HD Image/Forensics Data Recovery Tool, I am Desperate for HELP!! Tory Brown Computer Support 16 08-04-2006 02:13 AM
Still Need desperate help to start with ASP NET - simplified problems - HELP!! pamelafluente@libero.it ASP .Net 16 07-03-2006 06:41 AM
DESPERATE FOR HELP! Please Read! Dave Navarro ASP General 2 08-27-2004 07:18 PM
DESPERATE FOR HELP! Please Read! Dave Navarro HTML 2 08-27-2004 07:18 PM



Advertisments