8
Reply

What is the different between managed code and unmanaged code?

    Compiled code is managed code Source code is unmanaged code

    Compiled code is managed code Source code is unmanaged code

    Compiled code is managed code Source code is unmanaged code

    Compiled code is managed code Source code is unmanaged code

    Managed code means the code which gets complied by CLR and then get converted into MSIL. Anything written using .net languages like c#,vb.net or vc++ ultimately gets converted into same MSIL and then to machine language.Code which is not complied by CLR is called unmanaged code. e.g. code written in VB 6.0

    Answer - In simple words, the code which requires managed runtime for its execution ex: .Net codes are called managed code. The code written in C/C++ which doesn't required managed runtime for its execution is called unmanaged code.

    http://net-informations.com/faq/net/managed-code.htm

    What is Managed Code ?Managed code is the code that is written to target the services of the managed runtime execution environment such as Common Language Runtime in .Net Technology.The Managed Code running under a Common Language Runtime cannot be accessed outside the runtime environment as well as cannot call directly from outside the runtime environment. It refers to a contract of cooperation between natively executing code and the runtime. It offers services like garbage collection, run-time type checking, reference checking etc. By using managed code you can avoid many typical programming mistakes that lead to security holes and unstable applications, also, many unproductive programming tasks are automatically taken care of, such as type safety checking, memory management, destruction of unused Objects etc.What is Unmanaged Code?Unmanaged code compiles straight to machine code and directly executed by the Operating System. The generated code runs natively on the host processor and the processor directly executes the code generated by the compiler. It is always compiled to target a specific architecture and will only run on the intended platform. So, if you want to run the same code on different architecture then you will have to recompile the code using that particular architecture.Unmanaged executable files are basically a binary image, x86 code, directly loaded into memory. This approach typically results in fastest code execution, but diagnosing and recovery from errors might difficult and time consuming in most cases. The memory allocation, type safety, security, etc needs to be taken care of by the programmer and this will lead unmanaged code prone to memory leaks like buffer overruns, pointer overrides etc.All code compiled by traditional C/C++ compilers are Unmanaged Code. COM components, ActiveX interfaces, and Win32 API functions are examples of unmanaged code. Managed code is code written in many high-level programming languages that are available for use with the Microsoft .NET Framework, including VB.NET, C#, J#, JScript.NET etc. Since Visual C++ can be compiled to either managed or unmanaged code it is possible to mix the two in the same application.