what are the major parameters for managed and unmanaged code in .Net
7 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Shervin CyrilRank #573 · 4.2K reputationPosted Nov 18, 2019, 8:09 AM EST
0
Hey Dipa,
The code written to execute in managed run time environment like CLR in .NET framework is called managed code. Here the code is executed in managed runtime instead of directly executed by operating system.
Some of the services of managed environment are,
Garbage collection,
Type checking
Exception handling
bounds checking
The above services will be automatically available to the code without programmer interfernace.
It also provides memory allocation, type safety, etc to the code.
Languages like Java, C#, VB.Net, etc are the few examples of managed languages.
To get more info please visit : - https://www.geeksforgeeks.org/managed-code-and-unmanaged-code-in-net/
Thanks,
Shervin
0
Ashutosh GuptaRank #805 · 2.9K reputationPosted Nov 18, 2019, 6:05 PM EST
0
an existing article "Managed code and unmanaged code(https://www.c-sharpcorner.com/uploadfile/puranindia/managed-code-and-unmanaged-code-in-net/)" on c# corner may help you
0
Mageshwaran RRank #411 · 6.1K reputationPosted Nov 18, 2019, 6:54 PM EST
0
Managed Code:
Managed code is .NET code (VB.NET, C# etc.) that you write and compile to .NET CIL.
Unmanaged Code:
Unmanaged code is code that is not under .NET that compiles to direct machine code.
0
Priyanka SinghRank #1,215 · 1.5K reputationPosted Nov 18, 2019, 7:02 PM EST
0
The resource, which is within your application domain is managed code. The resources that are within domain are faster.
The code, which is developed in .NET framework, is known as managed code. This code is directly executed by CLR with the help of managed code execution. Any language that is written in .NET Framework is managed code.
Unmanaged Code
The code, which is developed outside .NET, Framework is known as unmanaged code.
0
Arun Kumar TiwariRank #3,157 · 454 reputationPosted Nov 18, 2019, 7:10 PM EST
0
* Managed code is .NET code (VB.NET, C#, etc.) that you write and compile to .NET framework CIL. For example, managed code Languages like Java, C#, VB.Net, etc
* Unmanaged code is code that is not under the .NET framework that compiles to direct machine code.
0
Nirmal DayalRank #1,711 · 886 reputationPosted Nov 18, 2019, 7:14 PM EST
0
Managed code is .NET code (VB.NET, C# etc.) that you write and compile to .NET CIL.
Unmanaged code is code that is not under .NET that compiles to direct machine code.
What Is Managed Code?
Managed Code is what Visual Basic .NET and C# compilers create. It compiles to Intermediate Language (IL), not to machine code that could run directly on your computer. The CIL is kept in a file called an assembly, along with metadata that describes the classes, methods, and attributes (such as security requirements) of the code you've created. This assembly is the one-stop-shopping unit of deployment in the .NET world. You copy it to another server to deploy the assembly there—and often that copying is the only step required in the deployment.
Managed code runs in the Common Language Runtime. The runtime offers a wide variety of services to your running code. In the usual course of events, it first loads and verifies the assembly to make sure the CIL is okay. Then, just in time, as methods are called, the runtime arranges for them to be compiled to machine code suitable for the machine the assembly is running on, and caches this machine code to be used the next time the method is called. (This is called Just In Time, or JIT compiling, or often just Jitting.)
As the assembly runs, the runtime continues to provide services such as security, memory management, threading, and the like. The application is managed by the runtime.
Visual Basic .NET and C# can produce only managed code. If you're working with those applications, you are making managed code. Visual C++ .NET can produce managed code if you like: When you create a project, select one of the application types whose name starts with .Managed., such as .Managed C++ application..
What Is Unmanaged Code?
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 CIL 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 CIL. 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.
0
Rajeev KumarRank #1,334 · 1.3K reputationPosted Mar 6, 2023, 8:53 AM EST
0
Difference between managed and unmanaged code? Managed code is the one that is executed by the CLR of the .NET framework while unmanaged or unsafe code is executed by the operating system. The managed code provides security to the code while undamaged code creates security threats
Shervin CyrilRank #573 · 4.2K reputationPosted Nov 18, 2019, 8:09 AM EST
Ashutosh GuptaRank #805 · 2.9K reputationPosted Nov 18, 2019, 6:05 PM EST
Mageshwaran RRank #411 · 6.1K reputationPosted Nov 18, 2019, 6:54 PM EST
Priyanka SinghRank #1,215 · 1.5K reputationPosted Nov 18, 2019, 7:02 PM EST
The code, which is developed outside .NET, Framework is known as unmanaged code.
Arun Kumar TiwariRank #3,157 · 454 reputationPosted Nov 18, 2019, 7:10 PM EST
Nirmal DayalRank #1,711 · 886 reputationPosted Nov 18, 2019, 7:14 PM EST
What Is Managed Code?
Managed Code is what Visual Basic .NET and C# compilers create. It compiles to Intermediate Language (IL), not to machine code that could run directly on your computer. The CIL is kept in a file called an assembly, along with metadata that describes the classes, methods, and attributes (such as security requirements) of the code you've created. This assembly is the one-stop-shopping unit of deployment in the .NET world. You copy it to another server to deploy the assembly there—and often that copying is the only step required in the deployment.
Managed code runs in the Common Language Runtime. The runtime offers a wide variety of services to your running code. In the usual course of events, it first loads and verifies the assembly to make sure the CIL is okay. Then, just in time, as methods are called, the runtime arranges for them to be compiled to machine code suitable for the machine the assembly is running on, and caches this machine code to be used the next time the method is called. (This is called Just In Time, or JIT compiling, or often just Jitting.)
As the assembly runs, the runtime continues to provide services such as security, memory management, threading, and the like. The application is managed by the runtime.
Visual Basic .NET and C# can produce only managed code. If you're working with those applications, you are making managed code. Visual C++ .NET can produce managed code if you like: When you create a project, select one of the application types whose name starts with .Managed., such as .Managed C++ application..
What Is Unmanaged Code?
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 CIL 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 CIL. 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.
Rajeev KumarRank #1,334 · 1.3K reputationPosted Mar 6, 2023, 8:53 AM EST
Difference between managed and unmanaged code? Managed code is the one that is executed by the CLR of the . NET framework while unmanaged or unsafe code is executed by the operating system. The managed code provides security to the code while undamaged code creates security threats
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts