Home > SOA Tips > .NET Developer > Introduction to the CLR
SOA Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

.NET DEVELOPER

Introduction to the CLR


Narayana Rao Surapaneni
03.04.2003
Rating: -3.33- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


When you program using a programming model, or framework, it's a good idea to understand that framework before you begin. And the .NET Framework is more than a little complex, with many components that have to be understood. This tip, excerpted from InformIT, discusses the purposes and attributes of the common language runtime, one of the fundamental portions of the .NET Framework.


The CLR is the execution environment provided by the Microsoft .NET Framework. It provides many services such as:

Because the CLR manages the code execution, all the code that is targeted for the CLR is known as managed code. Managed code emits metadata along with the executable. This metadata is used to describe the types (classes) and members used in the code, along with all the external references used in executing the code. The CLR uses this metadata to load the classes during execution and resolve method invocations during runtime.

The CLR provides automatic garbage collection of the objects that have been loaded into memory. All objects that are created via the new operator are allocated memory on the heap. A program can allocate as many objects as are required by the program logic. However, when an object is no longer required, there must be some mechanism to free up the memory that was occupied by the object.

This is accomplished in the CLR via a program called garbage collector, which collects all objects in memory that have no references. This program runs as a low-priority thread in the background process and collects all unreferenced objects. Because memory management is automatic, the chances for memory leaks in the program are minimized.

However, the time when garbage collector would actually release the objects from the memory is not known. This concept is known as nondeterministic garbage collection because it cannot be determined in advance when the objects would be released from memory.

If sufficient memory is not


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Microsoft .NET Web services
How do I balance throughput requirements and interoperability?
APM software traces transactions across tiers, technologies
How you can learn M Grammar for Oslo modeling
Legacy modernization opens Windows for publisher
Former .NET Web developers ride Ruby and Rails application framework
Microsoft Oslo at PDC: Dial 'M' for modeling language
Yahoo proxy fight looms
New Microsoft site for architects
LAMP coders go hybrid route
Silverlight shines on bank RIAs
Microsoft .NET Web services Research

Platforms and Servers
Tracking down managed memory leaks
Handling exceptions in .NET
.NET Compact Framework graphics
The Data Access Application Block
Decision time: .NET or J2EE?
A great .NET resource: .Net2TheMax
Delegates vs. interfaces in .NET
Project structure best practices
Working with PDFs in a .NET environment
Displaying errors with the error provider

.NET Developer
Programming Indigo
DataSets and Web services don't mix
Security in .NET 2.0
Tracking down managed memory leaks
Handling exceptions in .NET
.NET Compact Framework graphics
The Data Access Application Block
A great .NET resource: .Net2TheMax
Delegates vs. interfaces in .NET
Project structure best practices

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Common Language Infrastructure  (SearchSOA.com)
Visual J#  (SearchSOA.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


available for creating new objects, the CLR throws an exception that can be caught and gracefully handled by the application.

Code Access Security (CAS), as the name suggests, is used to control the access that the code has to system resources. The CLR has a runtime security system. Administrators can configure policy settings by specifying the resources that can be accessed by the code.

A call stack is created that represents the order in which the assemblies get called. The CLR's security system walks the stack to determine whether the code is authorized to access the system resources or perform certain operations. If any caller in the call stack does not have the requisite permission to access the specific system resources, a security exception is thrown by the CLR.

Simplified versioning is another feature provided in the .NET Framework. It supports versioning and also provides for side-by-side execution of different versions of the same component. The specific versions of the assembly and the dependent assemblies are stored in the assembly's manifest. The copies of the same assembly that differ only in version numbers are considered to be different assemblies by the CLR. Assemblies are explained in more detail in the later sections.

Simplified deployment is one of the features provided in the .NET Framework. The most important point to mention is that .NET components do not need to be registered in the Windows registry. All code generated in the .NET Framework is self-describing because assemblies contain the manifest and metadata information. This information contains all the data about the dependencies of the assembly and the specific versions of the components that these assemblies would use at execution time; therefore, multiple versions of the same components can coexist. The CLR enforces the versioning policy.

Cross-language interoperability is an important feature, and it was one of the design goals of the .NET Framework. This feature is possible because of the CTS and CLS. The CTS is explained in more detail in the next subsection.

Visual Studio .NET allows for debugging across an application consisting of different languages targeted for the CLR. In fact, the IDE also allows for debugging an application in which managed code interacts with unmanaged code.

CLR ensures that performance of the code execution is optimized. Compiled code is stored in cache. When the same code is called next time, this code is loaded into memory from cache. This advantage stands out more in the case of ASP.NET applications than for ASP applications. ASP code was interpreted every time an ASP page was requested. In ASP.NET, the code is compiled only once when the page is requested for the first time. This ensures that performance is optimized.

The .NET Framework also provides some classes for tracking the performance of the .NET applications. These classes are known as performance counters. The .NET Framework provides performance counters for getting information on exception handling, interoperation with unmanaged code, loading and unloading code into memory, locking and threading, memory, networking operations, and so on. These performance counters help to fine-tune the performance of the .NET applications.


To read the entire article from which this tip is excerpted, click over to InformIT. You have to register there, but the registration is free.


Rate this Tip
To rate tips, you must be a member of SearchSOA.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SOA Trends and Strategy - SOA Education, SOA Development, SOA Implementations
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2001 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts