Managed and Unmanaged

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have just read that SqlConnection and SqlCommand are unmanaged types, or
contain bits that are unmanaged? whereas a DataSet is wholly managed. This
is annoying me because I thought all .NET types were managed?

This obviously stems from looking in to Dispose but my questions are:

1. Is the above statement true?

2. What exactly does managed and unmanaged imply and how do I tell if a type
is managed or unmanaged?

3. Is the File type also unmanaged?

Thank you in advance

Pete
 
Managed code is code that is run (or managed by the Common Language Runtime
[CLR]). Unmanaged code is code that is not. Most of the classes that
communicate with a data source are (in some part) unmanaged because of the
very fact that the underlying data providers are not managed code. A
DataSet is not in communication with a data source (it is not a data access
object), while connections, commands, dataadapters and datareaders are part
of the ADO.NET data access layer.

You can generally "guess" that a type may not be 100% managed if it
interacts with unmanaged resources (databases, etc.), but you can also
generally tell by looking at what the object inherits from and where its
Dispose method is added.
 
This is also why it's important to call the method Dispose() instead of
Close() for objects like SqlConnection.

S. L.

Scott M. said:
Managed code is code that is run (or managed by the Common Language
Runtime [CLR]). Unmanaged code is code that is not. Most of the classes
that communicate with a data source are (in some part) unmanaged because
of the very fact that the underlying data providers are not managed code.
A DataSet is not in communication with a data source (it is not a data
access object), while connections, commands, dataadapters and datareaders
are part of the ADO.NET data access layer.

You can generally "guess" that a type may not be 100% managed if it
interacts with unmanaged resources (databases, etc.), but you can also
generally tell by looking at what the object inherits from and where its
Dispose method is added.

Pete said:
I have just read that SqlConnection and SqlCommand are unmanaged types, or
contain bits that are unmanaged? whereas a DataSet is wholly managed.
This
is annoying me because I thought all .NET types were managed?

This obviously stems from looking in to Dispose but my questions are:

1. Is the above statement true?

2. What exactly does managed and unmanaged imply and how do I tell if a
type
is managed or unmanaged?

3. Is the File type also unmanaged?

Thank you in advance

Pete
 
Back
Top