C# Programming - .NET Framework - Discussion
Discussion Forum : .NET Framework - General Questions (Q.No. 1)
1.
Which of the following statements are TRUE about the .NET CLR?
- It provides a language-neutral development & execution environment.
- It ensures that an application would not be able to access memory that it is not authorized to access.
- It provides services to run "managed" applications.
- The resources are garbage collected.
- It provides services to run "unmanaged" applications.
Discussion:
50 comments Page 1 of 5.
Sugath said:
1 decade ago
Managed Code:
Managed code is code that is written to target the services of the managed runtime execution environment (like Common Language Runtime in .NET Framework). The managed code is always executed by a managed runtime execution environment rather than the operating system directly. Managed refers to a method of exchanging information between the program and the runtime environment. Because the execution of code is governed by the runtime environment, the environment can guarantee what the code is going to do and provide the necessary security checks before executing any piece of code. Because of the same reason the managed code also gets different services from the runtime environment like Garbage Collection, type checking, exception handling, bounds checking, etc. This way managed code does not have to worry about memory allocations, type safety, etc. Applications written in Java, C#, VB.NET, etc target a runtime environment which manages the execution and the code written using these types of languages is known as Managed Code. Managed code is always compiled into an Intermediate Language (MSIL in case of .NET Framework). The compiler used by .NET framework to compile managed code compiles it into Intermediate Language and generates the necessary metadata, symbolic information that describes all of the entry points and the constructs exposed in the Intermediate Language (e.g., methods, properties) and their characteristics. The Common Language Infrastructure (CLI) Standard describes how the information is to be encoded, and programming languages that target the runtime emit the correct encoding.
In .NET Framework Managed Code runs within the .Net Framework's CLR and benefits from the services provided by the CLR. When we compile the managed code, the code gets compiled to an intermediate language (MSIL) and an executable is created. When a user runs the executable the Just In Time Compiler of CLR compiles the intermediate language into native code specific to the underlying architecture. Since this translation happens by the managed execution environment (CLR), the managed execution environment can make guarantees about what the code is going to do, because it can actually reason about it. It can insert traps and sort of protection around, if it's running in a sandboxed environment, it can insert all the appropriate garbage collection hooks, exception handling, type safety, array bounce, index checking and so forth.
Managed code also provides platform independence. As the managed code is first compiled to intermediate language, the CLR's JIT Compiler takes care of compiling this intermediate language into the architecture specific instructions.
Unmanaged Code
Code that is directly executed by the Operating System is known as un-managed code. Typically applications written in VB 6.0, C++, C, etc are all examples of unmanaged code. Unmanaged code typically targets the processor architecture and is always dependent on the computer architecture. Unmanaged code is always compiled to target a specific architecture and will only run on the intended platform. This means that if you want to run the same code on different architecture then you will have to recompile the code using that particular architecture. Unmanaged code is always compiled to the native code which is architecture specific. When we compile unmanaged code it gets compiled into a binary X86 image. And this image always depends on the platform on which the code was compiled and cannot be executed on the other platforms that are different that the one on which the code was compiled. Unmanaged code does not get any services from the managed execution environment.
In unmanaged code the memory allocation, type safety, security, etc needs to be taken care of by the developer. This makes unmanaged code prone to memory leaks like buffer overruns and pointer overrides and so forth.
Unmanaged executable files are basically a binary image, x86 code, loaded into memory. The program counter gets put there and that's the last the Operating System knows. There are protections in place around memory management and port I/O and so forth, but the system doesn't actually know what the application is doing.
Managed code is code that is written to target the services of the managed runtime execution environment (like Common Language Runtime in .NET Framework). The managed code is always executed by a managed runtime execution environment rather than the operating system directly. Managed refers to a method of exchanging information between the program and the runtime environment. Because the execution of code is governed by the runtime environment, the environment can guarantee what the code is going to do and provide the necessary security checks before executing any piece of code. Because of the same reason the managed code also gets different services from the runtime environment like Garbage Collection, type checking, exception handling, bounds checking, etc. This way managed code does not have to worry about memory allocations, type safety, etc. Applications written in Java, C#, VB.NET, etc target a runtime environment which manages the execution and the code written using these types of languages is known as Managed Code. Managed code is always compiled into an Intermediate Language (MSIL in case of .NET Framework). The compiler used by .NET framework to compile managed code compiles it into Intermediate Language and generates the necessary metadata, symbolic information that describes all of the entry points and the constructs exposed in the Intermediate Language (e.g., methods, properties) and their characteristics. The Common Language Infrastructure (CLI) Standard describes how the information is to be encoded, and programming languages that target the runtime emit the correct encoding.
In .NET Framework Managed Code runs within the .Net Framework's CLR and benefits from the services provided by the CLR. When we compile the managed code, the code gets compiled to an intermediate language (MSIL) and an executable is created. When a user runs the executable the Just In Time Compiler of CLR compiles the intermediate language into native code specific to the underlying architecture. Since this translation happens by the managed execution environment (CLR), the managed execution environment can make guarantees about what the code is going to do, because it can actually reason about it. It can insert traps and sort of protection around, if it's running in a sandboxed environment, it can insert all the appropriate garbage collection hooks, exception handling, type safety, array bounce, index checking and so forth.
Managed code also provides platform independence. As the managed code is first compiled to intermediate language, the CLR's JIT Compiler takes care of compiling this intermediate language into the architecture specific instructions.
Unmanaged Code
Code that is directly executed by the Operating System is known as un-managed code. Typically applications written in VB 6.0, C++, C, etc are all examples of unmanaged code. Unmanaged code typically targets the processor architecture and is always dependent on the computer architecture. Unmanaged code is always compiled to target a specific architecture and will only run on the intended platform. This means that if you want to run the same code on different architecture then you will have to recompile the code using that particular architecture. Unmanaged code is always compiled to the native code which is architecture specific. When we compile unmanaged code it gets compiled into a binary X86 image. And this image always depends on the platform on which the code was compiled and cannot be executed on the other platforms that are different that the one on which the code was compiled. Unmanaged code does not get any services from the managed execution environment.
In unmanaged code the memory allocation, type safety, security, etc needs to be taken care of by the developer. This makes unmanaged code prone to memory leaks like buffer overruns and pointer overrides and so forth.
Unmanaged executable files are basically a binary image, x86 code, loaded into memory. The program counter gets put there and that's the last the Operating System knows. There are protections in place around memory management and port I/O and so forth, but the system doesn't actually know what the application is doing.
GardenExit said:
9 years ago
Native code is not a machine code.
.Net languages all converge to IL (intermediate Language) and executed by the runtime, the runtime runs Win32.dll,kernel.dll, ui.dll, etc... which are all COM objects written in C++ in the form of Components and Containers objects (which exist in their C# form also in managed code).
COM Objects are unmanaged code.
But where the answer is wrong, it should be 1,2,3,4 and 5 is you can run unmanaged code from C# compilers, using the unmanaged keyword and using System.
Interop wrappers around the unmanaged code to marshal, say, marshalling method calls and parameter passing into functions in the IDispatch interface of a COM object.
.Net languages all converge to IL (intermediate Language) and executed by the runtime, the runtime runs Win32.dll,kernel.dll, ui.dll, etc... which are all COM objects written in C++ in the form of Components and Containers objects (which exist in their C# form also in managed code).
COM Objects are unmanaged code.
But where the answer is wrong, it should be 1,2,3,4 and 5 is you can run unmanaged code from C# compilers, using the unmanaged keyword and using System.
Interop wrappers around the unmanaged code to marshal, say, marshalling method calls and parameter passing into functions in the IDispatch interface of a COM object.
(2)
Xyz said:
1 decade ago
The runtime automatically handles object layout and manages references to objects, releasing them when they are no longer being used. Objects whose lifetimes are managed in this way are called managed data. Garbage collection eliminates memory leaks as well as some other common programming errors. If your code is managed, you can use managed data, unmanaged data, or both managed and unmanaged data in your .NET Framework application. Because language compilers supply their own types, such as primitive types, you might not always know (or need to know) whether your data is being managed.
Krishan chandra gupta said:
8 years ago
CLR converting Managed code[VB, C#, J#] to native code which is system understandable.
C#-------> [compiler ]--------->IL code----------->[JIT]----------> Native code.
CLR is checking the code is managed code or not,
CLR provide type safety.
It is ensured that an application would not access the memory that is not Authorised to access.
C#-------> [compiler ]--------->IL code----------->[JIT]----------> Native code.
CLR is checking the code is managed code or not,
CLR provide type safety.
It is ensured that an application would not access the memory that is not Authorised to access.
(4)
Arfab said:
10 years ago
Network is started CLR provides the following:
1. Modern memory management- the resources are automatically garbage collected.
2. Ability to use mixed languages.
3. Better security.
4. Clean way for software components to interact.
Managed code is executable under CLR.
1. Modern memory management- the resources are automatically garbage collected.
2. Ability to use mixed languages.
3. Better security.
4. Clean way for software components to interact.
Managed code is executable under CLR.
(2)
Kaushal said:
10 years ago
CLR is Common Language Runtime: The virtual machine component of Microsoft's .NET framework, manages the execution of .NET programs.
A process known as just-in-time compilation converts compiled code into machine instructions which the computer's CPU then executes.
A process known as just-in-time compilation converts compiled code into machine instructions which the computer's CPU then executes.
Inceptos said:
1 decade ago
CLR provides the following:
1. Modern memory management- the resources are automatically garbage collected.
2. Ability to use mixed languages.
3. Better security.
4. Clean way for software components to interact.
Managed code is executable under CLR.
1. Modern memory management- the resources are automatically garbage collected.
2. Ability to use mixed languages.
3. Better security.
4. Clean way for software components to interact.
Managed code is executable under CLR.
Vin2 said:
1 decade ago
It provides a code which is machine independent that's why 1st option is right, it provides tight security that's why 2nd option is right, CLR runs only managed code so 3rd option is right, and it has automatic garbage collection so 4rth option is right.
Shruthi said:
1 decade ago
It provides a code which is machine independent thats why 1st opt is right, it provides thight security thats why 2nd opt is right, CLR runs nly managed code so 3rd opt is right, and it has automatic garbage collection so 4rth opt is right.
Govindu said:
1 decade ago
il code is a half compile code,il code generated after compile source code. jit compile genarate machine code(processor understandable code like 1 and 0's) from il code when the program execute.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers