Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6156397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:36:11+00:00 2026-05-23T20:36:11+00:00

I follow this sample http://trac.osgeo.org/proj/wiki/ProjAPI but if I try to import this code in

  • 0

I follow this sample
http://trac.osgeo.org/proj/wiki/ProjAPI

but if I try to import this code in C# as follow

unsafe class Program
{
    public struct projUV  {public double u; public double v;        }

    [DllImport(@"C:\Users\t\Desktop\Lib\proj.dll", CharSet = CharSet.Auto,
        EntryPoint = "pj_free")]
    static extern void pj_free(void* p);

    [DllImport(@"C:\Users\t\Desktop\Lib\proj.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "pj_init_plus")]
    static extern void* pj_init_plus([MarshalAs(UnmanagedType.LPStr)]string m);

    [DllImport(@"C:\Users\t\Desktop\Lib\proj.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto,  EntryPoint = "pj_inv")]
    static extern projUV pj_inv(projUV px, void* py);

    [DllImport(@"C:\Users\t\Desktop\Lib\proj.dll", EntryPoint = "pj_transform")]
    static extern int pj_transform(void* src, void* dst, long point_count, int point_offset,
                      double* x, double* y, double* z);

    static void Main(string[] args)  {

        string proSrc = "+proj=merc +ellps=clrk66 +lat_ts=33";
        string proDst = "+proj=latlong +ellps=clrk66";

        void* projSrc = pj_init_plus(proSrc);
        void* projDst = pj_init_plus(proDst);

        double x = 15000;
        double y = 10000;
        double z = 0.0;

        double ris = pj_transform(projSrc, projDst, 1, 0, &x, &y, &z);

    }
}

I have this error:Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Note:
in the official sample there are this declaration: projPJ pj_merc, pj_latlong;
I use void* when call pj_init_plus but

what I wrong?

thanks
p.s. sorry for my english
G.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:36:12+00:00Added an answer on May 23, 2026 at 8:36 pm

    It wouldn’t hurt if you’d also mention the line number where the error is generated…

    Aside from that, this is a common problem. The information below is taken from:

    Original Source

    1) Most of the time you will not see this kind of an error with purely .NET code. The CLR was designed to avoid these situations with developer code. However, when you go beyond purely managed code, an invalid pointer is what causes this problem. This can happen when you pass a pointer to an API. If the pointer is null (the address is 0), you will almost always get this error (assuming the unmanaged code doesn’t crash first). If the pointer contains an address value that is outside the allocated memory range for the app, or is in the range reserved for OS usage, then you will also get the error. Additionally, you can map memory with different access levels (actually, as a .NET programmer, you usually don’t, but some other unmanaged code might). If your process doesn’t have “read” access to that mapped memory range, you’ll also get this error.

    In short, most of the time it’s a bug with your code trying to use unmanaged code (passing something by value instead of by ref, or passing a null pointer, or something to that effect), or it’s a bug in a 3rd party unmanaged library (even possibly a driver depending on what kind of code we’re interacting with here).

    For further information, please take a look at the following thread and the above explanation is provided by Rob Teixeira :

    Attempted to read or write protected memory. This is often an indication that other memory is corrupt

    2) In Visual Studio 2005, you can consider to set the Debugger as the following steps:

    In VS menu, click Tools -> Options. In the Options panel, please choose Debugging -> General. Then please uncheck option “Suppress JIT optimization on module load (Managed Only).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, I'm trying to follow the tutorial from http://rapidandroid.org/wiki/Graphing . But I found a
I'm trying to follow this tutorial from Cython: http://docs.cython.org/docs/tutorial.html#the-basics-of-cython and I'm having a problem.
i am making a sample program in hibernate follow this tutorial: http://www.myeclipseide.com/documentation/quickstarts/hibernateintroduction/ using reverse
I'm trying to follow THE magnificient Rails3 tutorial at http://railstutorial.org but ran into a
I follow this rule but some of my colleagues disagree with it and argue
I tried to follow this but the default modelbinder let my array null on
I want to include Core Location and I'm trying to follow this tutorial: http://www.mobileorchard.com/hello-there-a-corelocation-tutorial/
I've been trying to follow this tutorial for deploying a WCF sample to IIS
I am looking to use this plugin: http://keith-wood.name/countdown.html but I need to use the
I use this AES library (in C language), http://gladman.plushost.co.uk/oldsite/AES/aes-src-16-04-07.zip I follow this page and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.