VB.NET: Lesson 1-1 The .NET Framework and the CLR

August 9, 2007 at 4:18 am Leave a comment

Today I read the first lesson from chapter 1, “Introduction to the .NET Framework”, in  Developing Windows-Based Applications with Microsoft Visual Basic.NET and Visual C#.NET . I read through the lesson and took the notes shown in the section below as I read. After I finished reading, I thought “ok, that’s all good stuff to know, but I want to DO something!” So, I found an article in the MSDN library on viewing the contents of an assembly: How to: View Assembly Contents. This was actually very easy and helped me attach the material in this lesson to something concrete.

You use the MISL disassembler to view the assembly. If you haven’t used it before, you’ll be happy to hear that it’s easy to run. Just go to “Visual Studio Tools” on your start menu and select “Visual Studio 2005 Command Prompt”. In the DOS window that opens, type “ILDASM” which will launch the MISL disassembler in it’s own window. The MSDN “How to” article explains the rest. I recommend that you do this exercise, but don’t get sidetracked by trying to decipher everything in the manifest. It’s enough just to get the general idea of what’s in there. 

8/9/07 Update: I won’t be posting about any more lessons in this series. Read: MCSD is Outdated. Become an MCPD Instead to see why.

8/16/07 Update: If you would like to study for the MCTS or MCPD, then start here: Join me in studying for MCTS exam 70-536.

A summary of this lesson (my reading notes.)

  1. The .NET framework has two elements:
    • The Common Language Runtime (CLR). The CLR manages code execution. It compiles MSIL (Microsoft Intermediate Language), allocates memory, manages threads, and does garbage collection.
    • The .NET Framework class library. The class library provides reusable types that are Common Language Specification (CLS) compliant and thus can be called from any .NET language.
  2. Assemblies are the basic unit of a .NET application. They are a collection of code, resources, and metadata. The assembly has the following parts:
    • Assembly manifest. Each assembly has one manifest which provides:
      • Identity information, such as the assembly’s name and version number.
      • A list of all types exposed by the assembly.
      • A list of other assemblies required by the assembly
      • A list of code assess security instructions, including permissions required by the assembly and permissions to be denied the assembly.
    • Modules. Each assembly contains one or more modules which contain:
      • Code (MSIL). This is all, or part of, the code that makes up the application.
      • Metadata that describes the code
      • Type (class) metadata
  3. Compilation and execution of a .NET application:
    • Applications written in a high level .NET language like VB or C# are compiled to MSIL for deployment in one or more assemblies. At least one assembly will have a .NET executable file (stored as MISL code) designated as the entry point of the application.
    • At the beginning of execution the first assembly is loaded into memory, then the CLR:
      1. Determines the requirements for running the program from the assembly’s manifest.
      2. Compares security permissions requested by the assembly with the system’s security policy.
      3. If the security permissions are appropriate, it creates a process for the application to run in.
      4. Runs the Just In Time (JIT) compiler to compile the first block of MSIL into native binary code and stores the code for use until the program exits.
      5. Initiates execution of the native code.
      6. Compiles and stores more blocks of MISL as needed while the application executes.

Additional resources on this topic

From the MSDN Library: Overview of the .NET Framework, How to: View Assembly Contents

Tutorials from Bean Software: .NET Framework Assemblies- Part 1, .NET Framework Assemblies- Part 2

From the CodeProject: A .NET Assembly Viewer

Advertisements

Entry filed under: .NET, MCSD, Visual Basic.

Join me in preparing for Microsoft VB.NET certification MCSD is outdated. Become an MCPD instead!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Bird’s Bits

Computers, software & the Internet

Recent Posts

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 37 other followers


%d bloggers like this: