我正在尝试创建这样的IntPtr:
Dim pid 作为 新 IntPtr ( Int64 .MaxValue)等效的C#类似于:
IntPtr pid = new IntPtr ( Int64 .MaxValue);我一直收到错误OverflowException。 我怎样才能做到这一点? 编辑: 这是用AnyCPU编译的。它是使用.NET CF 2.0的设备应用程序;目标设备正在运行Windows Mobile 6.5
解决方案您好b $ b试试这个.. IntPtr pid = new IntPtr ( int .MaxValue);
IntPtr类型设计为整数,其大小为特定于平台。也就是说,这种类型的实例预计在32位硬件和操作系统上 32位,并且64位上的 64位位硬件和操作系统。 希望您的机器是32位操作系统。 参考: intptr [ ^ ]
在Visual Studio的对象浏览器中,当你转到 IntPtr(long),然后你会看到以下例外 对象浏览器
System.OverflowException:在32位平台上,值太大或太小而无法表示为System.IntPtr。
我猜你是在32位平台上运行你的应用程序,所以你得到这个错误。
I am trying to create an IntPtr like this:
Dim pid As New IntPtr(Int64.MaxValue)The C# equivalent would be something like:
IntPtr pid = new IntPtr(Int64.MaxValue);I keep getting the error "OverflowException". How can I make this work? edit: This is being compiled with "AnyCPU". It's a device application using .NET CF 2.0; The target device is running Windows Mobile 6.5
解决方案 Hi try this.. IntPtr pid = new IntPtr(int.MaxValue);The IntPtr type is designed to be an integer whose size is platform-specific. That is, an instance of this type is expected to be 32-bits on 32-bit hardware and operating systems, and 64-bits on 64-bit hardware and operating systems. hope your machine is 32 bit operating system. reference: intptr[^]
In the Object Browser of Visual Studio, when you go to IntPtr(long), then you see the following under Exceptions Object BrowserSystem.OverflowException: On a 32-bit platform, value is too large or too small to represent as an System.IntPtr.
I guess you are running your application on a 32-bit platform, so you get this error.
更多推荐
如何使用Int64创建IntPtr?
发布评论