发布的应用程序(Windows窗体)是机器代码吗?

发布于 2024-12-16 20:48:11 字数 236 浏览 2 评论 0原文

我知道,这个问题对很多人来说可能很常见,但我很困惑。我正在用 C# 阅读 .net。我浏览了很多文章以及 msdn。我的疑问是:

当我在VS中开发C# Windows窗体应用程序代码并运行它时,Project\bin\Debug\中扩展名为“.exe”的文件是中间代码还是机器代码?当我发布它时,当我得到安装程序时,它是机器代码还是中间代码?因为有时安装程序需要安装 .net。

请帮助我理解这个概念。

谢谢。

I know, the question may be a usual for many, but I am confused like anything. I am reading .net with c#. I went through many articles and also msdn. My doubt is:

When I develop a C# Windows form application code in VS and run it, do the files in Project\bin\Debug\ which have the extension ".exe" are an Intermediate code or machine code? and When I Publish it, the moment i get an installer, is it a machine code or an intermediate code? because sometimes an installer requires .net installed.

Please help me understand this concept.

Thank you.

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

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

发布评论

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

评论(3

夜唯美灬不弃 2024-12-23 20:48:11

编译后的 .exe 包含 MSIL(Microsoft 中间语言代码),其发生方式如下(来自此处< /a>):

  • 源代码被转换为通用中间语言,CIL 相当于 CPU 的汇编语言。
  • 然后,CIL 被组装成所谓的字节码形式,并创建 .NET 程序集。
  • 执行 .NET 程序集时,其代码将通过运行时的 JIT 编译器来生成本机代码。也可以使用提前编译,这消除了这一步,但代价是可执行文件的可移植性。
  • 本机代码由计算机的处理器执行。

当我发布它时,当我得到安装程序时,它是机器代码还是中间代码?因为有时安装程序需要安装 .net。

.Net .exe 始终是 MSIL 代码,安装程序可能会先安装 .net 框架作为应用程序的先决条件。

The compiled .exe contains MSIL (Microsoft Intermediate Language code), here's how it happens (from here):

  • Source code is converted to Common Intermediate Language, CIL's equivalent to Assembly language for a CPU.
  • CIL is then assembled into a form of so called bytecode and a .NET assembly is created.
  • Upon execution of a .NET assembly, its code is passed through the runtime's JIT compiler to generate native code. Ahead-of-time compilation may also be used, which eliminates this step, but at the cost of executable file portability.
  • The native code is executed by the computer's processor.

When I Publish it, the moment i get an installer, is it a machine code or an intermediate code? because sometimes an installer requires .net installed.

The .Net .exe are always MSIL code, the installer might be installing the .net framework before as a prerequisite for your application.

预谋 2024-12-23 20:48:11

简化答案:

当我在VS中开发C# Windows窗体应用程序代码并运行它时,Project\bin\Debug\中扩展名为“.exe”的文件是中间代码还是机器代码?

它是 IL 代码,当您启动 .exe 时,.NET 将其转换为二进制/机器代码

当我发布它时,当我得到安装程序时,它是机器代码还是中间代码?因为有时安装程序需要安装 .net。

同样的事情。发布模式(您应该发布)和调试模式之间的区别在于,前者是优化的,而后者是为了使调试更容易。

Simplified answers:

When I develop a C# Windows form application code in VS and run it, do the files in Project\bin\Debug\ which have the extension ".exe" are an Intermediate code or machine code?

It's IL code which will be converted to binary/machine code by .NET when you start the .exe

and When I Publish it, the moment i get an installer, is it a machine code or an intermediate code? because sometimes an installer requires .net installed.

Same thing. The difference between release mode (which you should publish) and debug mode is that the former is optimized while the other is made to make debugging easier.

白况 2024-12-23 20:48:11

它们都是 MSIL 代码,Project\bin\Debug 中的可执行文件与发布应用程序时获得的可执行文件相同,但它们与打开的调试符号链接。

They're all MSIL code, executables in Project\bin\Debug are same as the ones you get when you publish your application but they're linked with debugging symbols switched on.

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