I have code written in C # on Windows7 and VS2010, 32 bit using .Net 3.5 and it runs without any problems, now I converted it to 64-bit using .Net 4.0, but I got an error, when my code call is CloseHandle.
ERROR - CloseHandle
System.Runtime.InteropServices.SEHException (0x80004005): An external component threw an exception.
unsafe { fixed (byte* p = readBuffer) { IntPtr intPtr = (IntPtr)p; this.ReadFile(ref sourceFile, (ulong)buffer_size, intPtr, ref nNumBytesRead); if (intPtr != IntPtr.Zero) { try { FunctionSqudf.CloseHandle(intPtr); } catch (Exception ex) { Hardware.LogHardware.Error("CloseHandle", ex); } } } } [SecuritySafeCritical] [DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool CloseHandle(IntPtr hObject);
Any help is appreciated.
source share