473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Managed and Unmanaged Code Confusion

I am confused about Unmanaged Code, How .Net Framework treate that code,
What is the use of that.

Thanks in advance

Sandeep Chitode
Nov 18 '05 #1
2 2708
I hope someone will correct me if I'm horribly wrong, but:

Managed code runs in the CLR (a virtual machine) which provides a number of
services: security, type safety, memory management just to name a few.
Unmanaged code doesn't run in the CL and is typically known as COM, COM+,
ActiveX, Win32 API.... However, the CLR does allow for interopability
between the two (which would be how the CLR treats it), basically shielding
from you the fact that code is unmanged.

If you are specifically interested in interopability, start by checking out:
http://msdn.microsoft.com/library/de...anagedCode.asp

Ideally, the "use" of unmanaged code would be something only there for
backwards compatibility. Everyone (ideally again) should be using Managed
Code...it lends itself to safer (which is I use broadly) and code which is
quicker to develop. Realistically, the CLR and .Net still aren't ideal for
all forms of development, such as real time development, graphically intense
development, firmware and the likes..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
I am confused about Unmanaged Code, How .Net Framework treate that code,
What is the use of that.

Thanks in advance

Sandeep Chitode

Nov 18 '05 #2
> Managed code runs in the CLR (a virtual machine) which provides a number
of
services: security, type safety, memory management just to name a few.
Unmanaged code doesn't run in the CL and is typically known as COM, COM+,
ActiveX, Win32 API.... However, the CLR does allow for interopability
between the two (which would be how the CLR treats it), basically shielding from you the fact that code is unmanged.
Excellent explanation.
Ideally, the "use" of unmanaged code would be something only there for
backwards compatibility. Everyone (ideally again) should be using Managed
Code...it lends itself to safer (which is I use broadly) and code which is
quicker to develop. Realistically, the CLR and .Net still aren't ideal for all forms of development, such as real time development, graphically intense development, firmware and the likes..
I'm not sure what you mean by "Ideally," as that is a value judgment, almost
as if it is immoral to use unmanaged code. In fact, it is necessary to use
unmanaged code from time to time, if you are working on stuff that warrants
it. For example, I wrote some classes that "filter" images, applying
blurring, sharpness, contrast, and a number of other types of pixel-by-pixel
operations that become dreadfully slow if you use managed code only. I have
also written some classes that store tabular (Digital Elevation Model) data
in bitmaps for speed, and again, must loop through the pixels of the bitmap
to get the data. Using the GetPixel managed method to get to these pixels is
way too slow. Using a pointer is, of course, very fast. And note that
Microsoft has included fields and properties in managed classes to get a
pointer where necessary or useful.

The true advantage of managed code is that the developer doesn't have to
manage it. Specifically, you don't have to make sure that you have cleaned
up allocated memory, thus avoiding memory leaks. There is nothing immoral or
less-than-ideal about using unmanaged code from time to time. You just have
to manage it well for yourself.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uz**************@TK2MSFTNGP12.phx.gbl... I hope someone will correct me if I'm horribly wrong, but:

Managed code runs in the CLR (a virtual machine) which provides a number of services: security, type safety, memory management just to name a few.
Unmanaged code doesn't run in the CL and is typically known as COM, COM+,
ActiveX, Win32 API.... However, the CLR does allow for interopability
between the two (which would be how the CLR treats it), basically shielding from you the fact that code is unmanged.

If you are specifically interested in interopability, start by checking out: http://msdn.microsoft.com/library/de...anagedCode.asp
Ideally, the "use" of unmanaged code would be something only there for
backwards compatibility. Everyone (ideally again) should be using Managed
Code...it lends itself to safer (which is I use broadly) and code which is
quicker to develop. Realistically, the CLR and .Net still aren't ideal for all forms of development, such as real time development, graphically intense development, firmware and the likes..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
I am confused about Unmanaged Code, How .Net Framework treate that code,
What is the use of that.

Thanks in advance

Sandeep Chitode


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
1
by: Eric Twietmeyer | last post by:
Hello, I'm starting to investigate cs, managed c++ and interoperating with a very large unmanaged code base. We are going to use Windows Forms (written in cs) to replace our old fashioned GUI. ...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
12
by: doug | last post by:
I understand the basics of what managed code offers and that you open yourself up to security issues if you allow unmanaged code. We already have a decent amount of VB6 code to include COM DLLs. ...
6
by: guxu | last post by:
I have a managed C++ code which calls some methods in unmanaged C++ DLL. In my unmanaged DLL, I have a PROTECTED virutal function in a base class and derived class has a PRIVATE function which...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
2
by: Ian | last post by:
1. I want to be use mix unmanaged code with managed code. In particular, the unmanaged code uses MFC CFile to perform file I/O. Can CFile be used in unmanaged code that is mixes with managed...
25
by: Koliber (js) | last post by:
sorry for my not perfect english i am really f&*ckin angry in this common pattern about dispose: ////////////////////////////////////////////////////////// Public class...
9
by: =?Utf-8?B?RWR3YXJkUw==?= | last post by:
I would greatly appreciate some help on passing managed object into unmanaged code. I need to pass a reference (address of) of a managed class into unmanaged code (written by a thrid party). The...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.