Software job search
.net sql interview questions
  The best place for technical interview questions
free matrimony
 
Home.netSql serverAsp.netC#Vb.netAdo.netAjaxMcpd dumpsWord count tool
Question. What is the difference between managed and unmanaged code in .net?

Definitions for managed code:

1. Code that is executed by the CLR. Managed code provides information (i.e., metadata) to allow the CLR to locate methods encoded in assembly modules, store and retrieve security information, handle exceptions, and walk the program stack. Managed code can access both managed data and unmanaged data. Managed data—Memory that is allocated and released by the CLR using Garbage Collection. Managed data can only be accessed by managed code


2.Code that targets the common language runtime, the foundation of the .NET Framework, is known as managed code; code that does not target the common language runtime is known as unmanaged code. You can think of the runtime as an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type safety in the code. The concept of code management is a fundamental principle of the runtime.

3.Managed code supplies the metadata necessary for the CLR to provide services such as memory management, cross-language integration, code access security, and automatic lifetime control of objects. All code based on IL executes as managed code.

4.Code that executes under the CLI execution environment. Managed code uses the execution environment for memory management, object lifetime, and the basic type-system, among other fundamental services.

Unmanaged code is what you use to make before Visual Studio .NET 2002 was released. Visual Basic 6, Visual C++ 6, heck, even that 15-year old C compiler you may still have kicking around on your hard drive all produced unmanaged code. It compiled directly to machine code that ran on the machine where you compiled it—and on other machines as long as they had the same chip, or nearly the same. It didn't get services such as security or memory management from an invisible runtime; it got them from the operating system. And importantly, it got them from the operating system explicitly, by asking for them, usually by calling an API provided in the Windows SDK. More recent unmanaged applications got operating system services through COM calls.
Unlike the other Microsoft languages in Visual Studio, Visual C++ can create unmanaged applications. When you create a project and select an application type whose name starts with MFC, ATL, or Win32, you're creating an unmanaged application.
This can lead to some confusion: When you create a .Managed C++ application., the build product is an assembly of IL with an .exe extension. When you create an MFC application, the build product is a Windows executable file of native code, also with an .exe extension. The internal layout of the two files is utterly different. You can use the Intermediate Language Disassembler, ildasm, to look inside an assembly and see the metadata and IL. Try pointing ildasm at an unmanaged exe and you'll be told it has no valid CLR (Common Language Runtime) header and can't be disassembled—Same extension, completely different files.



 Rate this answer
     
 29 votes , average 2 out of 5

Back to interview questions
This question has been viewed 12557 times   

Other questions on interview questions

No Data



interview questions

Reader's opinions -

No comments
Loading

 
.net interview questions
Asp.net interview questions
C# interview questions
Vb.net interview questions
Ado.net interview questions
Ajax interview questions
Wcf interview questions
Wpf interview questions
.net threading interview questions
.net remoting and webservices interview questions
.net caching interview questions
.net oops interview questions
Sharepoint interview questions
Jquery interview questions
Silverlight interview questions
Linq interview questions
Wwf interview questions
Java interview questions
Sql server interview questions
Ssis interview questions
Ssrs interview questions
Data warehousing interview questions
Data mining interview questions
Oracle interview questions
Php interview questions
Design patterns interview questions
Uml interview questions
Mcpd dumps
Pmp practice tests

This site is best viewed with Internet Explorer 7.0 or higher, Firefox 2.0 or higher, Chrome at a minimum screen resolution of 1024x768.
A complete solution to interview questions
free matrimonial website      
Support Wikipedia