Difference between Unmanaged Code and Managed Code

Recently, I'm starting to develop laser ultrasonic scanning system in .Net platform. In the passed, I was using LabVIEW 8.6 to run the system. However, I would like to try with this new platform, where I can learn extra new programming language which lead me easy to compete in coming future.

Before I start to develop the codes for the full system, I have wrapped the unmanaged DLL in .Net using Marshal function. For that, I have to know the difference between the unmanaged and managed DLLs. The following are the definition and different between both.

Managed code is what Visual Basic .NET and C# compilers create. It runs on the CLR (Common Language Runtime), which, among other things, offers services like garbage collection, run-time type checking, and reference checking. So, think of it as, "My code is managed by the CLR.


Visual Basic and C# can only produce managed code, so, if you're writing an application in one of those languages you are writing an application managed by the CLR. If you are writing an application in Visual C++ .NET you can produce managed code if you like, but it's optional.


Unmanaged code compiles straight to machine code. So, by that definition all code compiled by traditional C/C++ compilers is 'unmanaged code'. Also, since it compiles to machine code and not an intermediate language it is non-portable.
No free memory management or anything else the CLR provides.
Since you cannot create unmanaged code with Visual Basic or C#, in Visual Studio all unmanaged code is written in C/C++.


Further links:
http://en.wikipedia.org/wiki/Managed_code

Comments

Popular posts from this blog

Split Container Control in C#

LabVIEW State Machine Basic Example

Calling Win32 DLLs in C# with P/Invoke