473,785 Members | 2,738 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 2728
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
2127
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
3513
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
1631
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
3368
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
3123
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
1271
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
3019
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
3565
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
9480
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
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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
10087
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
8971
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...
0
6737
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();...
0
5380
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
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.