1. What is .NET? .NET is a general-purpose software development platform, similar to Java. At its core is a virtual machine (called as CLR) that turns intermediate language (IL) into machine code. High-level language compilers for C#, VB.NET and C++ are provided to turn source code into IL. C# is a new programming language, very similar to Java. An extensive class library is included, featuring all the functionality one might expect from a contempory development platform - windows GUI development (Windows Forms), database access (ADO.NET), web development (ASP.NET), web services, XML etc.
2. What platforms does .NET run on? Currently, it is supported on Windows 98, Windows 2000/2003, Windows XP and Windows Vista. ASP.NET integrates with Internet Information Server (IIS) and thus requires that IIS be installed. .NET Compcat Framework runs on Windows CE or Windows Mobile. Mono is an open source project to provide .Net on Linux.
3. What is the CLI? Is it the same as the CLR? The CLI (Common Language Infrastructure) is the definiton of the fundamentals of the .NET framework - the Common Type System (CTS), metadata, the Virtual Execution Environment (VES) and its use of intermediate language (IL), and the support of multiple programming languages via the Common Language Specification (CLS). The CLR (Common Language Runtime) is Microsoft's primary implementation of the CLI. Other implementations are; the .NET Compact Framework for mobile devices, non-Microsoft CLI implementations like Mono and DotGNU Portable.NET.
4. What is IL? IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL during development. The IL is then converted to machine code at runtime by a Just-In-Time (JIT) compiler. Just like how Java programs are converted to Bytecode, C# and VB.NET code is converted to IL.
5. What versions of .NET and when they were released? Microsoft first announced .NET in June,2000. The following were the offical releases of .NET. • • • •
.NET .NET .NET .NET
1.0 1.1 2.0 3.0
was was was was
relased relased relased relased
in in in in
Feb,2002 Apr,2003 Nov,2005 Nov,2006
•
.NET 3.5 was relased in Nov,2007
The following table shows ASP.NET and C# versions along with .NET versions. .NET ASP.NET C# 1.0
1.0
1.0
1.1
1.1
1.1
2.0
2.0
2.0
3.5
3.0
3.0 3.5
6. What's the major additon in the latest versions of .NET 3.5? LINQ (Language Integrated Query) is a new way to access database, xml documents and collections. It enables programmers to access all data sources with expressions in C# and VB.NET. For example, we can access database without using any SQL using C# or VB.NET expressions.
7. What is C#? C# is a new language designed by Microsoft to work with the .NET framework. In their "Introduction to C#" whitepaper, Microsoft describe C# as follows: "C# is a simple, modern, object oriented, and type-safe programming language derived from C and C++. C# (pronounced “C sharpâ€) is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++." C# (or VB.NET) can be used to develop all types of applications - Console, Windows, Web, Web Services and Mobile.
What does 'Managed code' mean in the .NET? The .NET framework provides several core run-time services to the programs that run within it - for example exception handling, memory management and security. For these services to work, the code must provide a minimum level of information to the runtime. Such code is called managed code. Managed data: This is data that is allocated and freed by the .NET runtime's garbage collector.
9. What is an assembly? Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides
the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly. An assembly may be either a .EXE or .DLL file. It contains code that the common language runtime executes.
10. What are different types of Assemblies? Assemblies are classified as private assemblies and global assemblies. Private assemblies are simple and copied to bin directory of the application that is using it. Shared assemblies (also called as gobal assemblies) are copied to a single location called GAC (Global assembly cache). Hence, shared assemblies are not copied in the private folders of each calling application. Each shared assembly has a four part name including its name, version, public key token and culture information. The public key token and version information makes it almost impossible for two different assemblies with the same name or for two similar assemblies with different version to mix with each other.
11. What is the difference between a namespace and an assembly name? A namespace is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. The .NET Framework uses a hierarchical naming scheme for grouping types into logical categories of related functionality. The concept of a namespace is not related to that of an assembly. A single assembly may contain types whose hierarchical names have different namespace roots, and a logical namespace root may span multiple assemblies. In the .NET Framework, a namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.
12. What is meant by un-safe code? By un-safe code, it means that the managed program can access the memory address using pointers. There are two points to remember here: • Un-safe code is different from un-managed as it is still managed by the CLR • You still can not perform pointer arithmetic in un-safe code.
13. What is the difference between Unmanaged and Unsafe code? Un-managed code runs outside the Common Language Runtime (CLR) control while the unsafe code runs inside the CLR’s control. Both un-safe and un-managed codes may use pointers and direct memory addresses.
14. What are the shortcomings of MS.NET platform? The foremost short coming of .NET platform is that it is still the propriety of Microsoft. It is more coupled with the Microsoft Windows operating system and is implemented only on Microsoft Windows successfully. MS.NET desktop applications can run only on Microsoft Windows, Web based applications and web services can only be deployed on Microsoft Internet Information Server (IIS). Since, dot net framework contains a lot of utilities, components, and framework class libraries, the size of downloadable framework is quite large (25MB compared to 5MB size of JVM). The managed .Net applications are somewhat slower to start and run than the traditional Win32 applications. The compiled code of .Net managed applications is easier to de-compile back to the source code.
15. Can I use the Win32 API from a .NET Framework program? Using platform invoke it's possible. .NET Framework programs can access native code libraries by means of static DLL entry points. Here is an example of C# calling the Win32 MessageBox function: using System; using System.Runtime.InteropServices; class MainApp { [DllImport("user32.dll", EntryPoint="MessageBox")] public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType); public static void Main() { MessageBox(0, "This is PInvoke in operation!", ".NET", 0 ); } }
16. What is serialization in .NET and what are the ways to control serialization? Serialization is the process of converting an object into a stream of bytes. On the other hand Deserialization is the process of creating an object from a stream of bytes. Serialization/Deserialization is used to transport or to persist objects. Serialization can be defined as the process of storing the state of an object to a storage medium. You can serialize an object to a stream, disk, memory, over a network, and so forth. Remoting uses serialization to pass objects "By Value" from one computer or application domain to another. XML serialization serializes only public properties and fields and does not preserve Type fidelity. This is useful when you want to provide or consume data without restricting the application that uses the data.
As XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is also an open standard, which makes it an attractive choice too. There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code.