code_junkie

Memory AccessViolationException Error Calling DLL From C#

Nov 11th, 2011
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. int success = -1;
  2. unsafe
  3. {
  4. int res = 0;
  5. int* res_ptr = &res;
  6. int len = cmd.ToCharArray().Length;
  7. int* len_ptr = &len;
  8. CmdInterpreter(ref cmd, len_ptr, res_ptr);
  9. success = *res_ptr;
  10. }
  11.  
  12. [DllImport("brugs.dll", EntryPoint="CmdInterpreter",
  13. ExactSpelling=false, CallingConvention = CallingConvention.StdCall)]
  14. public static unsafe extern void CmdInterpreter(ref string cmd, int *len, int *res);
Add Comment
Please, Sign In to add comment