473,698 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ 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 2722
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***@discussi ons.microsoft.c om> wrote in message
news:DE******** *************** ***********@mic rosoft.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******** ******@TK2MSFTN GP12.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***@discussi ons.microsoft.c om> wrote in message
news:DE******** *************** ***********@mic rosoft.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
741
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 managed point-of-view I've noticed that: 1) for each managed and unmanaged C function (not C++ classes) I get a public managed static method (defined on a 'Global Functions' class) in the generated assembly with an export name of the form...
1
2121
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. The guts will remain in unmanaged c++. So I need to write public managed c++ wrapper classes for the couple of interfaces the unmanaged stuff needs to expose for the GUI. Questions:
3
3503
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
1625
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. If we put wrappers around some of our code or leave some "asis" what makes our existing production code 'evil' just because it is now considered 'unmanaged'? It may seem like a simple niave question, but the definitions for managed and...
6
3363
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 overrides the virutal one in the base. In my managed class, I have the following private: CUnmanaged __nogc* m_pUnManaged
9
3119
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 this, I want to use it. Is it possible to call Managed class functions from Unmanaged class? How to do it? I did something like this. I declared a managed class (in C++ CLI) called as MyManagedClass whose
2
1266
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 code? I've tried this but keep getting a system::exception is thrown with the message "External component has thrown an exception" when the CFile instance is created. 2. How does the assignment operator check to see that the source and...
25
3016
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 MyClass:IDisposable
9
3559
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 3rd party unmanaged DLL will pass this reference into standard Win32 unmanaged static callback function in my code. Inside this unmanaged callback function I need to cast this unmnaged pointer that I have received from 3rd party back into the...
0
8674
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9026
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.