tokenpocket官网app下载安卓|clr

作者: tokenpocket官网app下载安卓
2024-03-13 02:19:41

Home - CLR - CLR at De La Salle-College of Saint Benilde

- CLR - CLR at De La Salle-College of Saint Benilde

Skip to Main Content

Toggle navigation menu

Resources

Library Catalog

e-Resources

Print Materials

Non-Print Materials

Archival Materials

Audio-Visual Resources

Open Access Resources

Services

Ask LaRCy

Borrowing & Returning

Online Renewal & Reservation

LaRCy Guides

Library Instruction

Interlibrary Loan

Referrals

Visiting Researchers

Suggest-a-Purchase

Printing

Audio-Visual

Photo & Video Documentation

Laptop Lending

Reserve a Learning Space

Spaces

Computer Workstations

Discussion Rooms

Faculty/Graduate Areas

Learning Commons

Student Lounge

Study Carrels

Viewing Area

About CLR

Vision-Mission

Through the Years

By the Numbers

Organizational Chart

Directory

Branches

CLR Antipolo

Hours

Events

CLR News

Policies

Giving to the Library

My Account

Enter Search WordsSearch

CLR: Home

HomeResourcesToggle DropdownThe CLR Collection ServicesToggle DropdownOur Services LaRCy Guides This link opens in a new windowReserve a Learning Space This link opens in a new windowSpacesToggle DropdownOur Spaces About CLRToggle DropdownAbout Us CLR Antipolo This link opens in a new windowHours This link opens in a new windowCLR News This link opens in a new windowCalendar of Events This link opens in a new window This link opens in a new window

EverythingBooksArticlesJournalsSearch CLR and beyondBrought to you by WorldCat DiscoveryAdvanced Search

A-Z Databases List LaRCy Guides Video Tutorials

Br. Fidelis Leddy Center for Learning Resources (CLR) News

READ MORE CLR NEWS 

TODAY'S CLR HOURS

View Weekly Hours 

  R&R transactions via curbside pickup or courier delivery are being accommodated in all CLR branches (Monday-Saturday).

 CLR online services are available (Monday-Saturday, 8 AM - 5 PM).

   Chat with LaRCy

   Email us

    Call 8230-5100 local 1484 (Taft), 2482 (AKIC), or 3482 (DAC) during CLR hours

   Schedule an Appointment with LaRCy

  Request a Learning Session with LaRCy

   Browse our FAQs

     Reserve a Seat or Space

   Follow us on Social Media

Next: Resources >>

Resources

Library Catalog

e-Resources

Print Materials

Non-Print Materials

Archival Materials

Audio-Visual Resources

Open Access Resources

Services

Ask LaRCy

Borrowing & Returning

Online Renewal & Reservation

LaRCy Guides

Library Instruction

Interlibrary Loan

Referrals

Visiting Researchers

Suggest-a-Purchase

Printing

Audio-Visual

Photo & Video Documentation

Laptop Lending

Reserve a Learning Space

Spaces

Computer Workstations

Discussion Rooms

Faculty/Graduate Areas

Learning Commons

Student Lounge

Study Carrels

Viewing Area

About CLR

Vision-Mission

Through the Years

By the Numbers

Organizational Chart

Directory

Branches

CLR Antipolo

Hours

Events

CLR News

Policies

Giving to the Library

Your Gateway toExtraordinary

CLR DIRECTORY

DATAPRIVACY

De La Salle-College of Saint Benilde ©.All rights reserved.

Common Language Runtime (CLR) overview - .NET | Microsoft Learn

Common Language Runtime (CLR) overview - .NET | Microsoft Learn

Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge

More info about Internet Explorer and Microsoft Edge

Table of contents

Exit focus mode

Read in English

Save

Table of contents

Read in English

Save

Edit

Print

Twitter

LinkedIn

Facebook

Email

Table of contents

Common Language Runtime (CLR) overview

Article

04/25/2023

18 contributors

Feedback

In this article

.NET provides a run-time environment called the common language runtime that runs the code and provides services that make the development process easier.

Compilers and tools expose the common language runtime's functionality and enable you to write code that benefits from the managed execution environment. Code that you develop with a language compiler that targets the runtime is called managed code. Managed code benefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.

Note

Compilers and tools can produce output that the common language runtime can consume because the type system, the format of metadata, and the run-time environment (the virtual execution system) are all defined by a public standard, the ECMA Common Language Infrastructure specification. For more information, see ECMA C# and Common Language Infrastructure Specifications.

To enable the runtime to provide services to managed code, language compilers must emit metadata that describes the types, members, and references in your code. Metadata is stored with the code; every loadable common language runtime portable executable (PE) file contains metadata. The runtime uses metadata to locate and load classes, lay out instances in memory, resolve method invocations, generate native code, enforce security, and set run-time context boundaries.

The runtime automatically handles object layout and manages references to objects, releasing them when they're no longer being used. Objects whose lifetimes are managed in this way are called managed data. Garbage collection eliminates memory leaks and some other common programming errors. If your code is managed, you can use managed, unmanaged, or both managed and unmanaged data in your .NET application. Because language compilers supply their own types, such as primitive types, you might not always know or need to know whether your data is being managed.

The common language runtime makes it easy to design components and applications whose objects interact across languages. Objects written in different languages can communicate with each other, and their behaviors can be tightly integrated. For example, you can define a class and then use a different language to derive a class from your original class or call a method on the original class. You can also pass an instance of a class to a method of a class written in a different language. This cross-language integration is possible because language compilers and tools that target the runtime use a common type system defined by the runtime. They follow the runtime's rules for defining new types and for creating, using, persisting, and binding to types.

As part of their metadata, all managed components carry information about the components and resources they were built against. The runtime uses this information to ensure that your component or application has the specified versions of everything it needs, which makes your code less likely to break because of some unmet dependency. Registration information and state data are no longer stored in the registry, where they can be difficult to establish and maintain. Instead, information about the types you define and their dependencies is stored with the code as metadata. This way, the task of component replication and removal is less complicated.

Language compilers and tools expose the runtime's functionality in ways that are intended to be useful and intuitive to developers. Some features of the runtime might be more noticeable in one environment than in another. How you experience the runtime depends on which language compilers or tools you use. For example, if you're a Visual Basic developer, you might notice that with the common language runtime, the Visual Basic language has more object-oriented features than before. The runtime provides the following benefits:

Performance improvements.

The ability to easily use components developed in other languages.

Extensible types provided by a class library.

Language features such as inheritance, interfaces, and overloading for object-oriented programming.

Support for explicit free threading that allows creation of multithreaded and scalable applications.

Support for structured exception handling.

Support for custom attributes.

Garbage collection.

Use of delegates instead of function pointers for increased type safety and security. For more information about delegates, see Common Type System.

CLR versions

.NET Core and .NET 5+ releases have a single product version, that is, there's no separate CLR version. For a list of .NET Core versions, see Download .NET Core.

However, the .NET Framework version number doesn't necessarily correspond to the version number of the CLR it includes. For a list of .NET Framework versions and their corresponding CLR versions, see .NET Framework versions and dependencies.

Related articles

Title

Description

Managed Execution Process

Describes the steps required to take advantage of the common language runtime.

Automatic Memory Management

Describes how the garbage collector allocates and releases memory.

Overview of .NET Framework

Describes key .NET Framework concepts, such as the common type system, cross-language interoperability, managed execution, application domains, and assemblies.

Common Type System

Describes how types are declared, used, and managed in the runtime in support of cross-language integration.

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.

.NET

Open a documentation issue

Provide product feedback

Feedback

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.

Submit and view feedback for

This product

This page

View all page feedback

Additional resources

California Consumer Privacy Act (CCPA) Opt-Out Icon

Your Privacy Choices

Theme

Light

Dark

High contrast

Previous Versions

Blog

Contribute

Privacy

Terms of Use

Trademarks

© Microsoft 2024

Additional resources

In this article

California Consumer Privacy Act (CCPA) Opt-Out Icon

Your Privacy Choices

Theme

Light

Dark

High contrast

Previous Versions

Blog

Contribute

Privacy

Terms of Use

Trademarks

© Microsoft 2024

Common Language Runtime (CLR) in C# - GeeksforGeeks

Common Language Runtime (CLR) in C# - GeeksforGeeks

Skip to content

TutorialsPython TutorialTaking Input in PythonPython OperatorsPython Data TypesPython NumbersPython StringPython ListsPython TuplesSets in PythonPython DictionaryPython Loops and Control FlowPython If ElsePython For LoopsPython While LoopsPython BreaksPython Continue StatementPython Pass StatementPython FunctionsPython OOPS ConceptPython Data StructuresPython DSALinked ListStackQueueTreeHeapHashingGraphSetsMapAdvance Data StructureSorting AlgorithmsSearching AlgorithmsPython Exception HandlingPython File HandlingPython ExercisesPython List ExercisePython String ExercisePython Tuple ExercisePython Dictionary ExercisePython Set ExercisePython Design PatternsPython Programming ExamplesPython Practice QuestionsJavaJava Programming LanguageJava TutorialData TypesVariablesOperatorsOperators in JavaArithmetic OperatorsUnary OperatorsAssignment OperatorsRelational OperatorsLogical OperatorsTernary OperatorsFlow Control in JavaFlow Controlif Statementif-else Statementif-else-if LadderContinue StatementBreak StatementReturn StatementLoops in JavaLoopsdo-while LoopFor LoopFor-each LoopMethodsStringsArraysOOPs ConceptsOOPs ConceptsClasses and ObjectsAccess ModifiersInheritanceAbstractionEncapsulationPolymorphismInterfacePackagesMultithreadingFile HandlingRegular ExpressionJava CollectionsJava CollectionsCollection ClassList InterfaceArrayListVector ClassStack ClassLinkedList ClassQueue InterfaceSet InterfaceHashSet ClassTreeSetMap InterfaceHashMap ClassHashTable ClassIteratorComparatorCollection Interview QuestionsJava 8 TutorialJava ProgramsJava Programming ExamplesJava Array ProgramsJava String ProgramsJava Date-Time ProgramsJava File Handling ProgramsJava Collection ProgramsJava JDBC ProgramsJava Apache POI ProgramsJava OpenCV ProgramsJava Interview QuestionsJava Interview QuestionsCore Java Interview Questions-FreshersJava Multithreading Interview QuestionsOOPs Interview Questions and AnswersJava ExercisesJava QuizJava QuizCore Java MCQJava ProjectsAdvance JavaSpring TutorialSpring Boot TutorialSpring Boot Interview QuestionsSpring MVC TutorialSpring MVC Interview QuestionsHibernate TutorialHibernate Interview QuestionsProgramming LanguagesCC++JavaScriptPHPR TutorialC#SQLScalaPerlGo LanguageKotlinSystem DesignSystem Design TutorialWhat is System DesignKey Terminologies in System DesignAnalysis and Architecture of SystemsScalability in System DesignDatabases in System DesignHigh Level Design or HLDLow Level Design or LLDCommunication ProtocolsWeb Servers and ProxiesCase Studies in Designing SystemsComplete System Design TutorialSoftware Design PatternsFactory PatternObserver PatternSingleton Design PatternDecorator PatternStrategy PatternAdapter PatternCommand PatternIterator PatternPrototype Design PatternAll Design PatternsSystem Design RoadmapTop 10 System Design Interview Questions and AnswersInterview CornerCompany PreparationTop TopicsPractice Company QuestionsInterview ExperiencesExperienced InterviewsInternship InterviewsCompetitive ProgrammingMultiple Choice QuizzesAptitude for PlacementsComputer Science SubjectsMathematicsOperating SystemDBMSComputer NetworksComputer Organization and ArchitectureTheory of ComputationCompiler DesignDigital LogicSoftware EngineeringDevOpsGITAWSDockerKubernetesMicrosoft Azure TutorialGoogle Cloud PlatformLinuxLinux TutorialLinux Commands A-ZLinux Commands Cheatsheet25 Basic Linux CommandsFile Mangement in LinuxFile Permission Commandschmod Commandchown Commandchgrp Commandunmask CommandLinux System AdministrationLinux File SystemLinux Shell ScriptingLinux NetworkingLinux FirewallLinux Interview QuestionsSoftware TestingSoftware Testing TutorialSoftware Testing TutorialWhat is Software TestingPrinciples of Software TestingTypes of Software TestingLevels of Software TestingAutomation TestingManual TestingTesting ToolsSoftware Testing ToolsDefect Testing ToolsCross-Browser Testing ToolsIntegration Testing ToolUnit Testing ToolsMobile Testing ToolsGUI Testing ToolSecurity Testing ToolsPenetration Testing ToolsSeleniumSelenium TutorialSelenium BasicsSelenium PythonJiraJira TutorialJIRA InstallationJIRA LoginJIRA DashboardSoftware EngineeringSoftware Engineering TutorialSoftware Development Life Cycle (SDLC)Software CharacteristicsSoftware QualityWaterfall ModelIterative Waterfall ModelSpiral ModelPrototyping ModelIncremental Process ModelInterview QuestionsSoftware Testing Interview QuestionsAutomation Testing Interview QuestionsManual Testing Interview QuestionsSoftware Engineering Interview QuestionsPenetration Testing Interview QuestionsAPI Testing Interview QuestionsPostmanPostman TutorialPostman for API DevelopmentDownload and Install PostmanAPI Testing Using PostmanGenerate HTML Report for PostmanDatabasesDBMS TutorialSQL TutorialPostgreSQL TutorialMongoDB TutorialSQL Interview QuestionsMySQL Interview QuestionsPL/SQL Interview QuestionsAndroidAndroid TutorialAndroid Studio TutorialKotlin For AndroidAndroid ProjectsAndroid Interview Questions6 Weeks of Android App DevelopmentExcelMS Excel TutorialIntroduction to MS ExcelData Analysis in ExcelBasic Excel Formulas & FunctionsData Analysis in Advanced ExcelWorkbooksStatistical FunctionsData Visualization in ExcelPivot Tables in ExcelExcel Spreadsheets in PythonBasic Excel ShortcutsMathematicsNumber SystemAlgebraLinear AlgebraTrigonometrySet TheoryStatisticsProbabilityGeometryMensurationLogarithmsCalculusCommerceBusiness StudiesAccountancyMicroeconomicsStatistics for EconomicsMacroeconomicsHuman Resource Management (HRM)ManagementIncome TaxFinanceCommerce Complete GuideSEO-Search Engine OptimizationWhat is SEOSearch Engine Optimization BasicsTypes of SEOKeyword Optimization in SEOBacklinks in SEOSEO BlogsMobile SEOSEO Complete ReferenceAptitudeAptitude Question and AnswersQuantitative AptitudeLogical ReasoningVerbal AbilityDSAData StructuresArraysMatrixStringsLinked ListSingly Linked ListDoubly Linked ListCircular Linked ListDoubly Circular Linked ListLinked List TutorialStackQueueTreeGeneric TreeBinary TreeBinary Search TreeAVL TreeB TreeB+ TreeRed Black TreeTree Data Structure TutorialHeapHashingGraphSet Data StructureMap Data StructureAdvanced Data StructureData Structures TutorialAlgorithmsAnalysis of AlgorithmsDesign and Analysis of AlgorithmsAsymptotic AnalysisAsymptotic NotationsWorst, Average and Best CasesSearching AlgorithmsLinear SearchBinary SearchSearching Algorithms TutorialSorting AlgorithmsSelection SortBubble SortInsertion SortMerge SortQuick SortHeap SortCounting SortRadix SortBucket SortSorting Algorithms TutorialGreedy AlgorithmsDynamic ProgrammingGraph AlgorithmsPattern SearchingRecursionBacktrackingDivide and ConquerMathematical AlgorithmsGeometric AlgorithmsBitwise AlgorithmsRandomized AlgorithmsBranch and BoundAlgorithms TutorialDSA TutorialPracticeAll DSA ProblemsProblem of the DayCompany Wise Coding PracticeAmazonMicrosoftFlipkartExplore AllGfG SDE SheetPractice Problems Difficulty WiseSchoolBasicEasyMediumHardLanguage Wise Coding PracticeCPPJavaPythonCurated DSA ListsBeginner's DSA SheetTop 50 Array ProblemsTop 50 String ProblemsTop 50 DP ProblemsTop 50 Graph ProblemsTop 50 Tree ProblemsCompetitive ProgrammingCompany Wise SDE SheetsFacebook SDE SheetAmazon SDE SheetApple SDE SheetNetflix SDE SheetGoogle SDE SheetDSA Cheat SheetsSDE SheetDSA Sheet for BeginnersFAANG Coding SheetProduct-Based Coding SheetCompany-Wise Preparation SheetTop Interview QuestionsTop 100 DSA Interview Questions Topic-wisePuzzlesAll PuzzlesTop 100 Puzzles Asked In InterviewsTop 20 Puzzles Commonly Asked During SDE InterviewsData SciencePython TutorialR TutorialMachine LearningData Science using PythonData Science using RData Science PackagesPandas TutorialNumPy TutorialData VisualizationPython Data Visualization TutorialData Visualization with RData AnalysisData Analysis with PythonData Analysis with RDeep LearningNLP TutorialWeb TechHTML TutorialCSS TutorialJavaScript TutorialPHP TutorialReactJS TutorialNodeJS TutorialAngularJS TutorialBootstrap TutorialWeb Development Using PythonDjangoGetting started with DjangoCreate an App in DjangoViews In DjangoDjango TemplatesDjango URL patternsDjango Admin InterfaceDjango ModelsMySQL Databased with DjangoDjango CRUDDjango FormsDjango Static FileProjects for BeginnersDjango TutorialFlaskWeb Development Using FlaskFlask App RoutingURL building in FlaskFlask TemplatesTemplating With Jinja2 in FlaskFlask ModelDatabase with Flask SQL AlchemyAuthentication with FlaskWTForms in FlaskStatic files in FlaskPython Flask ProjectsFlask Interview QuestionsFrontend ProjectsBuilding a Survey Form using HTML and CSSFood delivery system using HTML and CSSToDo webapp using DjangoBuilding Blog CMSAdd Pagination in DjangoTailwind CSS with DjangoDjango with ReactjsPostmanGithubJSON TutorialTypeScript TutorialWordpress TutorialWeb DesignWeb BrowsersGoogle ChromeMozilla FirefoxApple SafariMicrosoft EdgeTorCheat SheetsHTML Cheat SheetCSS Cheat SheetJavaScript Cheat SheetReact Cheat SheetAngular Cheat SheetjQuery Cheat SheetBootstrap Cheat SheetJavaScript ProjectsLearn Complete Web DevelopmentFile FormatsCoursesCoding for EveryoneDSA to DevelopmentMachine Learning and Data ScienceDSA CoursesData Structure & Algorithm(C++/JAVA)Data Structure & Algorithm(Python)Data Structure & Algorithm(JavaScript)Programming LanguagesCPPJavaPythonJavaScriptC

Home

Saved Videos

Courses

Data Structures and Algorithms

DSA Tutorial

Data Structures Tutorial

Algorithms Tutorial

Top 100 DSA Interview Questions

DSA-Roadmap[Basic-to-Advanced]

ML & Data Science

Learn Python

Data Science Tutorial

Machine Learning Tutorial

Deep Learning Tutorial

NLP Tutorial

Computer Vision Tutorial

Web Development

HTML Tutorial

CSS Tutorial

JavaScript Tutorial

ReactJS Tutorial

NodeJS Tutorial

Languages

C

C++

Java

R Tutorial

Golang

Interview Corner

Company Interview Corner

Experienced Interviews

Internship Experiences

Practice Company Questions

Competitive Programming

CS Subjects

Operating Systems

DBMS

Computer Networks

Software Engineering

Software Testing

Jobs

Get Hired: Apply for Jobs

Job-a-thon: Hiring Challenge

Corporate Hiring Solutions

Practice

All DSA Problems

Problem of the Day

GFG SDE Sheet

Beginner's DSA Sheet

Love Babbar Sheet

Top 50 Array Problems

Top 50 String Problems

Top 50 DP Problems

Top 50 Graph Problems

Top 50 Tree Problems

Contests

World Cup Hack-A-Thon

GFG Weekly Coding Contest

Job-A-Thon: Hiring Challenge

BiWizard School Contest

All Contests and Events

GBlog

Puzzles

What's New ?

Change Language

.NET FrameworkC# Data TypesC# KeywordsC# Decision MakingC# MethodsC# DelegatesC# ConstructorsC# ArraysC# ArrayListC# StringC# TupleC# IndexersC# InterfaceC# MultithreadingC# Exception

Open In App

Solve Coding ProblemsIntroductionC# TutorialIntroduction to .NET FrameworkC# | .NET Framework (Basic Architecture and Component Stack)Hello World in C#Common Language Runtime (CLR) in C#FundamentalsC# | IdentifiersC# | Data TypesC# | VariablesC# | LiteralsC# | OperatorsC# | KeywordsControl StatementsC# Decision Making (if, if-else, if-else-if ladder, nested if, switch, nested switch)Switch Statement in C#Loops in C#C# | Jump Statements (Break, Continue, Goto, Return and Throw)OOP ConceptsC# | Class and ObjectC# | ConstructorsC# | InheritanceC# | EncapsulationC# | AbstractionMethodsC# | MethodsC# | Method OverloadingC# | Method ParametersC# | Method OverridingAnonymous Method in C#ArraysC# | ArraysC# | Jagged ArraysC# | Array ClassHow to sort an Array in C# | Array.Sort() Method Set - 1How to find the rank of an array in C#ArrayListArrayList in C#C# | ArrayList ClassC# | Array vs ArrayListStringC# | StringC# | Verbatim String Literal - @C# | String classStringBuilder in C#C# | String vs StringBuilderTupleC# | TupleC# | Tuple ClassValueTuple in C#ValueTuple Struct in C#IndexersC# | IndexersC# | Multidimensional IndexersC# | Overloading of IndexersPropertiesC# | PropertiesC# | Restrictions on PropertiesCollections & GenericsCollections in C#C# | Collection ClassC# | Generics - IntroductionList Implementation in C#C# SortedList with ExamplesHashSet in C# with ExamplesSortedSet in C# with ExamplesC# Dictionary with examplesSortedDictionary Implementation in C#C# Hashtable with ExamplesC# Stack with ExamplesC# Queue with ExamplesLinked List Implementation in C#

Solve Coding ProblemsIntroductionC# TutorialIntroduction to .NET FrameworkC# | .NET Framework (Basic Architecture and Component Stack)Hello World in C#Common Language Runtime (CLR) in C#FundamentalsC# | IdentifiersC# | Data TypesC# | VariablesC# | LiteralsC# | OperatorsC# | KeywordsControl StatementsC# Decision Making (if, if-else, if-else-if ladder, nested if, switch, nested switch)Switch Statement in C#Loops in C#C# | Jump Statements (Break, Continue, Goto, Return and Throw)OOP ConceptsC# | Class and ObjectC# | ConstructorsC# | InheritanceC# | EncapsulationC# | AbstractionMethodsC# | MethodsC# | Method OverloadingC# | Method ParametersC# | Method OverridingAnonymous Method in C#ArraysC# | ArraysC# | Jagged ArraysC# | Array ClassHow to sort an Array in C# | Array.Sort() Method Set - 1How to find the rank of an array in C#ArrayListArrayList in C#C# | ArrayList ClassC# | Array vs ArrayListStringC# | StringC# | Verbatim String Literal - @C# | String classStringBuilder in C#C# | String vs StringBuilderTupleC# | TupleC# | Tuple ClassValueTuple in C#ValueTuple Struct in C#IndexersC# | IndexersC# | Multidimensional IndexersC# | Overloading of IndexersPropertiesC# | PropertiesC# | Restrictions on PropertiesCollections & GenericsCollections in C#C# | Collection ClassC# | Generics - IntroductionList Implementation in C#C# SortedList with ExamplesHashSet in C# with ExamplesSortedSet in C# with ExamplesC# Dictionary with examplesSortedDictionary Implementation in C#C# Hashtable with ExamplesC# Stack with ExamplesC# Queue with ExamplesLinked List Implementation in C#

Common Language Runtime (CLR) in C#

Improve

Improve

Improve

Like Article

Like

Save Article

Save

Share

Report issue

Report

The Common Language Runtime (CLR) is a component of the Microsoft .NET Framework that manages the execution of .NET applications. It is responsible for loading and executing the code written in various .NET programming languages, including C#, VB.NET, F#, and others.

When a C# program is compiled, the resulting executable code is in an intermediate language called Common Intermediate Language (CIL) or Microsoft Intermediate Language (MSIL). This code is not machine-specific, and it can run on any platform that has the CLR installed. When the CIL code is executed, the CLR compiles it into machine code that can be executed by the processor.

The CLR provides many services to .NET applications, including memory management, type safety, security, and exception handling. It also provides Just-In-Time (JIT) compilation, which compiles the CIL code into machine code on the fly as the program runs, optimizing performance.

Additionally, the CLR provides a framework for developing and deploying .NET applications, including a set of libraries, called the .NET Framework Class Library, which provides access to a wide range of functionality, such as input/output operations, networking, database connectivity, and user interface design.

Overall, the CLR is a critical component of the .NET Framework and is responsible for ensuring that .NET applications are executed in a safe, secure, and efficient manner, making it a fundamental aspect of C# programming.

CLR is the basic and Virtual Machine component of the .NET Framework. It is the run-time environment in the .NET Framework that runs the codes and helps in making the development process easier by providing the various services. Basically, it is responsible for managing the execution of .NET programs regardless of any .NET programming language. Internally, CLR implements the VES(Virtual Execution System) which is defined in the Microsoft’s implementation of the CLI(Common Language Infrastructure). The code that runs under the Common Language Runtime is termed as the Managed Code. In other words, you can say that CLR provides a managed execution environment for the .NET programs by improving the security, including the cross language integration and a rich set of class libraries, etc. CLR is present in every .NET framework version. Below table illustrate the CLR version in .NET framework. 

CLR Versions.NET Framework Versions1.01.01.11.12.02.02.03.02.03.54444.5(also 4.5.1 & 4.5.2)44.6(also 4.6.1 & 4.6.2)44.7(also 4.7.1 & 4.7.2)

Below diagram illustrate how CLR is associated with the operating system/hardware along with the class libraries. Here, the runtime is actually CLR. 

Role of CLR in the execution of a C# programSuppose you have written a C# program and save it in a file which is known as the Source Code.Language specific compiler compiles the source code into the MSIL(Microsoft Intermediate Language) which is also known as the CIL(Common Intermediate Language) or IL(Intermediate Language) along with its metadata. Metadata includes all the types, actual implementation of each function of the program. MSIL is machine-independent code.Now CLR comes into existence. CLR provides the services and runtime environment to the MSIL code. Internally CLR includes the JIT(Just-In-Time) compiler which converts the MSIL code to machine code which further executed by CPU. CLR also uses the .NET Framework class libraries. Metadata provides information about the programming language, environment, version, and class libraries to the CLR by which CLR handles the MSIL code. As CLR is common so it allows an instance of a class that written in a different language to call a method of the class which written in another language.

Main Components of CLR

As the word specify, Common means CLR provides a common runtime or execution environment as there are more than 60 .NET programming languages. Main components of CLR: Common Language Specification (CLS): It is responsible for converting the different .NET programming language syntactical rules and regulations into CLR understandable format. Basically, it provides Language Interoperability. Language Interoperability means providing execution support to other programming languages also in .NET framework. Language Interoperability can be achieved in two ways : 

Managed Code: The MSIL code which is managed by the CLR is known as the Managed Code. For managed code CLR provides three .NET facilities: Unmanaged Code: Before .NET development, programming languages like.COM Components & Win32 API do not generate the MSIL code. So these are not managed by CLR rather managed by Operating System.

Common Type System (CTS): Every programming language has its own data type system, so CTS is responsible for understanding all the data type systems of .NET programming languages and converting them into CLR understandable format which will be a common format. There are 2 Types of CTS that every .NET programming language have : 

Value Types: Value Types will store the value directly into the memory location. These types work with stack mechanisms only. CLR allows memory for these at Compile Time.Reference Types: Reference Types will contain a memory address of value because the reference types won’t store the variable value directly in memory. These types work with Heap mechanism. CLR allot memory for these at Runtime.

Garbage Collector: It is used to provide the Automatic Memory Management feature. If there was no garbage collector, programmers would have to write the memory management codes which will be a kind of overhead on programmers. JIT(Just In Time Compiler): It is responsible for converting the CIL(Common Intermediate Language) into machine code or native code using the Common Language Runtime environment. Benefits of CLR: 

It improves the performance by providing a rich interact between programs at run time.Enhance portability by removing the need of recompiling a program on any operating system that supports it.Security also increases as it analyzes the MSIL instructions whether they are safe or unsafe. Also, the use of delegates in place of function pointers enhance the type safety and security.Support automatic memory management with the help of Garbage Collector.Provides cross-language integration because CTS inside CLR provides a common standard that activates the different languages to extend and share each other’s libraries.Provides support to use the components that developed in other .NET programming languages.Provide language, platform, and architecture independence.It allows easy creation of scalable and multithreaded applications, as the developer has no need to think about memory management and security issues. 

Last Updated :

24 Mar, 2023

Like Article

Save Article

Previous

Hello World in C#

Next

C# | Identifiers

Share your thoughts in the comments

Add Your Comment

Please Login to comment...

Similar Reads

Architecture of Common Language Runtime (CLR)

C# Program to Check Whether the CLR is Shutting Down or Not Using Environment Class

