C# vs2013 64位而非vs2010 64位中的AccessViolation异常

C# vs2013 64位而非vs2010 64位中的AccessViolation异常,c#,visual-studio-2010,visual-studio-2013,64-bit,dllimport,C#,Visual Studio 2010,Visual Studio 2013,64 Bit,Dllimport,在VS2013 64位framework 4+上运行代码时,我遇到System.AccessViolation异常。它在使用早期框架或32位模式时工作。它在VS2010上的32位和64位框架4上也可以正常工作 罪犯就在这里的某个地方: GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); IntPtr ptr; if(CPU.Is32Bit) { ptr = (IntPtr)(

在VS2013 64位framework 4+上运行代码时,我遇到System.AccessViolation异常。它在使用早期框架或32位模式时工作。它在VS2010上的32位和64位框架4上也可以正常工作

罪犯就在这里的某个地方:

    GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
    IntPtr ptr;
    if(CPU.Is32Bit)
    {
        ptr = (IntPtr)(handle.AddrOfPinnedObject().ToInt32() + index);
    }
    else
    {
        ptr = (IntPtr)(handle.AddrOfPinnedObject().ToInt64() + Convert.ToInt64(index));
    }

    res = beEncodeChunk(hbeStream, nBytes / 2, ptr, pOutput, ref pdwOutput); //<--- Error here
GCHandle handle=GCHandle.Alloc(缓冲区,GCHandleType.pinted);
IntPtr-ptr;
如果(CPU.is32位)
{
ptr=(IntPtr)(handle.AddrOfPinnedObject().ToInt32()+索引);
}
其他的
{
ptr=(IntPtr)(handle.AddrOfPinnedObject().ToInt64()+Convert.ToInt64(index));
}

res=beEncodeChunk(hbeStream,nBytes/2,ptr,pOutput,ref pdwOutput)// 我使用的lame版本似乎不是真正的64位兼容,并且不喜欢将64位IntPtr传递给它。我已通过与此库一起使用较新版本的DLL解决了问题:


没有“VS2013 64位”这样的东西。您指的是64位编译的二进制文件吗?是的,在vs2013If
CPU.Is32Bit=false
中以64位模式构建应用程序,这是否意味着该进程是64位的?是的,整个if结构实际上可以替换为ptr=(IntPtr)(handle.AddrOfPinnedObject().ToInt64()+索引);