سؤال

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.

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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.

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top