CIL or MSIL | Microsoft Intermediate Language or Common Intermediate Language

LINQ (Language Integrated Query)

C# | Check if SortedSet and a specified collection share common elements

C# | Check if a HashSet and a specified collection share common elements

Ruby Programming Language

Perl Programming Language

R Programming Language Free Course

Like

A

Anshul_Aggarwal

Follow

Article Tags :

C#

Additional Information

Current difficulty :

Medium

Vote for difficulty :

Easy

Normal

Medium

Hard

Expert

Improved By :

Tarandeep Singh 4talistern21rajeev0719singhabhishek0719kadiyanpratik88

Trending in News

View More

Google Maps testing a new feature that shows entrance to buildingsChatGPT Gets a Voice: Introducing the New Read Aloud FeatureMeta Quest+ is Now Like Game Pass For Your VR HeadsetMLB World Series Champions - Major League Baseball Winners List 30 OOPs Interview Questions and Answers (2024)

Explore More

A-143, 9th Floor, Sovereign Corporate Tower, Sector-136, Noida, Uttar Pradesh - 201305

CompanyAbout UsLegalCareersIn MediaContact UsAdvertise with usGFG Corporate SolutionPlacement Training ProgramExploreHack-A-ThonsGfG Weekly ContestDSA in JAVA/C++Master System DesignMaster CPGeeksforGeeks VideosGeeks CommunityLanguagesPythonJavaC++PHPGoLangSQLR LanguageAndroid TutorialTutorials ArchiveDSAData StructuresAlgorithmsDSA for BeginnersBasic DSA ProblemsDSA RoadmapTop 100 DSA Interview ProblemsDSA Roadmap by Sandeep JainAll Cheat SheetsData Science & MLData Science With PythonData Science For BeginnerMachine Learning TutorialML MathsData Visualisation TutorialPandas TutorialNumPy TutorialNLP TutorialDeep Learning TutorialHTML & CSSHTMLCSSWeb TemplatesCSS FrameworksBootstrapTailwind CSSSASSLESSWeb DesignDjango TutorialPythonPython Programming ExamplesPython ProjectsPython TkinterWeb ScrapingOpenCV Python TutorialPython Interview QuestionComputer ScienceOperating SystemsComputer NetworkDatabase Management SystemSoftware EngineeringDigital Logic DesignEngineering MathsDevOpsGitAWSDockerKubernetesAzureGCPDevOps RoadmapCompetitive ProgrammingTop DS or Algo for CPTop 50 TreeTop 50 GraphTop 50 ArrayTop 50 StringTop 50 DPTop 15 Websites for CPSystem DesignHigh Level DesignLow Level DesignUML DiagramsInterview GuideDesign PatternsOOADSystem Design BootcampInterview QuestionsJavaScriptJavaScript ExamplesTypeScriptReactJSNextJSAngularJSNodeJSLodashWeb BrowserPreparation CornerCompany-Wise Recruitment ProcessResume TemplatesAptitude PreparationPuzzlesCompany-Wise PreparationSchool SubjectsMathematicsPhysicsChemistryBiologySocial ScienceEnglish GrammarWorld GKManagement & FinanceManagementHR ManagementFinanceIncome TaxOrganisational BehaviourMarketingFree Online ToolsTyping TestImage EditorCode FormattersCode ConvertersCurrency ConverterRandom Number GeneratorRandom Password GeneratorMore TutorialsSoftware DevelopmentSoftware TestingProduct ManagementSAPSEO - Search Engine OptimizationLinuxExcelGeeksforGeeks VideosDSAPythonJavaC++Data ScienceCS Subjects

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

We use cookies to ensure you have the best browsing experience on our website. By using our site, you

acknowledge that you have read and understood our

Cookie Policy &

Privacy Policy

Got It !

Improvement

Please go through our recently updated Improvement Guidelines before submitting any improvements.

This article is being improved by another user right now. You can suggest the changes for now and it will be under the article's discussion tab.

You will be notified via email once the article is available for improvement.

Thank you for your valuable feedback!

Suggest changes

Please go through our recently updated Improvement Guidelines before submitting any improvements.

Suggest Changes

Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.

Create Improvement

Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.

Suggest Changes

Suggestion[CharLimit:2000]

Create Improvement

What kind of Experience do you want to share?

Interview Experiences

Admission Experiences

Engineering Exam Experiences

Work Experiences

Campus Experiences

Add Other Experiences

Common Language Runtime (CLR) Overview - SQL Server | Microsoft Learn

Common Language Runtime (CLR) Overview - SQL Server | Microsoft Learn

Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge

More info about Internet Explorer and Microsoft Edge

Table of contents

Exit focus mode

Read in English

Save

Table of contents

Read in English

Save

Edit

Print

Twitter

LinkedIn

Facebook

Email

Table of contents

Common Language Runtime Integration

Article

03/03/2023

12 contributors

Feedback

In this article

Applies to:

SQL Server

Azure SQL Managed Instance

Microsoft SQL Server and Azure SQL Managed Instance enable you to implement some of the functionalities with .NET languages using the native common language runtime (CLR) integration as SQL Server server-side modules (procedures, functions, and triggers). The CLR supplies managed code with services such as cross-language integration, code access security, object lifetime management, and debugging and profiling support. For SQL Server users and application developers, CLR integration means that you can now write stored procedures, triggers, user-defined types, user-defined functions (scalar and table valued), and user-defined aggregate functions using any .NET Framework language, including Microsoft Visual Basic .NET and Microsoft Visual C#. SQL Server includes the .NET Framework version 4 pre-installed.

Warning

CLR uses Code Access Security (CAS) in the .NET Framework, which is no longer supported as a security boundary. A CLR assembly created with PERMISSION_SET = SAFE may be able to access external system resources, call unmanaged code, and acquire sysadmin privileges. Beginning with SQL Server 2017 (14.x), an sp_configure option called clr strict security is introduced to enhance the security of CLR assemblies. clr strict security is enabled by default, and treats SAFE and EXTERNAL_ACCESS assemblies as if they were marked UNSAFE. The clr strict security option can be disabled for backward compatibility, but this is not recommended. Microsoft recommends that all assemblies be signed by a certificate or asymmetric key with a corresponding login that has been granted UNSAFE ASSEMBLY permission in the master database. For more information, see CLR strict security. SQL Server administrators can also add assemblies to a list of assemblies, which the Database Engine should trust. For more information, see sys.sp_add_trusted_assembly.

This 6-minute video shows you how to use CLR in Azure SQL Managed Instance:

When to use CLR modules

CLR Integration enables you to implement complex features that are available in .NET Framework such as regular expressions, code for accessing external resources (servers, web services, databases), custom encryption, etc. Some of the benefits of the server-side CLR integration are:

A better programming model. The .NET Framework languages are in many respects richer than Transact-SQL, offering constructs and capabilities previously not available to SQL Server developers. Developers may also leverage the power of the .NET Framework Library, which provides an extensive set of classes that can be used to quickly and efficiently solve programming problems.

Improved safety and security. Managed code runs in a common language run-time environment, hosted by the Database Engine. SQL Server leverages this to provide a safer and more secure alternative to the extended stored procedures available in earlier versions of SQL Server.

Ability to define data types and aggregate functions. User-defined types and user-defined aggregates are two new managed database objects that expand the storage and querying capabilities of SQL Server.

Streamlined development through a standardized environment. Database development is integrated into future releases of the Microsoft Visual Studio .NET development environment. Developers use the same tools for developing and debugging database objects and scripts as they use to write middle-tier or client-tier .NET Framework components and services.

Potential for improved performance and scalability. In many situations, the .NET Framework language compilation and execution models deliver improved performance over Transact-SQL.

SQL Server language extensions provide an alternative execution environment for runtimes close to the database engine. For a discussion of the differences between SQL CLR and SQL language extensions, see Compare SQL Server Language Extensions to SQL CLR.

The following table lists the topics in this section.

Overview of CLR Integration

Describes the kinds of objects that can be built using CLR integration. Also reviews the requirements for building database objects using CLR integration.

What's New in CLR Integration

Describes the new features in this release.

Architecture of CLR Integration

Describes the design goals of CLR integration.

Enabling CLR Integration

Describes how to enable CLR integration.

See Also

Installing the .NET Framework (SQL Server only)

Performance of CLR Integration

Feedback

Was this page helpful?

Yes

No

Provide product feedback

|

Get help at Microsoft Q&A

Feedback

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.

Submit and view feedback for

This product

This page

View all page feedback

Additional resources

California Consumer Privacy Act (CCPA) Opt-Out Icon

Your Privacy Choices

Theme

Light

Dark

High contrast

Previous Versions

Blog

Contribute

Privacy

Terms of Use

Trademarks

© Microsoft 2024

Additional resources

In this article

California Consumer Privacy Act (CCPA) Opt-Out Icon

Your Privacy Choices

Theme

Light

Dark

High contrast

Previous Versions

Blog

Contribute

Privacy

Terms of Use

Trademarks

© Microsoft 2024

