Last post Mar 02, 2011 09:23 AM by PINET
Feb 28, 2011 07:36 PM|Naseet123|LINK
What is the main difference between managed code and un-managed code in .NET?
Could you please explain with example?
Thanks in advance.
Feb 28, 2011 07:49 PM|hiteshspatel|LINK
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
Feb 28, 2011 08:05 PM|Naseet123|LINK
Code which is not complied by CLR is called unmanaged code. e.g. code written in VB 6.0. >> Does that mean we can not write un-managed code in C#.NET?
If you can provide some example of un-managed code then it will clear my doubt.
Mar 01, 2011 09:09 PM|hiteshspatel|LINK
to the best of my knowledge, the answer is no. However you are able to call unmanaged dll from the managed code using dllimport attribute. What exactly are you trying to achieve?
Mar 01, 2011 11:59 PM|XtremeBytes|LINK
Anything that runs under .NET Runtime is a managed code. With C# you cannot write an unmanaged code. You might have requirement where you have to use one of the exisitng DLL or a library created in any other language like C or VC++ that you use. They are
the typical unmanaged code.
Mar 02, 2011 12:14 AM|RaviSM|LINK
Manged Code is that code which run under CLR i.e Common Languge Runtime
1)Managed Code is executed under CLR
2)Converted into MSIL i.e microsoft intermediate language.
3)Memory allocation and Garbage collection are managed by CLR
in unmanaged code
and this Link
Mar 02, 2011 01:39 AM|ramiramilu|LINK
Read this -
Mar 02, 2011 04:21 AM|Nandip Makwana|LINK
You can refer the following blog post.
Mar 02, 2011 08:55 AM|ptsivakumar|LINK
a) Managed Code is created by VB.Net or C# compiler. Where as, Unmanaged Code is created by older tools such as VB 6.0, VC++ etc.
b) Managed Code is compiled to Intermediate Language (IL), not to machine code that could run directly on your computer. Where as, Unmanaged Code compiled directly to machine code that ran on the machine where you compiled it.
c) Managed Code gets the services such as security or memory management from CLR, where as Unmanaged Code does not gets such services.
Mar 02, 2011 09:23 AM|PINET|LINK
The non dot net languages code is added as unmanaged code in .net project, basically it is also code but lacking .net features and security (as it can have pointers etc.) so previous languages code is added in .net using unmanaged option (tag) and by doing
that you are telling .net environment that this code is secure and i have tested it, (.Net runtime will not add security to it.)