为 64 位平台编程 [英] Programming for the 64 bit platform

查看:23
本文介绍了为 64 位平台编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 .Net 应用程序(假设是 Asp.Net 应用程序)上工作时,与在 32 位平台上工作相比,在 64 位平台上工作的方式有什么不同.

While working on a .Net application (let's say an Asp.Net one), are there any differences in the way you would do things while working on the 64 bit platform, as compared to working on a 32 bit platform.

我想的很少,因为您正在开发框架,而且框架会为您处理大部分事情,对吧?

I would imagine very little since you are working on the framework, and the framework is taking care of most things for you, right?

但是,请发表您的意见.

But, please give your comments.

谢谢.

推荐答案

如果您正在使用 p/invoke,那么您需要确保您有 64 位版本的 DLL 可用.如果您调用 MS 提供的 DLL,例如 kernel32,这不是问题,因为它们在 32 位和 64 位平台上具有相同的名称(奇怪,我知道),因此您的 64 位应用程序将隐式链接到正确的版本.但是,如果您使用 3rd 方 DLL 并且您的 64 位应用程序尝试链接到 32 位 DLL,您将收到运行时异常.

If you're using p/invoke then you need to be sure that you've got 64bit versions of the DLLs available. This isn't an issue if you're calling MS supplied DLLs such as kernel32 as they've got the same name on the 32 and 64 bit platforms (bizarre, I know) and so your 64 bit app will implicitly link to the correct version. However, if you're using 3rd party DLLs and your 64bit app tries to link to a 32bit DLL you'll get a runtime exception.

这也意味着,如果您使用进程内 COM 对象,则会遇到问题.当您跨进程边界移动时,64 位应用程序可以调用 32 位进程外 COM 对象(反之亦然),COM 将为您处理编组.

This also means that if you're using in-process COM object you'll have a problem. A 64bit app can call an out-of-process COM object that's 32 bit (and vice-versa) as you're moving across a process boundary and COM will take care of the marshalling for you.

除此之外,该框架会为您处理大部分事情.您永远不必担心指针大小,并且 clr 类型具有明确的大小(int 始终为 32 位,long 始终为 64 位).在纯粹的 .NET 世界中,几乎没有什么可担心的.当你开始走出沙箱时,你必须更加小心.

Other than this, the framework takes care of most things for you. You never really have to worry about pointer sizes and the clr types have explicit sizes (int is always 32 bits, long always 64 bits). In a pure .NET world there's very little to worry about. It's when you start moving outside the sandbox that you have to be more careful.

这篇关于为 64 位平台编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