yload":{"allShortcutsEnabled":false,"fileTree":{"docs/design/coreclr/botr":{"items":[{"name":"images","path":"docs/design/coreclr/botr/images","contentType":"directory"},{"name":"README.md","path":"docs/design/coreclr/botr/README.md","contentType":"file"},{"name":"botr-faq.md","path":"docs/design/coreclr/botr/botr-faq.md","contentType":"file"},{"name":"clr-abi.md","path":"docs/design/coreclr/botr/clr-abi.md","contentType":"file"},{"name":"corelib.md","path":"docs/design/coreclr/botr/corelib.md","contentType":"file"},{"name":"dac-notes.md","path":"docs/design/coreclr/botr/dac-notes.md","contentType":"file"},{"name":"exceptions.md","path":"docs/design/coreclr/botr/exceptions.md","contentType":"file"},{"name":"garbage-collection.md","path":"docs/design/coreclr/botr/garbage-collection.md","contentType":"file"},{"name":"guide-for-porting.md","path":"docs/design/coreclr/botr/guide-for-porting.md","contentType":"file"},{"name":"ilc-architecture.md","path":"docs/design/coreclr/botr/ilc-architecture.md","contentType":"file"},{"name":"intro-to-clr.md","path":"docs/design/coreclr/botr/intro-to-clr.md","contentType":"file"},{"name":"managed-type-system.md","path":"docs/design/coreclr/botr/managed-type-system.md","contentType":"file"},{"name":"method-descriptor.md","path":"docs/design/coreclr/botr/method-descriptor.md","contentType":"file"},{"name":"mixed-mode.md","path":"docs/design/coreclr/botr/mixed-mode.md","contentType":"file"},{"name":"profilability.md","path":"docs/design/coreclr/botr/profilability.md","contentType":"file"},{"name":"profiling.md","path":"docs/design/coreclr/botr/profiling.md","contentType":"file"},{"name":"r2r-perfmap-format.md","path":"docs/design/coreclr/botr/r2r-perfmap-format.md","contentType":"file"},{"name":"readytorun-format.md","path":"docs/design/coreclr/botr/readytorun-format.md","contentType":"file"},{"name":"readytorun-overview.md","path":"docs/design/coreclr/botr/readytorun-overview.md","contentType":"file"},{"name":"shared-generics.md","path":"docs/design/coreclr/botr/shared-generics.md","contentType":"file"},{"name":"stackwalking.md","path":"docs/design/coreclr/botr/stackwalking.md","contentType":"file"},{"name":"threading.md","path":"docs/design/coreclr/botr/threading.md","contentType":"file"},{"name":"type-loader.md","path":"docs/design/coreclr/botr/type-loader.md","contentType":"file"},{"name":"type-system.md","path":"docs/design/coreclr/botr/type-system.md","contentType":"file"},{"name":"vectors-and-intrinsics.md","path":"docs/design/coreclr/botr/vectors-and-intrinsics.md","contentType":"file"},{"name":"virtual-stub-dispatch.md","path":"docs/design/coreclr/botr/virtual-stub-dispatch.md","contentType":"file"},{"name":"xplat-minidump-generation.md","path":"docs/design/coreclr/botr/xplat-minidump-generation.md","contentType":"file"}],"totalCount":27},"docs/design/coreclr":{"items":[{"name":"botr","path":"docs/design/coreclr/botr","contentType":"directory"},{"name":"jit","path":"docs/design/coreclr/jit","contentType":"directory"},{"name":"profiling","path":"docs/design/coreclr/profiling","contentType":"directory"}],"totalCount":3},"docs/design":{"items":[{"name":"coreclr","path":"docs/design/coreclr","contentType":"directory"},{"name":"features","path":"docs/design/features","contentType":"directory"},{"name":"libraries","path":"docs/design/libraries","contentType":"directory"},{"name":"mono","path":"docs/design/mono","contentType":"directory"},{"name":"security","path":"docs/design/security","contentType":"directory"},{"name":"specs","path":"docs/design/specs","contentType":"directory"},{"name":"tools","path":"docs/design/tools","contentType":"directory"}],"totalCount":7},"docs":{"items":[{"name":"coding-guidelines","path":"docs/coding-guidelines","contentType":"directory"},{"name":"design","path":"docs/design","contentType":"directory"},{"name":"infra","path":"docs/infra","contentType":"directory"},{"name":"issue-mappings","path":"docs/issue-mappings","contentType":"directory"},{"name":"project","path":"docs/project","contentType":"directory"},{"name":"tools","path":"docs/tools","contentType":"directory"},{"name":"workflow","path":"docs/workflow","contentType":"directory"},{"name":"README.md","path":"docs/README.md","contentType":"file"},{"name":"area-owners.md","path":"docs/area-owners.md","contentType":"file"},{"name":"deep-dive-blog-posts.md","path":"docs/deep-dive-blog-posts.md","contentType":"file"},{"name":"issue-cleanup.md","path":"docs/issue-cleanup.md","contentType":"file"},{"name":"issues-pr-management.md","path":"docs/issues-pr-management.md","contentType":"file"}],"totalCount":12},"":{"items":[{"name":".config","path":".config","contentType":"directory"},{"name":".devcontainer","path":".devcontainer","contentType":"directory"},{"name":".github","path":".github","contentType":"directory"},{"name":"docs","path":"docs","contentType":"directory"},{"name":"eng","path":"eng","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":".CodeQL.yml","path":".CodeQL.yml","contentType":"file"},{"name":".clang-format","path":".clang-format","contentType":"file"},{"name":".clang-tidy","path":".clang-tidy","contentType":"file"},{"name":".dockerignore","path":".dockerignore","contentType":"file"},{"name":".editorconfig","path":".editorconfig","contentType":"file"},{"name":".gitattributes","path":".gitattributes","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".markdownlint.json","path":".markdownlint.json","contentType":"file"},{"name":".vsconfig","path":".vsconfig","contentType":"file"},{"name":"Build.proj","path":"Build.proj","contentType":"file"},{"name":"CODE-OF-CONDUCT.md","path":"CODE-OF-CONDUCT.md","contentType":"file"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","contentType":"file"},{"name":"Directory.Build.props","path":"Directory.Build.props","contentType":"file"},{"name":"Directory.Build.rsp","path":"Directory.Build.rsp","contentType":"file"},{"name":"Directory.Build.targets","path":"Directory.Build.targets","contentType":"file"},{"name":"Directory.Solution.props","path":"Directory.Solution.props","contentType":"file"},{"name":"LICENSE.TXT","path":"LICENSE.TXT","contentType":"file"},{"name":"NuGet.config","path":"NuGet.config","contentType":"file"},{"name":"PATENTS.TXT","path":"PATENTS.TXT","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"SECURITY.md","path":"SECURITY.md","contentType":"file"},{"name":"THIRD-PARTY-NOTICES.TXT","path":"THIRD-PARTY-NOTICES.TXT","contentType":"file"},{"name":"build.cmd","path":"build.cmd","contentType":"file"},{"name":"build.sh","path":"build.sh","contentType":"file"},{"name":"dotnet.cmd","path":"dotnet.cmd","contentType":"file"},{"name":"dotnet.sh","path":"dotnet.sh","contentType":"file"},{"name":"global.json","path":"global.json","contentType":"file"}],"totalCount":33}},"fileTreeProcessingTime":18.797048,"foldersToFetch":[],"repo":{"id":210716005,"defaultBranch":"main","name":"runtime","ownerLogin":"dotnet","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2019-09-24T23:36:39.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/9141961?v=4","public":true,"private":false,"isOrgOwned":true},"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"main","listCacheKey":"v0:1710264296.0","canEdit":false,"refType":"branch","currentOid":"be0e14cdd60d6e11e4ee13d96d748bfc0efffbc1"},"path":"docs/design/coreclr/botr/intro-to-clr.md","currentUser":null,"blob":{"rawLines":null,"stylingDirectives":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/dotnet/runtime/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"intro-to-clr.md","displayUrl":"https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/intro-to-clr.md?raw=true","headerInfo":{"blobSize":"45.3 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"7626ff4","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fdotnet%2Fruntime%2Fblob%2Fmain%2Fdocs%2Fdesign%2Fcoreclr%2Fbotr%2Fintro-to-clr.md","isCSV":false,"isRichtext":true,"toc":[{"level":1,"text":"Introduction to the Common Language Runtime (CLR)","anchor":"introduction-to-the-common-language-runtime-clr","htmlText":"Introduction to the Common Language Runtime (CLR)"},{"level":1,"text":"The CLR: A (very rare) Complete Programming Platform","anchor":"the-clr-a-very-rare-complete-programming-platform","htmlText":"The CLR: A (very rare) Complete Programming Platform"},{"level":2,"text":"Multi-language Support","anchor":"multi-language-support","htmlText":"Multi-language Support"},{"level":1,"text":"The Primary Goal of the CLR","anchor":"the-primary-goal-of-the-clr","htmlText":"The Primary Goal of the CLR"},{"level":1,"text":"Fundamental Features of the CLR","anchor":"fundamental-features-of-the-clr","htmlText":"Fundamental Features of the CLR"},{"level":2,"text":"The CLR Garbage Collector (GC)","anchor":"the-clr-garbage-collector-gc","htmlText":"The CLR Garbage Collector (GC)"},{"level":2,"text":"The Concept of \"Managed Code\"","anchor":"the-concept-of-managed-code","htmlText":"The Concept of \"Managed Code\""},{"level":3,"text":"The stack unwinding problem","anchor":"the-stack-unwinding-problem","htmlText":"The stack unwinding problem"},{"level":3,"text":"The \"World\" of Managed Code","anchor":"the-world-of-managed-code","htmlText":"The \"World\" of Managed Code"},{"level":2,"text":"Memory and Type Safety","anchor":"memory-and-type-safety","htmlText":"Memory and Type Safety"},{"level":3,"text":"Verifiable Code - Enforcing Memory and Type Safety","anchor":"verifiable-code---enforcing-memory-and-type-safety","htmlText":"Verifiable Code - Enforcing Memory and Type Safety"},{"level":2,"text":"High Level Features","anchor":"high-level-features","htmlText":"High Level Features"},{"level":3,"text":"Object Oriented Programming","anchor":"object-oriented-programming","htmlText":"Object Oriented Programming"},{"level":3,"text":"Value Types (and Boxing)","anchor":"value-types-and-boxing","htmlText":"Value Types (and Boxing)"},{"level":3,"text":"Exceptions","anchor":"exceptions","htmlText":"Exceptions"},{"level":3,"text":"Parameterized Types (Generics)","anchor":"parameterized-types-generics","htmlText":"Parameterized Types (Generics)"},{"level":3,"text":"Programs as Data (Reflection APIs)","anchor":"programs-as-data-reflection-apis","htmlText":"Programs as Data (Reflection APIs)"},{"level":1,"text":"Other Features","anchor":"other-features","htmlText":"Other Features"},{"level":2,"text":"Interoperation with Unmanaged Code","anchor":"interoperation-with-unmanaged-code","htmlText":"Interoperation with Unmanaged Code"},{"level":2,"text":"Ahead of time Compilation","anchor":"ahead-of-time-compilation","htmlText":"Ahead of time Compilation"},{"level":2,"text":"Threading","anchor":"threading","htmlText":"Threading"},{"level":1,"text":"Summary and Resources","anchor":"summary-and-resources","htmlText":"Summary and Resources"},{"level":2,"text":"Useful Links","anchor":"useful-links","htmlText":"Useful Links"}],"lineInfo":{"truncatedLoc":"259","truncatedSloc":"151"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"Markdown","languageID":222,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/dotnet/runtime/blob/main/docs/design/coreclr/botr/intro-to-clr.md","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/dotnet/runtime/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/dotnet/runtime/raw/main/docs/design/coreclr/botr/intro-to-clr.md","renderImageOrRaw":false,"richText":"Introduction to the Common Language Runtime (CLR)\nBy Vance Morrison (@vancem) - 2007\nWhat is the Common Language Runtime (CLR)? To put it succinctly:\n\nThe Common Language Runtime (CLR) is a complete, high level virtual machine designed to support a broad variety of programming languages and interoperation among them.\n\nPhew, that was a mouthful. It also in and of itself is not very illuminating. The statement above is useful however, because it is the first step in taking the large and complicated piece of software known as the CLR and grouping its features in an understandable way. It gives us a \"10,000 foot\" view of the runtime from which we can understand the broad goals and purpose of the runtime. After understanding the CLR at this high level, it is easier to look more deeply into sub-components without as much chance of getting lost in the details.\nThe CLR: A (very rare) Complete Programming Platform\nEvery program has a surprising number of dependencies on its runtime environment. Most obviously, the program is written in a particular programming language, but that is only the first of many assumptions a programmer weaves into the program. All interesting programs need some runtime library that allows them to interact with the other resources of the machine (such as user input, disk files, network communications, etc). The program also needs to be converted in some way (either by interpretation or compilation) to a form that the native hardware can execute directly. These dependencies of a program are so numerous, interdependent and diverse that implementers of programming languages almost always defer to other standards to specify them. For example, the C++ language does not specify the format of a C++ executable. Instead, each C++ compiler is bound to a particular hardware architecture (e.g., X86) and to an operating system environment (e.g., Windows, Linux, or Mac OS), which describes the format of the executable file format and specifies how it will be loaded. Thus, programmers don't make a \"C++ executable,\" but rather a \"Windows X86 executable\" or a \"Power PC Mac OS executable.\"\nWhile leveraging existing hardware and operating system standards is usually a good thing, it has the disadvantage of tying the specification to the level of abstraction of the existing standards. For example, no common operating system today has the concept of a garbage-collected heap. Thus, there is no way to use existing standards to describe an interface that takes advantage of garbage collection (e.g., passing strings back and forth, without worrying about who is responsible for deleting them). Similarly, a typical executable file format provides just enough information to run a program but not enough information for a compiler to bind other binaries to the executable. For example, C++ programs typically use a standard library (on Windows, called msvcrt.dll) which contains most of the common functionality (e.g., printf), but the existence of that library alone is not enough. Without the matching header files that go along with it (e.g., stdio.h), programmers can't use the library. Thus, existing executable file format standards cannot be used both to describe a file format that can be run and to specify other information or binaries necessary to make the program complete.\nThe CLR fixes problems like these by defining a very complete specification (standardized by ECMA) containing the details you need for the COMPLETE lifecycle of a program, from construction and binding through deployment and execution. Thus, among other things, the CLR specifies:\n\nA GC-aware virtual machine with its own instruction set (called the Common Intermediate Language (CIL)) used to specify the primitive operations that programs perform. This means the CLR is not dependent on a particular type of CPU.\nA rich meta data representation for program declarations (e.g., types, fields, methods, etc), so that compilers generating other executables have the information they need to call functionality from 'outside'.\nA file format that specifies exactly how to lay the bits down in a file, so that you can properly speak of a CLR EXE that is not tied to a particular operating system or computer hardware.\nThe lifetime semantics of a loaded program, the mechanism by which one CLR EXE file can refer to another CLR EXE and the rules on how the runtime finds the referenced files at execution time.\nA class library that leverages the features that the CLR provides (e.g., garbage collection, exceptions, or generic types) to give access both to basic functionality (e.g., integers, strings, arrays, lists, or dictionaries) as well as to operating system services (e.g., files, network, or user interaction).\n\nMulti-language Support\nDefining, specifying and implementing all of these details is a huge undertaking, which is why complete abstractions like the CLR are very rare. In fact, the vast majority of such reasonably complete abstractions were built for single languages. For example, the Java runtime, the Perl interpreter or the early version of the Visual Basic runtime offer similarly complete abstraction boundaries. What distinguishes the CLR from these earlier efforts is its multi-language nature. With the possible exception of Visual Basic (because it leverages the COM object model), the experience within the language is often very good, but interoperating with programs written in other languages is very difficult at best. Interoperation is difficult because these languages can only communicate with \"foreign\" languages by using the primitives provided by the operating system. Because the OS abstraction level is so low (e.g., the operating system has no concept of a garbage-collected heap), needlessly complicated techniques are necessary. By providing a COMMON LANGUAGE RUNTIME, the CLR allows languages to communicate with each other with high-level constructs (e.g., GC-collected structures), easing the interoperation burden dramatically.\nBecause the runtime is shared among many languages, it means that more resources can be put into supporting it well. Building good debuggers and profilers for a language is a lot of work, and thus they exist in a full-featured form only for the most important programming languages. Nevertheless, because languages that are implemented on the CLR can reuse this infrastructure, the burden on any particular language is reduced substantially. Perhaps even more important, any language built on the CLR immediately has access to all the class libraries built on top of the CLR. This large (and growing) body of (debugged and supported) functionality is a huge reason why the CLR has been so successful.\nIn short, the runtime is a complete specification of the exact bits one has to put in a file to create and run a program. The virtual machine that runs these files is at a high level appropriate for implementing a broad class of programming languages. This virtual machine, along with an ever growing body of class libraries that run on that virtual machine, is what we call the common language runtime (CLR).\nThe Primary Goal of the CLR\nNow that we have basic idea what the CLR is, it is useful to back up just a bit and understand the problem the runtime was meant to solve. At a very high level, the runtime has only one goal:\n\nThe goal of the CLR is to make programming easy.\n\nThis statement is useful for two reasons. First, it is a very useful guiding principle as the runtime evolves. For example, fundamentally only simple things can be easy, so adding user visible complexity to the runtime should always be viewed with suspicion. More important than the cost/benefit ratio of a feature is its added exposed complexity/weighted benefit over all scenarios ratio. Ideally, this ratio is negative (that is, the new feature reduces complexity by removing restrictions or by generalizing existing special cases); however, more typically it is kept low by minimizing the exposed complexity and maximizing the number of scenarios to which the feature adds value.\nThe second reason this goal is so important is that ease of use is the fundamental reason for the CLR's success. The CLR is not successful because it is faster or smaller than writing native code (in fact, well-written native code often wins). The CLR is not successful because of any particular feature it supports (like garbage collection, platform independence, object-oriented programming or versioning support). The CLR is successful because all of those features, as well as numerous others, combine to make programming significantly easier than it would be otherwise. Some important but often overlooked ease of use features include:\n\nSimplified languages (e.g., C# and Visual Basic are significantly simpler than C++)\nA dedication to simplicity in the class library (e.g., we only have one string type, and it is immutable; this greatly simplifies any API that uses strings)\nStrong consistency in the naming in the class library (e.g., requiring APIs to use whole words and consistent naming conventions)\nGreat support in the tool chain needed to create an application (e.g., Visual Studio makes building CLR applications very simple, and Intellisense makes finding the right types and methods to create the application very easy).\n\nIt is this dedication to ease of use (which goes hand in hand with simplicity of the user model) that stands out as the reason for the success of the CLR. Oddly, some of the most important ease-of-use features are also the most \"boring.\" For example, any programming environment could apply consistent naming conventions, yet actually doing so across a large class library is quite a lot of work. Often such efforts conflict with other goals (such as retaining compatibility with existing interfaces), or they run into significant logistical concerns (such as the cost of renaming a method across a very large code base). It is at times like these that we have to remind ourselves about our number-one overarching goal of the runtime and ensure that we have our priorities straight to reach that goal.\nFundamental Features of the CLR\nThe runtime has many features, so it is useful to categorize them as follows:\n\nFundamental features – Features that have broad impact on the design of other features. These include:\n\nGarbage Collection\nMemory Safety and Type Safety\nHigh level support for programming languages.\n\n\nSecondary features – Features enabled by the fundamental features that may not be required by many useful programs:\n\nProgram isolation with AppDomains\nProgram Security and sandboxing\n\n\nOther Features – Features that all runtime environments need but that do not leverage the fundamental features of the CLR. Instead, they are the result of the desire to create a complete programming environment. Among them are:\n\nVersioning\nDebugging/Profiling\nInteroperation\n\n\n\nThe CLR Garbage Collector (GC)\nOf all the features that the CLR provides, the garbage collector deserves special notice. Garbage collection (GC) is the common term for automatic memory reclamation. In a garbage-collected system, user programs no longer need to invoke a special operator to delete memory. Instead the runtime automatically keeps track of all references to memory in the garbage-collected heap, and from time-to-time, it will traverse these references to find out which memory is still reachable by the program. All other memory is garbage and can be reused for new allocations.\nGarbage collection is a wonderful user feature because it simplifies programming. The most obvious simplification is that most explicit delete operations are no longer necessary. While removing the delete operations is important, the real value to the programmer is a bit more subtle:\n\nGarbage collection simplifies interface design because you no longer have to carefully specify which side of the interface is responsible for deleting objects passed across the interface. For example, CLR interfaces simply return strings; they don't take string buffers and lengths. This means they don't have to deal with the complexity of what happens when the buffers are too small. Thus, garbage collection allows ALL interfaces in the runtime to be simpler than they otherwise would be.\nGarbage collection eliminates a whole class of common user mistakes. It is frightfully easy to make mistakes concerning the lifetime of a particular object, either deleting it too soon (leading to memory corruption), or too late (unreachable memory leaks). Since a typical program uses literally MILLIONS of objects, the probability for error is quite high. In addition, tracking down lifetime bugs is very difficult, especially if the object is referenced by many other objects. Making this class of mistakes impossible avoids a lot of grief.\n\nStill, it is not the usefulness of garbage collection that makes it worthy of special note here. More important is the simple requirement it places on the runtime itself:\n\nGarbage collection requires ALL references to the GC heap to be tracked.\n\nWhile this is a very simple requirement, it in fact has profound ramifications for the runtime. As you can imagine, knowing where every pointer to an object is at every moment of program execution can be quite difficult. We have one mitigating factor, though. Technically, this requirement only applies to when a GC actually needs to happen (thus, in theory we don't need to know where all GC references are all the time, but only at the time of a GC). In practice, however, this mitigation doesn't completely apply because of another feature of the CLR:\n\nThe CLR supports multiple concurrent threads of execution with a single process.\n\nAt any time some other thread of execution might perform an allocation that requires a garbage collection. The exact sequence of operations across concurrently executing threads is non-deterministic. We can't tell exactly what one thread will be doing when another thread requests an allocation that will trigger a GC. Thus, GCs can really happen any time. Now the CLR does NOT need to respond immediately to another thread's desire to do a GC, so the CLR has a little \"wiggle room\" and doesn't need to track GC references at all points of execution, but it does need to do so at enough places that it can guarantee \"timely\" response to the need to do a GC caused by an allocation on another thread.\nWhat this means is that the CLR needs to track all references to the GC heap almost all the time. Since GC references may reside in machine registers, in local variables, statics, or other fields, there is quite a bit to track. The most problematic of these locations are machine registers and local variables because they are so intimately related to the actual execution of user code. Effectively, what this means is that the machine code that manipulates GC references has another requirement: it must track all the GC references that it uses. This implies some extra work for the compiler to emit the instructions to track the references.\nTo learn more, check out the Garbage Collector design document.\nThe Concept of \"Managed Code\"\nCode that does the extra bookkeeping so that it can report all of its live GC references \"almost all the time\" is called managed code (because it is \"managed\" by the CLR). Code that does not do this is called unmanaged code. Thus all code that existed before the CLR is unmanaged code, and in particular, all operating system code is unmanaged.\nThe stack unwinding problem\nClearly, because managed code needs the services of the operating system, there will be times when managed code calls unmanaged code. Similarly, because the operating system originally started the managed code, there are also times when unmanaged code calls into managed code. Thus, in general, if you stop a managed program at an arbitrary location, the call stack will have a mixture of frames created by managed code and frames created by unmanaged code.\nThe stack frames for unmanaged code have no requirements on them over and above running the program. In particular, there is no requirement that they can be unwound at runtime to find their caller. What this means is that if you stop a program at an arbitrary place, and it happens to be in a unmanaged method, there is no way in general[1] to find who the caller was. You can only do this in the debugger because of extra information stored in the symbolic information (PDB file). This information is not guaranteed to be available (which is why you sometimes don't get good stack traces in a debugger). This is quite problematic for managed code, because any stack that can't be unwound might in fact contain managed code frames (which contain GC references that need to be reported).\nManaged code has additional requirements on it: not only must it track all the GC references it uses during its execution, but it must also be able to unwind to its caller. Additionally, whenever there is a transition from managed code to unmanaged code (or the reverse), managed code must also do additional bookkeeping to make up for the fact that unmanaged code does not know how to unwind its stack frames. Effectively, managed code links together the parts of the stack that contain managed frames. Thus, while it still may be impossible to unwind the unmanaged stack frames without additional information, it will always be possible to find the chunks of the stack that correspond to managed code and to enumerate the managed frames in those chunks.\n[1] More recent platform ABIs (application binary interfaces) define conventions for encoding this information, however there is typically not a strict requirement for all code to follow them.\nThe \"World\" of Managed Code\nThe result is that special bookkeeping is needed at every transition to and from managed code. Managed code effectively lives in its own \"world\" where execution can't enter or leave unless the CLR knows about it. The two worlds are in a very real sense distinct from one another (at any point in time the code is in the managed world or the unmanaged world). Moreover, because the execution of managed code is specified in a CLR format (with its Common Intermediate Language (CIL)), and it is the CLR that converts it to run on the native hardware, the CLR has much more control over exactly what that execution does. For example, the CLR could change the meaning of what it means to fetch a field from an object or call a function. In fact, the CLR does exactly this to support the ability to create MarshalByReference objects. These appear to be ordinary local objects, but in fact may exist on another machine. In short, the managed world of the CLR has a large number of execution hooks that it can use to support powerful features which will be explained in more detail in the coming sections.\nIn addition, there is another important ramification of managed code that may not be so obvious. In the unmanaged world, GC pointers are not allowed (since they can't be tracked), and there is a bookkeeping cost associated with transitioning from managed to unmanaged code. What this means is that while you can call arbitrary unmanaged functions from managed code, it is often not pleasant to do so. Unmanaged methods don't use GC objects in their arguments and return types, which means that any \"objects\" or \"object handles\" that those unmanaged functions create and use need to be explicitly deallocated. This is quite unfortunate. Because these APIs can't take advantage of CLR functionality such as exceptions or inheritance, they tend to have a \"mismatched\" user experience compared to how the interfaces would have been designed in managed code.\nThe result of this is that unmanaged interfaces are almost always wrapped before being exposed to managed code developers. For example, when accessing files, you don't use the Win32 CreateFile functions provided by the operating system, but rather the managed System.IO.File class that wraps this functionality. It is in fact extremely rare that unmanaged functionality is exposed to users directly.\nWhile this wrapping may seem to be \"bad\" in some way (more code that does not seem to do much), it is in fact good because it actually adds quite a bit of value. Remember it was always possible to expose the unmanaged interfaces directly; we chose to wrap the functionality. Why? Because the overarching goal of the runtime is to make programming easy, and typically the unmanaged functions are not easy enough. Most often, unmanaged interfaces are not designed with ease of use in mind, but rather are tuned for completeness. Anyone looking at the arguments to CreateFile or CreateProcess would be hard pressed to characterize them as \"easy.\" Luckily, the functionality gets a \"facelift\" when it enters the managed world, and while this makeover is often very \"low tech\" (requiring nothing more complex than renaming, simplification, and organizing the functionality), it is also profoundly useful. One of the very important documents created for the CLR is the Framework Design Guidelines. This 800+ page document details best practices in making new managed class libraries.\nThus, we have now seen that managed code (which is intimately involved with the CLR) differs from unmanaged code in two important ways:\n\nHigh Tech: The code lives in a distinct world, where the CLR controls most aspects of program execution at a very fine level (potentially to individual instructions), and the CLR detects when execution enters and exits managed code. This enables a wide variety of useful features.\nLow Tech: The fact that there is a transition cost when going from managed to unmanaged code, as well as the fact that unmanaged code cannot use GC objects encourages the practice of wrapping most unmanaged code in a managed façade. This means interfaces can get a \"facelift\" to simplify them and to conform to a uniform set of naming and design guidelines that produce a level of consistency and discoverability that could have existed in the unmanaged world, but does not.\n\nBoth of these characteristics are very important to the success of managed code.\nMemory and Type Safety\nOne of the less obvious but quite far-reaching features that a garbage collector enables is that of memory safety. The invariant of memory safety is very simple: a program is memory safe if it accesses only memory that has been allocated (and not freed). This simply means that you don't have \"wild\" (dangling) pointers that are pointing at random locations (more precisely, at memory that was freed prematurely). Clearly, memory safety is a property we want all programs to have. Dangling pointers are always bugs, and tracking them down is often quite difficult.\n\nA GC is necessary to provide memory safety guarantees\n\nOne can quickly see how a garbage collector helps in ensuring memory safety because it removes the possibility that users will prematurely free memory (and thus access memory that was not properly allocated). What may not be so obvious is that if you want to guarantee memory safety (that is make it impossible for programmers to create memory-unsafe programs), practically speaking you can't avoid having a garbage collector. The reason for this is that non-trivial programs need heap style (dynamic) memory allocations, where the lifetime of the objects is essentially under arbitrary program control (unlike stack-allocated, or statically-allocated memory, which has a highly constrained allocation protocol). In such an unconstrained environment, the problem of determining whether a particular explicit delete statement is correct becomes impossible to predict by program analysis. Effectively, the only way you have to determine if a delete is correct is to check it at runtime. This is exactly what a GC does (checks to see if memory is still live). Thus, for any programs that need heap-style memory allocations, if you want to guarantee memory safety, you need a GC.\nWhile a GC is necessary to ensure memory safety, it is not sufficient. The GC will not prevent the program from indexing off the end of an array or accessing a field off the end of an object (possible if you compute the field's address using a base and offset computation). However, if we do prevent these cases, then we can indeed make it impossible for a programmer to create memory-unsafe programs.\nWhile the common intermediate language (CIL) does have operators that can fetch and set arbitrary memory (and thus violate memory safety), it also has the following memory-safe operators and the CLR strongly encourages their use in most programming:\n\nField-fetch operators (LDFLD, STFLD, LDFLDA) that fetch (read), set and take the address of a field by name.\nArray-fetch operators (LDELEM, STELEM, LDELEMA) that fetch, set and take the address of an array element by index. All arrays include a tag specifying their length. This facilitates an automatic bounds check before each access.\n\nBy using these operators instead of the lower-level (and unsafe) memory-fetch operators in user code, as well as avoiding other unsafe CIL operators (e.g., those that allow you to jump to arbitrary, and thus possibly bad locations) one could imagine building a system that is memory-safe but nothing more. The CLR does not do this, however. Instead the CLR enforces a stronger invariant: type safety.\nFor type safety, conceptually each memory allocation is associated with a type. All operators that act on memory locations are also conceptually tagged with the type for which they are valid. Type safety then requires that memory tagged with a particular type can only undergo operations allowed for that type. Not only does this ensure memory safety (no dangling pointers), it also allows additional guarantees for each individual type.\nOne of the most important of these type-specific guarantees is that the visibility attributes associated with a type (and in particular with fields) are enforced. Thus, if a field is declared to be private (accessible only by the methods of the type), then that privacy will indeed be respected by all other type-safe code. For example, a particular type might declare a count field that represents the count of items in a table. Assuming the fields for the count and the table are private, and assuming that the only code that updates them updates them together, there is now a strong guarantee (across all type-safe code) that the count and the number of items in the table are indeed in sync. When reasoning about programs, programmers use the concept of type safety all the time, whether they know it or not. The CLR elevates type-safety from being simply a programming language/compiler convention, to something that can be strictly enforced at run time.\nVerifiable Code - Enforcing Memory and Type Safety\nConceptually, to enforce type safety, every operation that the program performs has to be checked to ensure that it is operating on memory that was typed in a way that is compatible with the operation. While the system could do this all at runtime, it would be very slow. Instead, the CLR has the concept of CIL verification, where a static analysis is done on the CIL (before the code is run) to confirm that most operations are indeed type-safe. Only when this static analysis can't do a complete job are runtime checks necessary. In practice, the number of run-time checks needed is actually very small. They include the following operations:\n\nCasting a pointer to a base type to be a pointer to a derived type (the opposite direction can be checked statically)\nArray bounds checks (just as we saw for memory safety)\nAssigning an element in an array of pointers to a new (pointer) value. This particular check is only required because CLR arrays have liberal casting rules (more on that later...)\n\nNote that the need to do these checks places requirements on the runtime. In particular:\n\nAll memory in the GC heap must be tagged with its type (so the casting operator can be implemented). This type information must be available at runtime, and it must be rich enough to determine if casts are valid (e.g., the runtime needs to know the inheritance hierarchy). In fact, the first field in every object on the GC heap points to a runtime data structure that represents its type.\nAll arrays must also have their size (for bounds checking).\nArrays must have complete type information about their element type.\n\nLuckily, the most expensive requirement (tagging each heap item) was something that was already necessary to support garbage collection (the GC needs to know what fields in every object contain references that need to be scanned), so the additional cost to provide type safety is low.\nThus, by verifying the CIL of the code and by doing a few run-time checks, the CLR can ensure type safety (and memory safety). Nevertheless, this extra safety exacts a price in programming flexibility. While the CLR does have general memory fetch operators, these operators can only be used in very constrained ways for the code to be verifiable. In particular, all pointer arithmetic will fail verification today. Thus many classic C or C++ conventions cannot be used in verifiable code; you must use arrays instead. While this constrains programming a bit, it really is not bad (arrays are quite powerful), and the benefits (far fewer \"nasty\" bugs), are quite real.\nThe CLR strongly encourages the use of verifiable, type-safe code. Even so, there are times (mostly when dealing with unmanaged code) that unverifiable programming is needed. The CLR allows this, but the best practice here is to try to confine this unsafe code as much as possible. Typical programs have only a very small fraction of their code that needs to be unsafe, and the rest can be type-safe.\nHigh Level Features\nSupporting garbage collection had a profound effect on the runtime because it requires that all code must support extra bookkeeping. The desire for type-safety also had a profound effect, requiring that the description of the program (the CIL) be at a high level, where fields and methods have detailed type information. The desire for type safety also forces the CIL to support other high-level programming constructs that are type-safe. Expressing these constructs in a type-safe manner also requires runtime support. The two most important of these high-level features are used to support two essential elements of object oriented programming: inheritance and virtual call dispatch.\nObject Oriented Programming\nInheritance is relatively simple in a mechanical sense. The basic idea is that if the fields of type derived are a superset of the fields of type base, and derived lays out its fields so the fields of base come first, then any code that expects a pointer to an instance of base can be given a pointer to an instance of derived and the code will \"just work\". Thus, type derived is said to inherit from base, meaning that it can be used anywhere base can be used. Code becomes polymorphic because the same code can be used on many distinct types. Because the runtime needs to know what type coercions are possible, the runtime must formalize the way inheritance is specified so it can validate type safety.\nVirtual call dispatch generalizes inheritance polymorphism. It allows base types to declare methods that will be overridden by derived types. Code that uses variables of type base can expect that calls to virtual methods will be dispatched to the correct overridden method based on the actual type of the object at run time. While such run-time dispatch logic could have been implemented using primitive CIL instructions without direct support in the runtime, it would have suffered from two important disadvantages\n\nIt would not be type safe (mistakes in the dispatch table are catastrophic errors)\nEach object-oriented language would likely implement a slightly different way of implementing its virtual dispatch logic. As result, interoperability among languages would suffer (one language could not inherit from a base type implemented in another language).\n\nFor this reason, the CLR has direct support for basic object-oriented features. To the degree possible, the CLR tried to make its model of inheritance \"language neutral,\" in the sense that different languages might still share the same inheritance hierarchy. Unfortunately, that was not always possible. In particular, multiple inheritance can be implemented in many different ways. The CLR chose not to support multiple inheritance on types with fields, but does support multiple inheritance from special types (called interfaces) that are constrained not to have fields.\nIt is important to keep in mind that while the runtime supports these object-oriented concepts, it does not require their use. Languages without the concept of inheritance (e.g., functional languages) simply don't use these facilities.\nValue Types (and Boxing)\nA profound, yet subtle aspect of object oriented programming is the concept of object identity: the notion that objects (allocated by separate allocation calls) can be distinguished, even if all their field values are identical. Object identity is strongly related to the fact that objects are accessed by reference (pointer) rather than by value. If two variables hold the same object (their pointers address the same memory), then updates to one of the variables will affect the other variable.\nUnfortunately, the concept of object identity is not a good semantic match for all types. In particular, programmers don't generally think of integers as objects. If the number '1' was allocated at two different places, programmers generally want to consider those two items equal, and certainly don't want updates to one of those instances affecting the other. In fact, a broad class of programming languages called `functional languages' avoid object identity and reference semantics altogether.\nWhile it is possible to have a \"pure\" object oriented system, where everything (including integers) is an object (Smalltalk-80 does this), a certain amount of implementation \"gymnastics\" is necessary to undo this uniformity to get an efficient implementation. Other languages (Perl, Java, JavaScript) take a pragmatic view and treat some types (like integers) by value, and others by reference. The CLR also chose a mixed model, but unlike the others, allowed user-defined value types.\nThe key characteristics of value types are:\n\nEach local variable, field, or array element of a value type has a distinct copy of the data in the value.\nWhen one variable, field or array element is assigned to another, the value is copied.\nEquality is always defined only in terms of the data in the variable (not its location).\nEach value type also has a corresponding reference type which has only one implicit, unnamed field. This is called its boxed value. Boxed value types can participate in inheritance and have object identity (although using the object identity of a boxed value type is strongly discouraged).\n\nValue types very closely model the C (and C++) notion of a struct (or C++ class). Like C you can have pointers to value types, but the pointers are a type distinct from the type of the struct.\nExceptions\nAnother high-level programming construct that the CLR directly supports is exceptions. Exceptions are a language feature that allows programmers to throw an arbitrary object at the point that a failure occurs. When an object is thrown, the runtime searches the call stack for a method that declares that it can catch the exception. If such a catch declaration is found, execution continues from that point. The usefulness of exceptions is that they avoid the very common mistake of not checking if a called method fails. Given that exceptions help avoid programmer mistakes (thus making programming easier), it is not surprising that the CLR supports them.\nAs an aside, while exceptions avoid one common error (not checking for failure), they do not prevent another (restoring data structures to a consistent state in the event of a failure). This means that after an exception is caught, it is difficult in general to know if continuing execution will cause additional errors (caused by the first failure). This is an area where the CLR is likely to add value in the future. Even as currently implemented, however, exceptions are a great step forward (we just need to go further).\nParameterized Types (Generics)\nPrevious to version 2.0 of the CLR, the only parameterized types were arrays. All other containers (such as hash tables, lists, queues, etc.), all operated on a generic Object type. The inability to create List, or Dictionary certainly had a negative performance effect because value types needed to be boxed on entry to a collection, and explicit casting was needed on element fetch. Nevertheless, that is not the overriding reason for adding parameterized types to the CLR. The main reason is that parameterized types make programming easier.\nThe reason for this is subtle. The easiest way to see the effect is to imagine what a class library would look like if all types were replaced with a generic Object type. This effect is not unlike what happens in dynamically typed languages like JavaScript. In such a world, there are simply far more ways for a programmer to make incorrect (but type-safe) programs. Is the parameter for that method supposed to be a list? a string? an integer? any of the above? It is no longer obvious from looking at the method's signature. Worse, when a method returns an Object, what other methods can accept it as a parameter? Typical frameworks have hundreds of methods; if they all take parameters of type Object, it becomes very difficult to determine which Object instances are valid for the operations the method will perform. In short, strong typing helps a programmer express their intent more clearly, and allows tools (e.g., the compiler) to enforce their intent. This results in a big productivity boost.\nThese benefits do not disappear just because the type gets put into a List or a Dictionary, so clearly parameterized types have value. The only real question is whether parameterized types are best thought of as a language specific feature which is \"compiled out\" by the time CIL is generated, or whether this feature should have first class support in the runtime. Either implementation is certainly possible. The CLR team chose first class support because without it, parameterized types would be implemented different ways by different languages. This would imply that interoperability would be cumbersome at best. In addition, expressing programmer intent for parameterized types is most valuable at the interface of a class library. If the CLR did not officially support parameterized types, then class libraries could not use them, and an important usability feature would be lost.\nPrograms as Data (Reflection APIs)\nThe fundamentals of the CLR are garbage collection, type safety, and high-level language features. These basic characteristics forced the specification of the program (the CIL) to be fairly high level. Once this data existed at run time (something not true for C or C++ programs), it became obvious that it would also be valuable to expose this rich data to end programmers. This idea resulted in the creation of the System.Reflection interfaces (so-called because they allow the program to look at (reflect upon) itself). This interface allows you to explore almost all aspects of a program (what types it has, the inheritance relationship, and what methods and fields are present). In fact, so little information is lost that very good \"decompilers\" for managed code are possible (e.g., NET Reflector). While those concerned with intellectual property protection are aghast at this capability (which can be fixed by purposefully destroying information through an operation called obfuscating the program), the fact that it is possible is a testament to the richness of the information available at run time in managed code.\nIn addition to simply inspecting programs at run time, it is also possible to perform operations on them (e.g., invoke methods, set fields, etc.), and perhaps most powerfully, to generate code from scratch at run time (System.Reflection.Emit). In fact, the runtime libraries use this capability to create specialized code for matching strings (System.Text.RegularExpressions), and to generate code for \"serializing\" objects to store in a file or send across the network. Capabilities like this were simply infeasible before (you would have to write a compiler!) but thanks to the runtime, are well within reach of many more programming problems.\nWhile reflection capabilities are indeed powerful, that power should be used with care. Reflection is usually significantly slower than its statically compiled counterparts. More importantly, self-referential systems are inherently harder to understand. This means that powerful features such as Reflection or Reflection.Emit should only be used when the value is clear and substantial.\nOther Features\nThe last grouping of runtime features are those that are not related to the fundamental architecture of the CLR (GC, type safety, high-level specification), but nevertheless fill important needs of any complete runtime system.\nInteroperation with Unmanaged Code\nManaged code needs to be able to use functionality implemented in unmanaged code. There are two main \"flavors\" of interoperation. First is the ability simply to call unmanaged functions (this is called Platform Invoke or PINVOKE). Unmanaged code also has an object-oriented model of interoperation called COM (component object model) which has more structure than ad hoc method calls. Since both COM and the CLR have models for objects and other conventions (how errors are handled, lifetime of objects, etc.), the CLR can do a better job interoperating with COM code if it has special support.\nAhead of time Compilation\nIn the CLR model, managed code is distributed as CIL, not native code. Translation to native code occurs at run time. As an optimization, the native code that is generated from the CIL can be saved in a file using a tool called crossgen (similar to .NET Framework NGEN tool). This avoids large amounts of compilation time at run time and is very important because the class library is so large.\nThreading\nThe CLR fully anticipated the need to support multi-threaded programs in managed code. From the start, the CLR libraries contained the System.Threading.Thread class which is a 1-to-1 wrapper over the operating system notion of a thread of execution. However, because it is just a wrapper over the operating system thread, creating a System.Threading.Thread is relatively expensive (it takes milliseconds to start). While this is fine for many operations, one style of programming creates very small work items (taking only tens of milliseconds). This is very common in server code (e.g., each task is serving just one web page) or in code that tries to take advantage of multi-processors (e.g., a multi-core sort algorithm). To support this, the CLR has the notion of a ThreadPool which allows WorkItems to be queued. In this scheme, the CLR is responsible for creating the necessary threads to do the work. While the CLR does expose the ThreadPool directly as the System.Threading.Threadpool class, the preferred mechanism is to use the Task Parallel Library, which adds additional support for very common forms of concurrency control.\nFrom an implementation perspective, the important innovation of the ThreadPool is that it is responsible for ensuring that the optimal number of threads are used to dispatch the work. The CLR does this using a feedback system where it monitors the throughput rate and the number of threads and adjusts the number of threads to maximize the throughput. This is very nice because now programmers can think mostly in terms of \"exposing parallelism\" (that is, creating work items), rather than the more subtle question of determining the right amount of parallelism (which depends on the workload and the hardware on which the program is run).\nSummary and Resources\nPhew! The runtime does a lot! It has taken many pages just to describe some of the features of the runtime, without even starting to talk about internal details. The hope is, however, that this introduction will provide a useful framework for a deeper understanding of those internal details. The basic outline of this framework is:\n\nThe Runtime is a complete framework for supporting programming languages\nThe Runtime's goal is to make programming easy.\nThe Fundamental features of the runtime are:\n\nGarbage Collection\nMemory and Type Safety\nSupport for High-Level Language Features\n\n\n\nUseful Links\n\nMSDN Entry for the CLR\nWikipedia Entry for the CLR\nECMA Standard for the Common Language Infrastructure (CLI)\n.NET Framework Design Guidelines\nCoreCLR Repo Documentation\n\n","renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":4,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":false,"symbols":[{"name":"Introduction to the Common Language Runtime (CLR)","kind":"section_1","ident_start":0,"ident_end":49,"extent_start":0,"extent_end":54,"fully_qualified_name":"Introduction to the Common Language Runtime (CLR)","ident_utf16":{"start":{"line_number":0,"utf16_col":0},"end":{"line_number":0,"utf16_col":49}},"extent_utf16":{"start":{"line_number":0,"utf16_col":0},"end":{"line_number":2,"utf16_col":0}}},{"name":"The CLR: A (very rare) Complete Programming Platform","kind":"section_1","ident_start":919,"ident_end":971,"extent_start":917,"extent_end":7247,"fully_qualified_name":"The CLR: A (very rare) Complete Programming Platform","ident_utf16":{"start":{"line_number":11,"utf16_col":2},"end":{"line_number":11,"utf16_col":54}},"extent_utf16":{"start":{"line_number":11,"utf16_col":0},"end":{"line_number":34,"utf16_col":0}}},{"name":"Multi-language Support","kind":"section_2","ident_start":4834,"ident_end":4856,"extent_start":4834,"extent_end":4880,"fully_qualified_name":"Multi-language Support","ident_utf16":{"start":{"line_number":25,"utf16_col":0},"end":{"line_number":25,"utf16_col":22}},"extent_utf16":{"start":{"line_number":25,"utf16_col":0},"end":{"line_number":27,"utf16_col":0}}},{"name":"The Primary Goal of the CLR","kind":"section_1","ident_start":7249,"ident_end":7276,"extent_start":7247,"extent_end":10290,"fully_qualified_name":"The Primary Goal of the CLR","ident_utf16":{"start":{"line_number":34,"utf16_col":2},"end":{"line_number":34,"utf16_col":29}},"extent_utf16":{"start":{"line_number":34,"utf16_col":0},"end":{"line_number":51,"utf16_col":0}}},{"name":"Fundamental Features of the CLR","kind":"section_1","ident_start":10292,"ident_end":10323,"extent_start":10290,"extent_end":41948,"fully_qualified_name":"Fundamental Features of the CLR","ident_utf16":{"start":{"line_number":51,"utf16_col":2},"end":{"line_number":51,"utf16_col":33}},"extent_utf16":{"start":{"line_number":51,"utf16_col":0},"end":{"line_number":218,"utf16_col":0}}},{"name":"The CLR Garbage Collector (GC)","kind":"section_2","ident_start":11148,"ident_end":11178,"extent_start":11145,"extent_end":15436,"fully_qualified_name":"The CLR Garbage Collector (GC)","ident_utf16":{"start":{"line_number":67,"utf16_col":3},"end":{"line_number":67,"utf16_col":33}},"extent_utf16":{"start":{"line_number":67,"utf16_col":0},"end":{"line_number":90,"utf16_col":0}}},{"name":"The Concept of \"Managed Code\"","kind":"section_2","ident_start":15439,"ident_end":15468,"extent_start":15436,"extent_end":22614,"fully_qualified_name":"The Concept of \"Managed Code\"","ident_utf16":{"start":{"line_number":90,"utf16_col":3},"end":{"line_number":90,"utf16_col":32}},"extent_utf16":{"start":{"line_number":90,"utf16_col":0},"end":{"line_number":121,"utf16_col":0}}},{"name":"The stack unwinding problem","kind":"section_3","ident_start":15826,"ident_end":15853,"extent_start":15822,"extent_end":18078,"fully_qualified_name":"The stack unwinding problem","ident_utf16":{"start":{"line_number":94,"utf16_col":4},"end":{"line_number":94,"utf16_col":31}},"extent_utf16":{"start":{"line_number":94,"utf16_col":0},"end":{"line_number":104,"utf16_col":0}}},{"name":"The \"World\" of Managed Code","kind":"section_3","ident_start":18082,"ident_end":18109,"extent_start":18078,"extent_end":22614,"fully_qualified_name":"The \"World\" of Managed Code","ident_utf16":{"start":{"line_number":104,"utf16_col":4},"end":{"line_number":104,"utf16_col":31}},"extent_utf16":{"start":{"line_number":104,"utf16_col":0},"end":{"line_number":121,"utf16_col":0}}},{"name":"Memory and Type Safety","kind":"section_2","ident_start":22617,"ident_end":22639,"extent_start":22614,"extent_end":30396,"fully_qualified_name":"Memory and Type Safety","ident_utf16":{"start":{"line_number":121,"utf16_col":3},"end":{"line_number":121,"utf16_col":25}},"extent_utf16":{"start":{"line_number":121,"utf16_col":0},"end":{"line_number":162,"utf16_col":0}}},{"name":"Verifiable Code - Enforcing Memory and Type Safety","kind":"section_3","ident_start":27305,"ident_end":27355,"extent_start":27301,"extent_end":30396,"fully_qualified_name":"Verifiable Code - Enforcing Memory and Type Safety","ident_utf16":{"start":{"line_number":142,"utf16_col":4},"end":{"line_number":142,"utf16_col":54}},"extent_utf16":{"start":{"line_number":142,"utf16_col":0},"end":{"line_number":162,"utf16_col":0}}},{"name":"High Level Features","kind":"section_2","ident_start":30399,"ident_end":30418,"extent_start":30396,"extent_end":41948,"fully_qualified_name":"High Level Features","ident_utf16":{"start":{"line_number":162,"utf16_col":3},"end":{"line_number":162,"utf16_col":22}},"extent_utf16":{"start":{"line_number":162,"utf16_col":0},"end":{"line_number":218,"utf16_col":0}}},{"name":"Object Oriented Programming","kind":"section_3","ident_start":31139,"ident_end":31166,"extent_start":31135,"extent_end":33605,"fully_qualified_name":"Object Oriented Programming","ident_utf16":{"start":{"line_number":166,"utf16_col":4},"end":{"line_number":166,"utf16_col":31}},"extent_utf16":{"start":{"line_number":166,"utf16_col":0},"end":{"line_number":179,"utf16_col":0}}},{"name":"Value Types (and Boxing)","kind":"section_3","ident_start":33609,"ident_end":33633,"extent_start":33605,"extent_end":35954,"fully_qualified_name":"Value Types (and Boxing)","ident_utf16":{"start":{"line_number":179,"utf16_col":4},"end":{"line_number":179,"utf16_col":28}},"extent_utf16":{"start":{"line_number":179,"utf16_col":0},"end":{"line_number":196,"utf16_col":0}}},{"name":"Exceptions","kind":"section_3","ident_start":35958,"ident_end":35968,"extent_start":35954,"extent_end":37166,"fully_qualified_name":"Exceptions","ident_utf16":{"start":{"line_number":196,"utf16_col":4},"end":{"line_number":196,"utf16_col":14}},"extent_utf16":{"start":{"line_number":196,"utf16_col":0},"end":{"line_number":202,"utf16_col":0}}},{"name":"Parameterized Types (Generics)","kind":"section_3","ident_start":37170,"ident_end":37200,"extent_start":37166,"extent_end":39686,"fully_qualified_name":"Parameterized Types (Generics)","ident_utf16":{"start":{"line_number":202,"utf16_col":4},"end":{"line_number":202,"utf16_col":34}},"extent_utf16":{"start":{"line_number":202,"utf16_col":0},"end":{"line_number":210,"utf16_col":0}}},{"name":"Programs as Data (Reflection APIs)","kind":"section_3","ident_start":39690,"ident_end":39724,"extent_start":39686,"extent_end":41948,"fully_qualified_name":"Programs as Data (Reflection APIs)","ident_utf16":{"start":{"line_number":210,"utf16_col":4},"end":{"line_number":210,"utf16_col":38}},"extent_utf16":{"start":{"line_number":210,"utf16_col":0},"end":{"line_number":218,"utf16_col":0}}},{"name":"Other Features","kind":"section_1","ident_start":41950,"ident_end":41964,"extent_start":41948,"extent_end":45132,"fully_qualified_name":"Other Features","ident_utf16":{"start":{"line_number":218,"utf16_col":2},"end":{"line_number":218,"utf16_col":16}},"extent_utf16":{"start":{"line_number":218,"utf16_col":0},"end":{"line_number":236,"utf16_col":0}}},{"name":"Interoperation with Unmanaged Code","kind":"section_2","ident_start":42197,"ident_end":42231,"extent_start":42194,"extent_end":42833,"fully_qualified_name":"Interoperation with Unmanaged Code","ident_utf16":{"start":{"line_number":222,"utf16_col":3},"end":{"line_number":222,"utf16_col":37}},"extent_utf16":{"start":{"line_number":222,"utf16_col":0},"end":{"line_number":226,"utf16_col":0}}},{"name":"Ahead of time Compilation","kind":"section_2","ident_start":42836,"ident_end":42861,"extent_start":42833,"extent_end":43262,"fully_qualified_name":"Ahead of time Compilation","ident_utf16":{"start":{"line_number":226,"utf16_col":3},"end":{"line_number":226,"utf16_col":28}},"extent_utf16":{"start":{"line_number":226,"utf16_col":0},"end":{"line_number":230,"utf16_col":0}}},{"name":"Threading","kind":"section_2","ident_start":43265,"ident_end":43274,"extent_start":43262,"extent_end":45132,"fully_qualified_name":"Threading","ident_utf16":{"start":{"line_number":230,"utf16_col":3},"end":{"line_number":230,"utf16_col":12}},"extent_utf16":{"start":{"line_number":230,"utf16_col":0},"end":{"line_number":236,"utf16_col":0}}},{"name":"Summary and Resources","kind":"section_1","ident_start":45134,"ident_end":45155,"extent_start":45132,"extent_end":46410,"fully_qualified_name":"Summary and Resources","ident_utf16":{"start":{"line_number":236,"utf16_col":2},"end":{"line_number":236,"utf16_col":23}},"extent_utf16":{"start":{"line_number":236,"utf16_col":0},"end":{"line_number":259,"utf16_col":0}}},{"name":"Useful Links","kind":"section_2","ident_start":45767,"ident_end":45779,"extent_start":45764,"extent_end":46410,"fully_qualified_name":"Useful Links","ident_utf16":{"start":{"line_number":247,"utf16_col":3},"end":{"line_number":247,"utf16_col":15}},"extent_utf16":{"start":{"line_number":247,"utf16_col":0},"end":{"line_number":259,"utf16_col":0}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"csrf_tokens":{"/dotnet/runtime/branches":{"post":"4gbDVO4TBfi7F801Gct8FL41u5BDtDyesx8aOV-YAJUGQoNNIDqgcy7TNwf0ikjxn1mruP0l_TMx16MjxfgyEg"},"/repos/preferences":{"post":"UGNEWgEsXdx8ogGWeL5yLKnQCwRLqSC1pa5Dt9N8QWe0jZj_l89gkISD0rzLFJXfJnd_hB7oQdjFcbqAlEAIyA"}}},"title":"runtime/docs/design/coreclr/botr/intro-to-clr.md at main · dotnet/runtim

Just a moment...

a moment...Enable JavaScript and cookies to continue

Common Language Runtime - Wikipedia

Common Language Runtime - Wikipedia

Jump to content

Main menu

Main menu

move to sidebar

hide

Navigation

Main pageContentsCurrent eventsRandom articleAbout WikipediaContact usDonate

Contribute

HelpLearn to editCommunity portalRecent changesUpload file

Search

Search

Create account

Log in

Personal tools

Create account Log in

Pages for logged out editors learn more

ContributionsTalk

Contents

move to sidebar

hide

(Top)

1See also

2References

3External links

Toggle the table of contents

Common Language Runtime

26 languages

العربيةCatalàDanskDeutschEestiEspañolEuskaraفارسیFrançais한국어Bahasa IndonesiaItalianoעבריתMagyarNederlands日本語PolskiPortuguêsРусскийSlovenščinaСрпски / srpskiSvenskaไทยTürkçeУкраїнська中文

Edit links

ArticleTalk

English

ReadEditView history

Tools

Tools

move to sidebar

hide

Actions

ReadEditView history

General

What links hereRelated changesUpload fileSpecial pagesPermanent linkPage informationCite this pageGet shortened URLDownload QR codeWikidata item

Print/export

Download as PDFPrintable version

From Wikipedia, the free encyclopedia

Virtual machine component of Microsoft's .NET framework

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)

