小编Kha*_*lla的帖子

System.Runtime.InteropServices.SEHException(0x80004005):外部组件引发了异常

我在 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#

6
推荐指数
1
解决办法
3万
查看次数

C#中C++引用类型的等价物

我在C#应用程序中使用用C++编写的dll.什么是等价物

  1. char const *
  2. unsigned short

在C#中

谢谢

c# const char

0
推荐指数
1
解决办法
1239
查看次数

标签 统计

c# ×2

char ×1

const ×1