CLR



1. CLR is the .NET equivalent of  

  • A) Java Virtual Machine
  • B) Common Type System
  • C) Compiler of C
  • D) None of these
  • E) All of these


2. What is CLR?  

Common language runtime.it is the heart of .net framework and it takes care of code execution.It helps in running your program by acting as a translator between your program and the computer you are running it on.features of CLR -

a. Garbage Collection-helps in automatic memory management by disposing or the objects when they are not being referenced anymore.

b. IL to native code -CLR uses JIT compiler to convert MSIL to native code.

c. Code access security(CAS)-provides right to certain programs. eg if a piece of code is trying to delete a file for which it does not have permission, CLR prevents it from doing so.

d. Code verification-ensures type safety and prevents code from accessing invalid memory locations etc.



3. What is CLI?  

Common Language Infrastructure – a specification that .net languages are built on. The CLR is an implementation of the CLI


4. What is CIL?  

Common Intermediate Language – .net languages such as C# get compiled to CIL bytecode. This format is understood by the CLR



5. How can JIT code be faster than ahead of time compiled code?  

The JIT code is interpreted for an computer’s specific hardware configuration whereas ahead-of-time compilied code is written for a set of computers meeting a more general specification. This means the JIT can take advantage of very specific hardware features.


6. Explain the path from C# source to native code  

1.C# gets compiled to CIL
2.CIL is then executed by the CLR. It does this using a JIT compiler which converts the CIL into native code.


7. Describe how a .Net application is compiled and executed.  

From the source code, the compiler generates Microsoft Intermediate Language (MSIL) which is further used for the creation of an EXE or DLL. The CLR processes these at runtime. Thus, compiling is the process of generating this MSIL.

The way you do it in .Net is as follows:

Right-click and select Build / Ctrl-Shift-B / Build menu, Build command
F5 - compile and run the application.
Ctrl+F5 - compile and run the application without debugging.

Compilation can be done with Debug or Release configuration. The difference between these two is that in the debug configuration, only an assembly is generated without optimization. However, in release complete optimization is performed without debug symbols. 



8. Overview of CLR integration.  

The CLR (Common Language Runtime) integration is hosted in the Microsoft SQL Server 2005.
With CLR integration, stored procedures, triggers, user- defined functions, user-defined types, and user-defined aggregates in managed code, etc can be written.
As managed code compiles to native code before executing, significant performance can be achieved.
The SQL Server acts as an operating system for the CLR when it is hosted inside SQL Server.

Following are the steps to build a CLR stored procedure in SQL Server 2005

  • Enable CLR integration in SQL Server 2005
  • Create a CLR stored procedure Assembly
  • Deploy the Assembly in SQL Server 2005
  • Create and execute the CLR stored procedure in SQL Server 2005 



9. What are the major components of .NET framework?  

Common Language Runtime: It helps in application execution, allocation and reclamation of memory, enforces type safety. .Net base class library: It contains collection of classes used in application development.


10. What is CLR Triggers ?  

A CLR trigger could be a Date Definition or Date Manipulation Language trigger or could be an AFTER or INSTEAD OF trigger.

Methods written in managed codes that are members of an assembly need to be executed provided the assembly is deployed in SQL 2005 using the CREATE assembly statement.

The Microsoft.SqlServer.Server Namespace contains the required classes and enumerations for this objective.

One can create a database object inside SQL Server that is developed in an assembly created in .Net CLR - it’s a special type of stored procedure that executes on an event. CLR triggers can reference data in the inserted and deleted tables, know about modified columns after an update statement, and access information about objects affected in the database as a result of DDL statements.



11. Explain the concepts of CTS and CLS(Common Language Specification).  

CTS

When different languages are integrated and want to communicate, it is certain that the languages have their own data types and different declaration styles. CTS define how these different variables are declared and used in run time. E.g. VB offers an Integer data type while C++ offers long data type. Using CTS, these data types are converted to System32 which itself a data type of CLS.

CLS

Any language(s) that intend to use the Common Language Infrastructure needs to communicate with other CLS-Compliant language. This communication is based on set of rules laid by CLS. These rules define a subset of CTS.



12. Overview of CLR integration.  

The CLR (Common Language Runtime) integration is hosted in the Microsoft SQL Server 2005.
With CLR integration, stored procedures, triggers, user- defined functions, user-defined types, and user-defined aggregates in managed code, etc can be written.
As managed code compiles to native code before executing, significant performance can be achieved.
The SQL Server acts as an operating system for the CLR when it is hosted inside SQL Server.

Following are the steps to build a CLR stored procedure in SQL Server 2005

  • Enable CLR integration in SQL Server 2005
  • Create a CLR stored procedure Assembly
  • Deploy the Assembly in SQL Server 2005
  • Create and execute the CLR stored procedure in SQL Server 2005 



13. What is Manage Code ?  

Code that runs under the common language runtime. The common language runtime handles many tasks that would formerly have been handled in the application’s executable. Managed code solves the Windows programming problems of component registration and versioning (sometimes called DLL Hell) because managed code contains all the versioning and type information that the common language runtime needs to run the application. The common language runtime handles registration dynamically at run time rather than statically through the system registry, as is done with applications based on the Component Object Model (COM).


14. Define Type Checker.  

Type checker will verify types used in the application with CTS or CLS standards supported by CLR, this provides type safety.


Java Interview Question

.Net Interview Question

PHP Interview Question

AngularJS Interview Questions