This article may rely excessively on sources too closely associated with the subject, potentially preventing the article from being verifiable and neutral. Please help improve it by replacing them with more appropriate citations to reliable, independent, third-party sources. (March 2019) (Learn how and when to remove this template message)

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: "Common Language Runtime" – news · newspapers · books · scholar · JSTOR (September 2014) (Learn how and when to remove this template message)

(Learn how and when to remove this template message)

Program execution

General concepts

Code

Translation

Compiler

Compile time

Optimizing compiler

Intermediate representation (IR)

Execution

Runtime system

Runtime

Executable

Interpreter

Virtual machine

Types of code

Source code

Object code

Bytecode

Machine code

Microcode

Compilation strategies

Ahead-of-time (AOT)

Just-in-time (JIT)

Tracing just-in-time

Compile and go system

Precompilation

Transcompilation

Recompilation

Notable runtimes

Android Runtime (ART)

BEAM

Common Language Runtime (CLR) and Mono

CPython and PyPy

crt0

Java virtual machine (JVM)

LuaJIT

Objective-C and Swift's

V8 and Node.js

Zend Engine

Notable compilers & toolchains

GNU Compiler Collection (GCC)

LLVM and Clang

MSVC

vte

The Common Language Runtime (CLR), the virtual machine component of Microsoft .NET Framework, manages the execution of .NET programs. Just-in-time compilation converts the managed code (compiled intermediate language code) into machine instructions which are then executed on the CPU of the computer.[1] The CLR provides additional services including memory management, type safety, exception handling, garbage collection, security and thread management. All programs written for the .NET Framework, regardless of programming language, are executed in the CLR. All versions of the .NET Framework include CLR. The CLR team was started June 13, 1998.

