问题和标题有点不明白 到底是要Inptr还是要HttpContext

解决方案 »

  1.   

    没有测试: System.Runtime.InteropServices.GCHandle gch = GCHandle.Alloc(httpContext, GCHandleType.Pinned);
     IntPtr _context= gch.AddrOfPinnedObject();
    ...
     gch.Free();
      

  2.   

    感谢大康
    编译通过
    不过在运行至
    System.Runtime.InteropServices.GCHandle gch = GCHandle.Alloc(this.Context, GCHandleType.Pinned);
    时报错:
    Object 包含非基元或非直接复制到本机结构中的数据。如果改为
    System.Runtime.InteropServices.GCHandle gch = GCHandle.Alloc(this.Context, GCHandleType.Normal);
    则在运行至
    IntPtr _context = gch.AddrOfPinnedObject();
    报错
    句柄未被固定。