我在 Windows7 和 VS2010 上使用 .Net 3.5 用 C# 编写了 32 位代码,并且运行没有任何问题,现在我使用 .Net 4.0 将其转换为 64 位,但当我的代码调用 CloseHandle 时出现错误。
错误 - CloseHandle
System.Runtime.InteropServices.SEHException (0x80004005):外部组件引发异常。
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); …Run Code Online (Sandbox Code Playgroud) 我在C#应用程序中使用用C++编写的dll.什么是等价物
char const *unsigned short在C#中
谢谢