CLR implements the Virtual Execution System (VES) as defined in the Common Language Infrastructure (CLI) standard, initially developed by Microsoft itself. A public standard defines the Common Language Infrastructure specification.[2]

During the transition from legacy .NET technologies like the .NET Framework and its proprietary runtime to the community-developed .NET Core, the CLR was dubbed CoreCLR.[3] Today, it is simply called the .NET runtime.[4]

Overview of the Common Language Runtime release history[1]

CLR version

.NET version

1.0

1.0

1.1

1.1

2.0

2.0, 3.0, 3.5

4

4, 4.5, 4.6, 4.7, 4.8

See also[edit]

Common Intermediate Language

List of CLI languages

Java virtual machine

References[edit]

^ a b "Common Language Runtime (CLR)". MSDN Library. Retrieved 14 November 2013.

^ "ECMA C# and Common Language Infrastructure Standards". Visual Studio Developer Center. Retrieved 14 November 2013.

^ "Understanding .NET Framework, .NET Core, .NET Standard And Future .NET". www.c-sharpcorner.com. Retrieved February 1, 2021.

^ ".NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps". GitHub. Retrieved November 5, 2023.

External links[edit]

Components of Common Language Runtime

Components of CLR

Overview of the .NET Framework 4.0

.NET Framework Conceptual Overview

vte.NET

.NET strategy

Libraries and frameworks

Implementations

.NET (Core)

.NET Framework

Version history

.NET Compact Framework

.NET Micro Framework

DotGNU

Mono

XNA Framework

Architecture

Common Language Runtime (CLR)

COM Interop

Framework Class Library (FCL)

Components

ADO.NET

Entity Framework

ASP.NET

Web Forms

AJAX

Core

Dynamic Data

MVC

Razor

Avalonia

ClickOnce

Dynamic Language Runtime

Extensible Application Markup Language (XAML)

Language Integrated Query (LINQ)

Managed Extensibility Framework

Microsoft Silverlight

Microsoft XNA

Parallel Extensions

Windows Communication Foundation (WCF)

WCF Data Services

Windows Forms (WinForms)

Windows Identity Foundation (WIF)

Windows Presentation Foundation (WPF)

Windows Workflow Foundation (WF)

.NET Remoting

ToolsObfuscators

Dotfuscator

SmartAssembly

Decompilers

.NET Reflector

dotPeek

Misc

CLR Profiler

ILAsm

.NET Compiler Platform

Native Image Generator (NGen)

XAMLPad

IDEs

Visual Studio

Blend

Express

MonoDevelop

SharpDevelop

Xamarin Studio

Organizations

.NET Foundation

Microsoft

Xamarin

Category

List

Commons

vteCommon Language InfrastructureArchitecture

Application domain

Code Access Security

Common Intermediate Language

instructions

Common Type System

Platform Invocation Services

Virtual Execution System

Components

Assembly

Delegate

Global Assembly Cache

Manifest

Metadata

Standard Libraries

ImplementationsMicrosoft

.NET

.NET Framework

.NET Compact Framework

.NET Micro Framework

Other

Mono

DotGNU

LanguagesMajor languages

C#

Visual Basic

F#

PowerShell

Other

Axum

A#

Boo

Cobra

C++/CLI

IronScheme

IronPython

IronRuby

JScript .NET

J#

Nemerle

Oxygene

Phalanger

Q#

Scala

Small Basic

X#

Comparison

C# and Java

C# and Visual Basic .NET

Java and .NET platforms

Visual Basic and Visual Basic .NET

Authority control databases International

FAST

VIAF

National

France

BnF data

Israel

United States

Retrieved from "https://en.wikipedia.org/w/index.php?title=Common_Language_Runtime&oldid=1183640522"

Categories: .NET Framework terminologyStack-based virtual machinesHidden categories: Articles with short descriptionShort description matches WikidataArticles lacking reliable references from March 2019All articles lacking reliable referencesArticles needing additional references from September 2014All articles needing additional referencesArticles with multiple maintenance issuesArticles with FAST identifiersArticles with VIAF identifiersArticles with BNF identifiersArticles with BNFdata identifiersArticles with J9U identifiersArticles with LCCN identifiers

This page was last edited on 5 November 2023, at 16:29 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0;

additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.

Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view

Toggle limited content width

/clr (Common Language Runtime compilation) | Microsoft Learn

/clr (Common Language Runtime compilation) | Microsoft Learn

Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge

More info about Internet Explorer and Microsoft Edge

Table of contents

Exit focus mode

Language

Read in English

Save

Table of contents

Read in English

Save

Edit

Print

Twitter

LinkedIn

Facebook

Email

Table of contents

/clr (Common Language Runtime Compilation)

Article

10/29/2021

7 contributors

Feedback

In this article

Enables applications and components to use features from the common language runtime (CLR) and enables C++/CLI compilation.

Syntax

/clr[:options]

Arguments

options

One or more of the following comma-separated arguments.

none

With no options, /clr creates metadata for the component. The metadata can be consumed by other CLR applications, and enables the component to consume types and data in the metadata of other CLR components. For more information, see Mixed (Native and Managed) Assemblies.

netcore

Available starting in Visual Studio 2019 version 16.4, /clr:netcore creates metadata and code for the component using the latest cross-platform .NET framework, also known as .NET Core. The metadata can be consumed by other .NET Core applications. And, the option enables the component to consume types and data in the metadata of other .NET Core components.

nostdlib

Instructs the compiler to ignore the default \clr directory. The compiler produces errors if you include multiple versions of a DLL, such as System.dll. This option lets you specify the specific framework to use during compilation.

pure

/clr:pure is deprecated. The option is removed in Visual Studio 2017 and later. We recommend that you port code that must be pure MSIL to C#.

safe

/clr:safe is deprecated. The option is removed in Visual Studio 2017 and later. We recommend that you port code that must be safe MSIL to C#.

noAssembly

/clr:noAssembly is deprecated. Use /LN (Create MSIL Module) instead.

Tells the compiler not to insert an assembly manifest into the output file. By default, the noAssembly option isn't in effect.

A managed program that doesn't have assembly metadata in the manifest is known as a module. The noAssembly option can be used only to produce a module. If you compile by using /c and /clr:noAssembly, then specify the /NOASSEMBLY option in the linker phase to create a module.

Before Visual Studio 2005, /clr:noAssembly required /LD. /LD is now implied when you specify /clr:noAssembly.

initialAppDomain

initialAppDomain is obsolete. Enables a C++/CLI application to run on version 1 of the CLR. An application that's compiled by using initialAppDomain shouldn't be used by an application that uses ASP.NET because it's not supported in version 1 of the CLR.

Remarks

Managed code is code that can be inspected and managed by the CLR. Managed code can access managed objects. For more information, see /clr Restrictions.

For information about how to develop applications that define and consume managed types in C++, see Component Extensions for Runtime Platforms.

An application compiled by using /clr may or may not contain managed data.

To enable debugging on a managed application, see /ASSEMBLYDEBUG (Add DebuggableAttribute).

Only CLR types are instantiated on the garbage-collected heap. For more information, see Classes and Structs. To compile a function to native code, use the unmanaged pragma. For more information, see managed, unmanaged.

By default, /clr isn't in effect. When /clr is in effect, /MD is also in effect. For more information, see /MD, /MT, /LD (Use Run-Time Library). /MD ensures that the dynamically linked, multithreaded versions of the runtime routines are selected from the standard header files. Multithreading is required for managed programming because the CLR garbage collector runs finalizers in an auxiliary thread.

If you compile by using /c, you can specify the CLR type of the resulting output file by using the /CLRIMAGETYPE linker option.

/clr implies /EHa, and no other /EH options are supported for /clr. For more information, see /EH (Exception Handling Model).

For information about how to determine the CLR image type of a file, see /CLRHEADER.

All modules passed to a given invocation of the linker must be compiled by using the same run-time library compiler option (/MD or /LD).

Use the /ASSEMBLYRESOURCE linker option to embed a resource in an assembly. /DELAYSIGN, /KEYCONTAINER, and /KEYFILE linker options also let you customize how an assembly is created.

When /clr is used, the _MANAGED symbol is defined to be 1. For more information, see Predefined macros.

The global variables in a native object file are initialized first (during DllMain if the executable is a DLL), and then the global variables in the managed section are initialized (before any managed code is run). #pragma init_seg only affects the order of initialization in the managed and unmanaged categories.

Metadata and Unnamed Classes

Unnamed classes appear in metadata under names such as $UnnamedClass$$$, where is a sequential count of the unnamed classes in the compilation. For example, the following code sample generates an unnamed class in metadata.

// clr_unnamed_class.cpp

// compile by using: /clr /LD

class {} x;

Use ildasm.exe to view metadata.

To set this compiler option in the Visual Studio development environment

Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.

Set the Configuration dropdown to All configurations, and set the Platform dropdown to All Platforms.

Select the Configuration Properties > C/C++ > General page.

Modify the Common Language Runtime Support property. Choose OK to save your changes.

Note

In the Visual Studio IDE, the /clr compiler option can be individually set on the Configuration Properties > C/C++ > General page of the Property Pages dialog. However, we recommend you use a CLR template to create your project. It sets all of the properties required for successful creation of a CLR component. Another way to set these properties is to use the Common Language Runtime Support property on the Configuration Properties > Advanced page of the Property Pages dialog. This property sets all the other CLR-related tool options at once.

To set this compiler option programmatically

See CompileAsManaged.

See also

MSVC Compiler Options

MSVC Compiler Command-Line Syntax

Feedback

Was this page helpful?

Yes

No

Provide product feedback

|

Get help at Microsoft Q&A

Feedback

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.

Submit and view feedback for

This product

This page

View all page feedback

Additional resources

California Consumer Privacy Act (CCPA) Opt-Out Icon

Your Privacy Choices

Theme

Light

Dark

High contrast

Previous Versions

Blog

Contribute

Privacy

Terms of Use

Trademarks

© Microsoft 2024

Additional resources

In this article

California Consumer Privacy Act (CCPA) Opt-Out Icon

Your Privacy Choices

Theme

Light

Dark

High contrast

Previous Versions

Blog

Contribute

Privacy

Terms of Use

Trademarks

© Microsoft 2024

What is the Common Language Runtime? Definition from WhatIs.com.

What is the Common Language Runtime? Definition from WhatIs.com.

WhatIs

Search the TechTarget Network

Browse Definitions

:

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

#

Login

Register

TechTarget Network

Tech Accelerator

News

2023 IT Salary Survey Results

RSS

WhatIs

Browse Definitions

Internet technologies

Computer science

View All

Electronics

IT standards and organizations

Microprocessors

Robotics

Business software

View All

ERP

HR management

Marketing and CX

Microsoft

Software applications

Cloud computing

View All

Internet applications

Internet of Things

Web services

Computer science

View All

Electronics

Internet technologies

IT standards and organizations

Microprocessors

Robotics

Data analytics and AI

View All

Algorithms

Artificial intelligence

Data and data management

Database management

Data centers

View All

Data backup and disaster recovery

Data center management

Linux

Operating systems

Storage Admin

Storage and Data Mgmt

Virtualization

IT management

View All

Certifications

IT career paths

IT Operations

Personal computing

Project management

Technical support

Networking

View All

High-speed networks

Network Admin

Network hardware

Networking and communications

Wireless and mobile

Security

View All

Authentication and access control

Compliance, risk and governance

Network security

Security Admin

Threat management

Software development

View All

Agile software development

AppDev

DevOps

Programming

Please select a category

Business software

Cloud computing

Computer science

Data analytics and AI

Data centers

IT management

Networking

Security

Software development

Browse Features

Resources

Business strategies

Career resources

Emerging tech

Tech explainers

Follow:

Home

Internet technologies

Definition

Common Language Runtime (CLR)

Share this item with your network:

By

TechTarget Contributor

The Common Language Runtime (CLR) is programming that manages the execution of programs written in any of several supported languages, allowing them to share common object-oriented classes written in any of the languages. It is a part of Microsoft's .NET Framework. The CLR is somewhat comparable to the Java virtual machine that Sun Microsystems provides for running programs compiled from the Java language. Microsoft refers to its CLR as a "managed execution environment." A program compiled for the CLR does not need a language-specific execution environment and can easily be moved to and run on any system with Windows 2000 or Windows XP.

Programmers writing in any of Visual Basic , Visual C++ , or C# compile their programs into an intermediate form of code called Common Intermediate Language (CIL) in a portable execution file that can then be managed and executed by the CLR. The programmer and the environment specify descriptive information about the program when it is compiled and the information is stored with the compiled program as Metadata . Metadata, stored in the compiled program, tells the CLR what language was used, its version and what class libraries will be needed by the program. The CLR allows an instance of a class written in one language to call a method of a class written in another language. It also provides garbage collecting (returning unneeded memory to the computer), exception handling and debugging services.

This was last updated in May 2019

Continue Reading About Common Language Runtime (CLR)

Tangled in .NET: Will 5.0 really unify Microsoft's development stack?

AIOps platforms delve deeper into root cause analysis

Related Terms

cloud access security broker (CASB)

A cloud access security broker (CASB) is a software tool or service that sits between an organization's on-premises ...

See complete definition

Nvidia Omniverse

Nvidia Omniverse is a computing platform built to enhance digital design and development by integrating 3D design, spatial ...

See complete definition

storage security

Storage security is the group of parameters and settings that make storage resources available to authorized users and trusted ...

See complete definition

New & Updated Definitions

tabletop exercise (TTX)

A tabletop exercise (TTX) is a disaster preparedness activity that takes participants through the process of dealing with a simulated disaster scenario. See More.

identity provider

Gemma

asynchronous replication

Current Procedural Terminology (CPT) code

AWS CloudFormation (Amazon Web Services CloudFormation)

NVRAM (non-volatile random access memory)

vulnerability assessment

point of care (POC) testing

Latest TechTarget resources

Networking

Security

CIO

HR Software

Customer Experience

Networking

firewall as a service (FWaaS)

Firewall as a service (FWaaS), also known as a cloud firewall, is a service that provides cloud-based network traffic analysis ...

private 5G

Private 5G is a wireless network technology that delivers 5G cellular connectivity for private network use cases.

NFVi (network functions virtualization infrastructure)

NFVi (network functions virtualization infrastructure) encompasses all of the networking hardware and software needed to support ...

Security

identity provider

An identity provider (IdP) is a system component that provides an end user or internet-connected device with a single set of ...

vulnerability assessment

A vulnerability assessment is the process of defining, identifying, classifying and prioritizing vulnerabilities in computer ...

phishing

Phishing is a fraudulent practice in which an attacker masquerades as a reputable entity or person in an email or other form of ...

CIO

Nvidia Omniverse

Nvidia Omniverse is a computing platform built to enhance digital design and development by integrating 3D design, spatial ...

model-based systems engineering (MBSE)

Model-based systems engineering (MBSE) uses models to share information across collaborators in the design, development, test and...

digital strategy (digital media strategy)

A digital strategy, sometimes called a digital media strategy, is a plan for maximizing the business benefits of data assets and ...

HRSoftware

human capital management (HCM)

Human capital management (HCM) is a comprehensive set of practices and tools used for recruiting, managing and developing ...

Betterworks

Betterworks is performance management software that helps workforces and organizations to improve manager effectiveness and ...

OKRs (Objectives and Key Results)

OKRs (Objectives and Key Results) encourage companies to set, communicate and monitor organizational goals and results in an ...

Customer Experience

martech (marketing technology)

Martech (marketing technology) refers to the integration of software tools, platforms, and applications designed to streamline ...

transactional marketing

Transactional marketing is a business strategy that focuses on single, point-of-sale transactions.

customer profiling

Customer profiling is the detailed and systematic process of constructing a clear portrait of a company's ideal customer by ...

Browse by Topic

Browse Resources

About Us

Meet The Editors

Editorial Ethics Policy

Contact Us

Advertisers

Business Partners

Events

Media Kit

Corporate Site

Reprints

All Rights Reserved,

Copyright 1999 - 2024, TechTarget

Privacy Policy

Cookie Preferences

Cookie Preferences

Do Not Sell or Share My Personal Information

Close

Citizen's Land Registration Portal

Citizen's Land Registration Portal

Citizen's Land Registration Portal

Proceed to CLRP Main Page

Please click here

Download CLRP Training Guides

Please click here

How to Request for User Account

Please click here

Access CLRP Help Desk

Please click here

MENSAHE GALING SA ADMINISTRATOR, LAND REGISTRATION AUTHORITY

Napagpasyahan ng ating pamahalaan na bahagyang buksan na ang ibang mga kalakal sa ating bansa hindi dahil wala na ang pandemya, kundi dahil hindi na kakayanin ng ating ekonomiya.

Ang programa na ito, na brainchild ng inyong lingkod, na pinapatupad ng Land Registration Authority (LRA), sa tulong ng Land Registration Systems, Inc. (LARES), ay naging operational noong January 06, 2020.

Dito sa website na ito mag-e-encode ang clients ng mga entries ng kanilang mga transactions, at pagkatapos ay ipri-print nila ang Registration Application Form (RAF) na naglalaman ng mga sumusunod:

1. Data ng kanilang na-encode;

2. Bar Code; at,

3. Listahan ng mga documents na kinakailangan i-submit sa Registry of Deeds (RD).

Dahil nakalista sa nasabing RAF ang mga required documents, na ibinagay ng computer program batay sa mga information na na-encode ng client, maiiwasan na ang pag-require ng karagdagang requirements maliban sa nakalista sa RAF. Hindi masasayang ang panahon sa pagkuha ng mga requirements na hindi kailangan.

Hindi na rin magiging hadlang at dahilan ang mga napakaraming kailangan i-encode ng mga empleyado natin, dahil ang client na ang mag-encode.

Dadalhin ng client ang RAF sa RD at kapag nabasa na ito ng Bar Code Reader na isasagawa ng kinauukulan doon, ito ay papasok sa data ng LRA.

Ip-proof read ng Entry Clerk at Encoder ng RD ang data na nakapasok, magpi-print ng Transaction Preview Notice (TPN) at ibibigay ito sa client at lalagdaan niya ito.

Sa TPN, na pinapatupad na ng LRA simula October 15, 2018, binibigyan ng karapatan ang client na mag-submit ng correction sa kanyang transaction bago pa ito ma-approve, dahil kapag na-approve na ito, alinsunod sa Sec. 108, P.D. 1529, ang anumang kasunod na correction nito ay maaaring kakailanganin ng pahintulot ng hukuman.

Kahit walang training kayang i-encode ng transacting public ang mga simple sale at mortgage, na bumubuo ng mahigit-kumulang na 326,664 transactions na pumapasok sa RD kada taon.

Para malaman ang guide kung paano mag-encode nito, i-click ang link na ito: Manuals

Ang mga guide ay hindi nangangailangan ng analysis, tinuturo lang nito saan hahanapin ang mga dapat i-encode.

Sa madaling panahon, gagawan na rin natin ng guide ang mahigit-kumulang na 997,006 transactions na pumapasok sa RD kada taon, at mahigit-kumulang na 2.7 million na mga transactions kapag kasali sa bilang ang mga requests for CTC at ibang verifications.

Hindi kasali sa nabanggit ang ibang mga transactions na multiple at complicated dahil kailangan dumaan muna ng training bago matutunan itong gamitin ng wasto. Walang bayad ang training, magpa-schedule lang sa LRA o sa pinakamalapit na RD.

Habang ang programang ito ay ipinapatupad na, patuloy pa rin ang pagdagdag ng mga guidelines para sa mga gagamit nito at patuloy ang pagsasaayos ng programa, at bukas din ang ahensya sa mga suggestions para mas mapapabuti pa ito.

Para mas matugunan pa ang mga karapatan ng mga may-ari ng lupa, maliban sa programang ito, na tatawaging CLRP (2020), ang LRA ay lumikha rin ng mga sumusunod na programa: eTitle "Kaliwaan" Program (2020), Transaction Preview Notice (2018), Title Ready Program (2020), TOIVS (2018), eSerbisyo (2020), Electronic TD (2017), eSignature (2020), at A2A (2012). Para malaman ng transacting public paano gamitin ang mga ito, magsasagawa ng mga patalastas ang LRA at sa takdang panahon na wala ng banta ng COVID-19, magsasagawa rin ng mga seminars.

Mabuhay at tulungan nawa tayo ng Diyos!

Sa ngalan ng lingkod bayan,

RENATO D. BERMEJO

Administrator, LRA

Please select the Training Materials you want to download:

Registered Land - Deed of Sale

Download

Unregistered Land - Deed of Sale

Download

Registered Land - Special Power of Attorney

Download

Unregistered Land - Special Power of Attorney

Download

Registered Land - Real Estate Mortgage

Download

Unregistered Land - Real Estate Mortgage

Download

How to request for user account:

How to request a CLRP user account

Download

Application Form for User Accounts

Download