473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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.

Sep 7 '06 #1
2 2000
Did you develop unmanaged proj.dll? Do you source for that DLL?
That code seems to be causing some meory overwrite.

"humbleaptience" <hu************@gmail.comwrote in message
news:11**********************@d34g2000cwd.googlegr 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.

Sep 7 '06 #2
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" <hu************@gmail.comwrote in message
news:11**********************@d34g2000cwd.googlegr 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.
Sep 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Askari | last post by:
Yesterday, ALL code in python work and nothing when I close(finish) a code. Today, when I close, some raise this windows error : Instruction at "0x00FC3D70" use memory address "0x00000000". Can't...
10
by: ZafT | last post by:
Thanks in advance for any tips that might get me going in the right direction. I am working on a simple exercise for school that is supposed to use read to read a file (about 10 MB). I am...
53
by: Alf P. Steinbach | last post by:
So, I got the itch to write something more... I apologize for not doing more on the attempted "Correct C++ Tutorial" earlier, but there were reasons. This is an UNFINISHED and RAW document,...
2
by: Ryan Linneman via .NET 247 | last post by:
Any help appreciated... I am using a third party DLL file to access an HMI using ethernet. The function is declared in a VB module as: 'Read internal word address Public Declare Function...
4
by: Tina | last post by:
This is an issue regarding what exactly is accomplished by using "Protected" when defining a variable. It seems it does much more than just applying Protected status to a variable. I have an...
2
by: Pieter | last post by:
Hi, Since 10 days (the first time was the 10th of november) I have some weird exception happening in an application here: All (except 1 of the total of 5) users had this error now 1 of 2 times...
0
by: nieve | last post by:
Hello all, I'm working on a c# application using smart cards. I've been using vs2008 on an XP machine and everything was ok till I tried installing and running a demo on a vista machine. What...
6
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the...
1
by: kamcap | last post by:
I have referenced a COM dll (unmanagged code) in a C# console application and this DLL is referenced in C# program using Interop facility in .NET. This dll actually a dataset/table which is written...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.