AccessViolationException, attempted to read or write protected memory

Posted by Malfist on Stack Overflow See other posts from Stack Overflow or by Malfist
Published on 2010-04-01T19:20:36Z Indexed on 2010/04/01 19:23 UTC
Read the original article Hit count: 857

I'm using a dll that contains unsafe code for interacting with specific hardware, and I'm trying to use it from C#, but I keep getting an AccessViolationException.

What's causing it, and how can I fix it?

namespace FingerPrint {
    public unsafe partial class Form1 : Form {

        [DllImport("MyDll.dll")]
        public static extern int DoesExist();

        public unsafe Form1() {
            InitializeComponent();

            MessageBox.Show(DoesExist() + "");
        }
    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET