AccessViolationException, attempted to read or write protected memory
- by Malfist
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() + "");
}
}
}