C# 控制台应用程序都是 16 位的吗?

发布于 2024-07-09 22:45:13 字数 278 浏览 7 评论 0原文

当我构建一个快速测试控制台应用程序时,我正在阅读有关 NTVDM.exe 的信息,它在抱怨此 EXE 的朋友机器上崩溃了。

据我了解,所有 DOS cmd 窗口(包括 C# 控制台应用程序)都以 16 位而不是 32 位运行。

这是真的? 这是否意味着我的所有工作控制台应用程序后台应用程序都以 16 位运行,而不是充分利用 32 位可用?

Windows 服务怎么样? 我相信我们将其编写为控制台应用程序,然后将其作为 Windows 服务运行?

谢谢

I was reading up about NTVDM.exe as I build a quick test console app and it crashed on a friends machine complaining about this EXE.

As I understand it all DOS cmd windows (C# console apps included) run as 16bit not 32bit.

Is this true? Does this mean all my works console app back office apps are running as 16bit rather than making the most of the 32bit available?

What about Windows services? As I believe we wrote it as a console app then made it run as a windows service?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

征﹌骨岁月お 2024-07-16 22:45:13

任何为 x86 编译的 .NET 应用程序都将是 32 位

C# 控制台应用程序,它们不会在“真正的”dos 中运行 - 它们在 32 位或 64 位环境中运行 - 取决于您的操作系统和 .NET 框架。

Any .NET app that is compiled for x86 will be 32-bit

C# console apps aren't running in "real" dos - they run in a 32-bit or 64-bit environment - depending on your OS and .NET framework.

三人与歌 2024-07-16 22:45:13

据我了解,所有 DOS cmd 窗口
(包括 C# 控制台应用程序)运行为
16 位而不是 32 位。

这是真的吗?

一点都不。

您可以在 Windows 下运行 DOS 应用程序,它们是 16 位的,但事实上它们看起来有点像控制台,这几乎只是巧合。

不存在 16 位 .NET 应用程序,并且应用程序是否处于控制台模式对于它是 16 位还是 32 位没有影响。

As I understand it all DOS cmd windows
(C# console apps included) run as
16bit not 32bit.

Is this true?

No, not at all.

You can run DOS applications under Windows, and they are 16-bit, but the fact that they look a bit console-like is pretty much just coincidence.

There are no 16-bit .NET applications, and whether an application is console mode or not makes no difference to whether it's 16 or 32 bit.

笑叹一世浮沉 2024-07-16 22:45:13

MS-DOS 应用程序在 ntvdm 下作为 16 位应用程序运行。

“Windows 控制台”应用程序不是 DOS 应用程序,并且作为本机 Windows 进程运行(EXE 文件的 PE 标头中的某个位将其标识为控制台应用程序,以便 Windows 可以为该应用程序创建/准备 Windows 控制台,如果一个尚不存在,例如从 CMD 或 PowerShell 运行控制台应用程序将重新使用已创建的控制台窗口,而在资源管理器中双击 EXE 将为应用程序创建一个新的控制台窗口。)

CMD != DOS

Windows Console != DOS

同样,至少从 Windows 2000 (NT5) 开始,Windows 中就存在一个完整的 Windows 控制台 API(尽管可能仅限于 NT3/4)。

MS-DOS Apps run as 16-bit apps under the ntvdm.

"Windows Console" Applications are not DOS applications, and run as a native Windows Process (where a bit in the PE Header of the EXE File identifies it as a Console Application, so that Windows can create/prep a Windows Console for the application if one does not already exist, e.g. running your Console Application from CMD or PowerShell will re-use the Console Window already created, whereas double-clicking the EXE in Explorer will create a new Console Window for the Application.)

CMD != DOS

Windows Console != DOS

Likewise, there is a full Windows Console API that has been present in Windows since at least Windows 2000 (NT5) if not sooner (though probably NT3/4 only.)

人心善变 2024-07-16 22:45:13

.NET 控制台应用程序。 (或任何其他 .NET 应用程序)将以其 JIT 的任何目标硬件运行。 所以对于 x86 来说它将是 32 位。

A .NET console app. (or any other .NET app) will run as whatever targeted hardware it is JIT'ed to is. So for x86 it will be 32 bit.

明明#如月 2024-07-16 22:45:13

据我了解,所有 DOS cmd 窗口(包括 C# 控制台应用程序)都以 16 位而非 32 位运行。

您错了。 所有 cmd.exe Windows 都是 32 位或 64 位,具体取决于体系结构。

大约十年前,DOS 与 Windows ME 一起消亡。

As I understand it all DOS cmd windows (C# console apps included) run as 16bit not 32bit.

You are wrong. All cmd.exe Windows are 32 or 64-Bit, depending on the architecture.

DOS died together with Windows ME almost a decade ago.

月寒剑心 2024-07-16 22:45:13

我不知道任何能够在 16 位模式下运行的 .NET VM 实现。 Microsoft .NET 运行时和 Mono 都仅为 32/64 位。 我不知道其他较小的,但如果它们可以在 16 位模式下工作,我会感到惊讶。

此外,cmd.exe 以 32 位模式运行,因为 cmd.exe 是 32 位 Windows 应用程序。 另一方面,command.com 以 16 位模式运行。

实际上,控制台应用程序远非本质上是 16 位的。 这根本不是事实,甚至在 Windows 之前也不是这样,因为 x86 保护模式是 32 位,因此在保护模式下运行的任何 DOS 游戏或应用程序都是 32 位。

在 .NET 中,您的 UI 类型(或 Windows 服务中缺少 UI)不会影响应用程序的字长。 默认情况下,.NET 二进制文件与平台无关,并根据主机的 .NET Framework、内核等类型作为 32 位或 64 位应用程序执行。 虽然它们也可以直接编译为 64 位。

I don't know about any .NET VM implementation that is capable of running in 16-bit mode. The Microsoft .NET runtime and Mono are both 32/64 bits only. I don't know about the other smaller ones, but I would be surprised if they could work in 16-bit mode.

Also, cmd.exe runs in 32 bit mode as cmd.exe is a 32-bit Windows application. On the other hand, command.com runs in 16-bit mode.

Actually, console applications are far from being inherently 16-bit. This is just simply not true, it wasn't even true before Windows, as the x86 protected mode is 32-bits, so any game or application for DOS running in portected mode is 32-bits.

In .NET, your type of UI (or lack of UI as in Windows Services) does not affect the word length of the application. By default, .NET binaries are platform independent, and get executed as 32-bit or 64-bit application depending the type of .NET Framework, kernel, etc. of the host machine. Although they can be compiled directly to 64-bits too.

南笙 2024-07-16 22:45:13

控制台 exe 没有什么特别之处; 它只是一个PE文件。 因此,无论控制台、winform exe 还是 Windows 服务,它都会以任何编译模式运行。

Visual Studio 等永远不会生成 16 位 exe。 x86 与 x64 更有趣;-p

可能,您的朋友没有安装 .NET 框架(或者只安装了 1.1)。

There is nothing special about a console exe; it is just a PE file. So regardless of console vs winform exe vs windows service, it is just going to run in whatever mode it was compiled.

Visual Studio etc will never generate a 16-bit exe. x86 vs x64 is more interesting ;-p

Probably, your friend doesn't have the .NET framework installed (or only has 1.1).

○闲身 2024-07-16 22:45:13

即使在 DOS 下,“.EXE”也可以是 16 位或 32 位(具有适当的编码或 DOS 扩展库)。

Even under DOS, ".EXE" could be 16-bit or 32-bit (with appropriate coding or DOS extender library).

往事随风而去 2024-07-16 22:45:13

NTVDM.EXE 是 DOS 模拟器,支持在假设 CPU 为 16 位且 DOS 系统的环境中运行 16 位 .COM.EXE 文件可以打电话。 它与命令提示符的唯一关联是文本模式 DOS 程序使用控制台窗口来提供文本模式下 VGA 屏幕的模拟。

如前所述,没有可以在 DOS 下运行的 .NET VM。 然而,从 Mono 项目源开始并构建一个在 FreeDOS 下运行的项目可能会很有趣......只是为了吓唬你的朋友;-)

NTVDM.EXE is the DOS emulator that supports running 16-bit .COM and .EXE files in an environment where they can assume the CPU is 16-bit and that DOS system calls are available. Its only association with command prompts is that text-mode DOS programs use the Console window to supply the emulation of a VGA screen in text mode.

As noted, there is no .NET VM available that can run under DOS. However, it might fun to start from the Mono project sources and build one that runs under FreeDOS... just to scare your friends ;-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文