Managed and Unmanaged Code Confusion

Discussion in 'ASP .Net' started by =?Utf-8?B?U2FuZHk=?=, Oct 26, 2004.

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

    Thanks in advance

    Sandeep Chitode
    =?Utf-8?B?U2FuZHk=?=, Oct 26, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?U2FuZHk=?=

    Karl Seguin Guest

    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/d...html/cpconInteroperatingWithUnmanagedCode.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" <> wrote in message
    news:D...
    > I am confused about Unmanaged Code, How .Net Framework treate that code,
    > What is the use of that.
    >
    > Thanks in advance
    >
    > Sandeep Chitode
    Karl Seguin, Oct 26, 2004
    #2
    1. Advertising

  3. > 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:...
    > 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/d...html/cpconInteroperatingWithUnmanagedCode.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" <> wrote in message
    > news:D...
    > > I am confused about Unmanaged Code, How .Net Framework treate that code,
    > > What is the use of that.
    > >
    > > Thanks in advance
    > >
    > > Sandeep Chitode

    >
    >
    Kevin Spencer, Oct 26, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Weston Fryatt
    Replies:
    2
    Views:
    953
    Weston Fryatt
    Jan 1, 2005
  2. Laurent Bugnion
    Replies:
    0
    Views:
    443
    Laurent Bugnion
    Dec 6, 2006
  3. frank
    Replies:
    3
    Views:
    760
    rossum
    Jan 22, 2007
  4. GAH
    Replies:
    0
    Views:
    487
  5. Jürgen Tabert

    managed C++ Webservice and unmanaged code

    Jürgen Tabert, Jun 3, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    138
    Jürgen Tabert
    Jun 3, 2005
Loading...

Share This Page