OpenCLNet.dll 中发生了 'System.AccessViolationException' 类型的未处理异常

An unhandled exception of type 'System.AccessViolationException' occurred in OpenCLNet.dll

'System.AccessViolationException' 类型的未处理异常发生在 OpenCLNet.dll

@

平台测试=新平台(platformid); "platformID" 在运行时的值为 1。

public class Program
{
    static void Main(string[] args)
    {
        IntPtr[] IntPtrArr = new IntPtr[10];
        uint platformID;
        OpenCL.GetPlatformIDs(1, IntPtrArr,out platformID);
        IntPtr platformid = new IntPtr(platformID);
        Platform test = new Platform(platformid);
    }
}

我是否正确获取了 PlatfromID 或 platfromid?

OpenCL.GetPlatformIDs输出参数不是平台ID,是你IntPtrArr中设置的平台数量,查看IntPtrArr中的条目是否已设置, 如果是这样,请将它们用作您的 platformID.