Benefits of Managed Code

The .NET Micro Framework contains the TinyCLR. Code that is executed and managed by the CLR is referred to as managed code, whereas code that does not target the CLR is known as unmanaged (native) code. The CLR executes intermediate-language code and provides the following core services and benefits:

• Automatic memory management using a garbage collector
• Thread management and synchronization
• Exception handling
• Strict type safety
• Secure and robust managed code
• Debugging services

The CLR uses a garbage collector that automatically frees unused memory blocks and manages threads by providing time slices to the individual threads and methods to synchronize access to shared resources. Managed code is executed under the control of the CLR, which takes care of references to objects, so you do not have to deal with the unsafe pointers that are common with native programming. With managed code, you can’t access memory blocks once they’ve been disposed of because the CLR frees objects only when they are not referenced anymore. It also enforces strict type safety, and the TinyCLR prevents execution of unsafe, nonsystem native code. Together with exception handling, a modern way to handle errors, managed code enables you to build secure and robust applications. Managed code assemblies contain much information (metadata). Therefore, using managed code also allows you to use static code analysis tools like FxCop to detect and enforce good programming practices such as:

• Enforcing consistent naming of classes and methods
• Detecting unused code
• Detecting performance issues
• Detecting design issues

Source of Information : Apress Expert Dot NET Micro Framework 2nd Edition (09-2009)


Subscribe to Developer Techno ?
Enter your email address:

Delivered by FeedBurner