All applications written with Visual C# are written using the .NET Framework. The .NET Framework provides the class libraries that simplify programming in Visual C#, and it also provides the runtime support you need to execute and manage your code.
The .NET Framework
A framework is commonly thought of as a set of class libraries that aid in the development of applications. The .NET Framework is more than just a set of classes. The .NET Framework is targeted by compilers using a wide variety of programming languages.
The .NET Framework is responsible for providing a basic platform that applications can share. This basic platform includes a runtime set of services that oversee the execution of applications. A key responsibility of the runtime is to manage execution so that software written by different programming languages uses classes and other types safely.
The Common Language Runtime
The common language runtime is responsible for managing and executing code written for the .NET Framework. Code that’s compiled with the Visual C# .NET compiler always runs with the help of the runtime and is known as managed code. The runtime is responsible for overseeing all aspects of code execution
Type Safety and the Runtime
The runtime ensures type safety for applications and components. For example, a traditional view of type safety is that a variable that refers to a string shouldn’t occasionally hold an integer value. This sort of type safety is enforced by the Visual C# .NET compiler. Type safety is an important part of the .NET security architecture, and the runtime uses type safety to keep applications working robustly.
Assemblies
Applications built for Windows typically have dependencies on one or more dynamic-link libraries (DLLs). Often these DLLs are components that are shared with other applications, and sometimes these DLLs contain Component Object Model (COM) classes that are registered in the system registry. Unfortunately, when these components are updated or improperly installed, existing applications can be broken—a situation commonly known as “DLL hell”. The .NET Framework seeks to avoid DLL hell through the use of assemblies—self-describing modules that replace the notion of DLLs and executable files (EXEs).
The Visual C# .NET compiler doesn’t generate machine code that can be directly executed on your computer. Instead, your project’s source code is compiled into an assembly.
An assembly has two parts: intermediate language (IL) and metadata.
Intermediate language (IL) contains the executable portion of the program. IL is similar to the output from the first pass of a compiler. Metadata describes the assembly contents. The .NET Framework uses metadata to eliminate the need for component registration. Tools such as Visual C# .NET use metadata to simplify development; tools can simply inspect the assembly’s metadata and determine the types and operations that are exported by the assembly.
Loading External Assemblies
When the common language runtime loads your application, it examines your program’s metadata to determine which external assemblies are required for execution. There are two types of assemblies.
· Private assemblies - Used by a single application
· Shared assemblies - Intended for use by multiple applications.
Using the Global Assembly Cache
Assemblies that are employed by multiple projects can be placed in the global assembly cache, which serves as both a storage location and a registry for shared .NET components. The global assembly cache offers much more flexibility than the registration used by COM, enabling multiple versions and cultures (previously known as locales) of an assembly to be stored.
Conclusion
The .NET Framework includes a large number of classes and other types that are used to develop your application, but the .NET Framework is more than just a class library. It also includes the common language runtime, which manages and supports code written for the .NET platform.
Visual C# is a new object-oriented language in the C family of languages, and it’s easily understood by existing C and C++ programmers. In addition, its clean syntax and simple programming model (much simpler than C++) make it an easy language to learn, even if you’re not currently using C or C++.