Microsoft .NET Framework interview questions

  1. What is .NET Framework?
  2. Is .NET a runtime service or a development platform? Answer It’s bothand actually a lot more. Microsoft .NET is a company-wide initiative. It includes a new way of delivering software and services to businesses and consumers. A part of Microsoft.NET is the .NET Frameworks. The frameworks is the first part of the MS.NET initiate to ship and it was given out to attendees at the PDC in July. The .NET frameworks consists of two parts: the .NET common language runtime and the .NET class library. These two components are packaged together into the .NET Frameworks SDK which will be available for free download from Microsoft’s MSDN web site later this month. In addition, the SDK also includes command-line compilers for C#, C++, JScript, and VB. You use these compilers to build applications and components. These components require the runtime to execute so this is a development platform. When Visual Studio.NET ships, it will include the .NET SDK and a GUI editor, wizards, tools, and a slew of other things. However, Visual Studio.NET is NOT required to build .NET applications.
  3. New features of Framework 1.1 ?
  4. What is CLR? How it will work?
  5. What is MSIL, IL, CTS?
  6. What is JIT and how is works
  7. What is strong name? A name that consists of an assembly’s identity—its simple text name, version number, and culture information (if provided)—strengthened by a public key and a digital signature generated over the assembly.
  8. What is portable executable (PE) The file format defining the structure that all executable files (EXE) and Dynamic Link Libraries (DLL) must use to allow them to be loaded and executed by Windows. PE is derived from the Microsoft Common Object File Format (COFF). The EXE and DLL files created using the .NET Framework obey the PE/COFF formats and also add additional header and data sections to the files that are only used by the CLR. The specification for the PE/COFF file formats is available at http://www.microsoft.com/whdc/hwdev/hardware/pecoffdown.mspx
  9. Which is the base class for .net Class library? Ans: system.object
  10. What is Event? Delegate, clear syntax for writing a event delegate// keyword_delegate.cs // delegate declaration delegate void MyDelegate(int i);
    class Program
    {
    	public static void Main()
    	{
    		TakesADelegate(new MyDelegate(DelegateFunction));
    	}
    	public static void TakesADelegate(MyDelegate SomeFunction)
    	{
    		SomeFunction(21);
    	}
    	public static void DelegateFunction(int i)
    	{
    		System.Console.WriteLine("Called by delegate withnumber: {0}.", i);
    	}
    }

  11. ment DataGrid in .NET? How would you make a combo-box appear in one column of a DataGrid? What are the ways to show data grid inside a data grid for a master details type of tables?
  12. If we write any code for DataGrid methods, what is the access specifier used for that methods in the code behind file and why?
  13. What is Application Domain? Application domains provide a unit of isolation for the common language runtime. They are created and run inside a process. Application domains are usually created by a runtime host, which is an application responsible for loading the runtime into a process and executing user code within an application domain. The runtime host creates a process and a default application domain, and runs managed code inside it. Runtime hosts include ASP.NET, Microsoft Internet Explorer, and the Windows shell.
  14. What is serialization in .NET? What are the ways to control serialization? Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created.
    • Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application. For example, you can share an object between different applications by serializing it to the clipboard. You can serialize an object to a stream, disk, memory, over the 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. Because XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is an open standard, which makes it an attractive choice.
  15. What are the different authentication modes in the .NET environment?
    	<authentication mode="Windows|Forms|Passport|None">
    	<forms name="name" loginUrl="url"
    	protection="All|None|Encryption|Validation"
    	timeout="30" path="/" > requireSSL="true|false"
    	slidingExpiration="true|false"><
    	credentials passwordFormat="Clear|SHA1|MD5"><
    	user name="username" password="password"/> 
    	</credentials> </forms>
    	<passport redirectUrl="internal"/>
    	</authentication>

    /li>

  16. What is the use of trace utility
  17. What is different between User Control and Web Control and Custom Control?
  18. What is exception handling? When an exception occurs, the system searches for the nearest catch clause that can handle the exception, as determined by the run-time type of the exception. First, the current method is searched for a lexically enclosing try statement, and the associated catch clauses of the try statement are considered in order. If that fails, the method that called the current method is searched for a lexically enclosing try statement that encloses the point of the call to the current method. This search continues until a catch clause is found that can handle the current exception, by naming an exception class that is of the same class, or a base class, of the run-time type of the exception being thrown. A catch clause that doesn’t name an exception class can handle any exception. Once a matching catch clause is found, the system prepares to transfer control to the first statement of the catch clause. Before execution of the catch clause begins, the system first executes, in order, any finally clauses that were associated withtry statements more nested that than the one that caught the exception. Exceptions that occur during destructor execution are worthspecial mention. If an exception occurs during destructor execution, and that exception is not caught, then the execution of that destructor is terminated and the destructor of the base class (if any) is called. If there is no base class (as in the case of the object type) or if there is no base class destructor, then the exception is discarded.
  19. What is 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 withthe information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly. Assemblies are a fundamental part of programming withthe .NET Framework. An assembly performs the following functions:
    • It contains code that the common language runtime executes. Microsoft intermediate language (MSIL) code in a portable executable (PE) file will not be executed if it does not have an associated assembly manifest. Note that each assembly can have only one entry point (that is,DllMain,WinMain, orMain).
    • It forms asecurity boundary. An assembly is the unit at which permissions are requested and granted.
    • It forms atype boundary. Every type’s identity includes the name of the assembly in which it resides. A type called MyType loaded in the scope of one assembly is not the same as a type called MyType loaded in the scope of another assembly.
    • It forms areference scope boundary. The assembly’s manifest contains assembly metadata that is used for resolving types and satisfying resource requests. It specifies the types and resources that are exposed outside the assembly. The manifest also enumerates other assemblies on which it depends.
    • It forms aversion boundary. The assembly is the smallest versionable unit in the common language runtime; all types and resources in the same assembly are versioned as a unit. The assembly’s manifest describes the version dependencies you specify for any dependent assemblies.
    • It forms a deployment unit. When an application starts, only the assemblies that the application initially calls must be present. Other assemblies, such as localization resources or assemblies containing utility classes, can be retrieved on demand. This allows applications to be kept simple and thin when first downloaded.
    • It is the unit at which side-by-side execution is supported.
    • Assemblies can be static or dynamic. Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in PE files. You can also use the .NET Framework to create dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.

      There are several ways to create assemblies. You can use development tools, such as Visual Studio .NET, that you have used in the past to create .dll or .exe files. You can use tools provided in the .NET Framework SDK to create assemblies withmodules created in other development environments. You can also use common language runtime APIs, such as Reflection.Emit, to create dynamic assemblies.

  20. s of assemblies? Private, Public/Shared, Satellite
  21. What are Satellite Assemblies? How you will create this? How will you get the different language strings? Satellite assemblies are often used to deploy language-specific resources for an application. These language-specific assemblies work in side-by-side execution because the application has a separate product ID for each language and installs satellite assemblies in a language-specific subdirectory for each language. When uninstalling, the application removes only the satellite assemblies associated witha given language and .NET Framework version. No core .NET Framework files are removed unless the last language for that .NET Framework version is being removed. For example, English and Japanese editions of the .NET Framework version 1.1 share the same core files. The Japanese .NET Framework version 1.1 adds satellite assemblies withlocalized resources in a \ja subdirectory. An application that supports the .NET Framework version 1.1, regardless of its language, always uses the same core runtime files.
  22. How will you load dynamic assembly? How will create assemblies at run time?
  23. What is Assembly manifest? what all details the assembly manifest will contain. Every assembly, whether static or dynamic, contains a collection of data that describes how the elements in the assembly relate to each other. The assembly manifest contains this assembly metadata. An assembly manifest contains all the metadata needed to specify the assembly’s version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes. The assembly manifest can be stored in either a PE file (an .exe or .dll) withMicrosoft intermediate language (MSIL) code or in a standalone PE file that contains only assembly manifest information. It contains Assembly name, Version number, Culture, Strong name information, List of all files in the assembly, Type reference information, Information on referenced assemblies.
  24. What are the contents of assembly? In general, a static assembly can consist of four elements:
    • The assembly manifest, which contains assembly metadata.
    • Type metadata.
    • Microsoft intermediate language (MSIL) code that implements the types.
    • A set of resources.
  25. Difference between assembly manifest & metadata assembly manifest -An integral part of every assembly that renders the assembly self-describing. The assembly manifest contains the assembly’s metadata. The manifest establishes the assembly identity, specifies the files that make up the assembly implementation, specifies the types and resources that make up the assembly, itemizes the compile-time dependencies on other assemblies, and specifies the set of permissions required for the assembly to run properly. This information is used at run time to resolve references, enforce version binding policy, and validate the integrity of loaded assemblies. The self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment feasible. metadata -Information that describes every element managed by the common language runtime: an assembly, loadable file, type, method, and so on. This can include information required for debugging and garbage collection, as well as security attributes, marshaling data, extended class and member definitions, version binding, and other information required by the runtime.
  26. What is Global Assembly Cache (GAC) and what is the purpose of it? (How to make an assembly to public? Steps) Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.  You should share assemblies by installing them into the global assembly cache only when you need to.
  27. If I have more than one version of one assemblies, then how’ll I use old version (how/where to specify version number?)in my application?
  28. How to find methods of a assembly file (not using ILDASM) Reflection
  29. Value type & data types difference. Example from .NET.
  30. Integer & struct are value types or reference types in .NET?
  31. What is Garbage Collection in .Net? Garbage collection process? The process of transitively tracing through all pointers to actively used objects in order to locate all objects that can be referenced, and then arranging to reuse any heap memory that was not found during this trace. The common language runtime garbage collector also compacts the memory that is in use to reduce the working space needed for the heap.
  32. Readonly vs. const? Aconstfield can only be initialized at the declaration of the field. Areadonlyfield can be initialized either at the declaration or in a constructor. Therefore,readonlyfields can have different values depending on the constructor used. Also, while aconstfield is a compile-time constant, thereadonlyfield can be used for runtime constants, as in the following example: public static readonly uint l1 = (uint) DateTime.Now.Ticks;
  33. //Declaring properties
    public bool MyProperty
    {
    	get {return this.myvalue;}
    	set {this.myvalue = value;}
    }
    

ion to get access to custom attributes.
class MainClass
{
public static void Main()
{
System.Reflection.MemberInfo info = typeof(MyClass);
object[] attributes = info.GetCustomAttributes();
for (int i = 0; i < attributes.Length; i ++)
{
System.Console.WriteLine(attributes[i]);
}
}
}

  • C++ & C# differences
  • What is the managed and unmanaged code in .net? The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime’s functionality and enable you to write code that benefits from this managed execution environment. Code that you develop witha language compiler that targets the runtime is calledmanaged code; itbenefits 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.
  • How do you create threading in .NET? What is the namespace for that?
  • using directive vs using statement You create an instance in ausingstatement to ensure thatDispose is called on the object when theusingstatement is exited. Ausing statement can be exited either when the end of theusingstatement is reached or if, for example, an exception is thrown and control leaves the statement block before the end of the statement. The using directive has two uses.
    • Create an alias for a namespace (a using alias).
    • Permit the use of types in a namespace, such that, you do not have to qualify the use of a type in that namespace (ausingdirective).
  • Describe the Managed Execution Process
  • What is Active Directory? What is the namespace used to access the Microsoft Active Directories?
  • Interop Services?
  • What is RCW (Run time Callable Wrappers)? The common language runtime exposes COM objects through a proxy called the runtime callable wrapper (RCW). Although the RCW appears to be an ordinary object to .NET clients, its primary function is to marshal calls between a .NET client and a COM object.
  • What is CCW (COM Callable Wrapper)
  • A proxy object generated by the common language runtime so that existing COM applications can use managed classes, including .NET Framework classes, transparently.

  • How does you handle this COM components developed in other programming languages in .NET?
  • How will you register com+ services?
  • What is use of ContextUtil class? ContextUtil is the preferred class to use for obtaining COM+ context information.
  • What is the new three features of COM+ services, which are not there in COM (MTS)
  • Is the COM architecture same as .Net architecture?  What is the difference between them (if at all there is)?
  • For more questions and answers, visit Santhosh Thomas’ site, as he constantly updates these questions with answers.

    This entry was posted in .NET. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

    14 Comments on Microsoft .NET Framework interview questions

    1. Andrew O
      Posted 2/17/2004 at 7:30 am | Permalink

      6. What is JIT and how is works ?

      summary: Before you can run Microsoft intermediate language (MSIL), it must be converted by a .NET Framework just-in-time (JIT) compiler to native code, which is CPU-specific code that runs on the same computer architecture as the JIT compiler. Because the common language runtime supplies a JIT compiler for each supported CPU architecture, developers can write a set of MSIL that can be JIT-compiled and run on computers with different architectures. However, your managed code will run only on a specific operating system if it calls platform-specific native APIs, or a platform-specific class library.
      JIT compilation takes into account the fact that some code might never get called during execution. Rather than using time and memory to convert all the MSIL in a portable executable (PE) file to native code, it converts the MSIL as needed during execution and stores the resulting native code so that it is accessible for subsequent calls.

      source: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconJITCompilation.asp

    2. Andrew O
      Posted 2/17/2004 at 7:32 am | Permalink

      4. What is CLR? How it will work?

      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, and they follow the runtime’s rules for defining new types, as well as for creating, using, persisting, and binding to types.

      source: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcommonlanguageruntimeoverview.asp

    3. KuralMAni
      Posted 3/8/2004 at 2:53 am | Permalink

      Wat is Ecno JIT and Standard JIT how they Differ

    4. Anil Abraham
      Posted 3/30/2004 at 8:05 am | Permalink

      How .Net FraneWork Differ from DNA Architecture ?

    5. Posted 4/27/2004 at 5:06 am | Permalink

      The more I tell the less it is. Its one of the best site for all the fresher who are hunting for the jobs, every one can go through this site and get confidence in interview.Definately it will help them.

    6. Anonymous
      Posted 7/3/2004 at 10:03 pm | Permalink

      What is the name of the .NET feature that allows an assembly to examine the metadata of another assembly at runtime?

      Wonderful site! I ran to this question. :-(

    7. Seth
      Posted 9/21/2004 at 12:46 pm | Permalink

      Kavya, I believe it’s reflection.

    8. raj kishore
      Posted 6/3/2005 at 1:57 am | Permalink

      questions are very good for tech interview

    9. Saurabh Deshmukh
      Posted 8/1/2005 at 2:01 am | Permalink

      Answer to Comment 4:

      DNA(Distributed interNet Application) Architecture based application provide a way to fully integrate the web with N-Tier model of development but they have some problems such as DLL HELL.

      The advantages of .Net Framework over DNA Architecture based applications are:

      1. DLL Hell
      2. XCOPY Deployment
      3. Versioning

      For more information refer to
      http://www.c-sharpcorner.com/WebForms/WebServicesP1RSR.asp

      Hope this helps.

    10. sowmya
      Posted 5/3/2006 at 6:20 am | Permalink

      what is the difference between c++ and c#?

    11. Subbu
      Posted 2/15/2007 at 2:23 am | Permalink

      What is meant by CLR?

      CLR is stands for Common Language Runtime.It is a part of the .Net Framework.all .net language languages run under the control of the .net framwork.
      and CLR follows no of the features
      1.Garbage Collector
      2.Code Access Security.
      3.Type Safety
      4.IL Optimizers to Native code. etc……

    12. Simi Sreedharan
      Posted 3/31/2007 at 2:32 am | Permalink

      What is meant by CLR?

      CLR is a multi language run time engine that manages execution of .Net programs

    13. Simi Sreedharan
      Posted 3/31/2007 at 3:07 am | Permalink

      Types of JIT compilers

      Three different JITters can be used to convert the MSIL into native code, depending on the circumstances:

      Pre – JIT

      Pre – JIT will compile an entire assembly into CPU-specific binary code. This compilation is done at install time, when the end user is least likely to notice that the assembly is being JIT-compiled. The advantage of install-time code generation is that it allows you to compile the entire assembly just once before you run it. Because the entire assembly is compiled, you don’t have to worry about intermittent performance issues every time a method in your code is executed the first time.

      When and if you use this utility depends on the size of your specific system and your deployment environment. Typically, if you’re going to create an installation application for your system, you should go ahead and use this JITter so that the user has a fully optimized version of the system “out of the box.”

      Econo – JIT

      Econo – JIT compiles only those methods that are called at runtime. However these compiled methods are removed if the system begins to run out of memory.

      The EconoJIT is specifically designed for systems that have limited resources—for example, handheld devices with small amounts of memory. The major difference between this JITter and the regular JITter is the incorporation of something called code pitching. Code pitching allows the EconoJIT to discard the generated, or compiled, code if the system begins to run out of memory. The benefit is that the memory is reclaimed. However, the disadvantage is that if the code being pitched is invoked again, it must be compiled again as though it had never been called.

      Normal – JIT

      This is the default Jitter.

      This JITter is called at run time each time a method is invoked for the first time (compiles only those methods that are called at runtime. These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the compiled code from cache is used for execution.)

    14. Rahul Patel
      Posted 5/1/2007 at 12:06 am | Permalink

      Hi..

      I have a problem that, In Windows based application we have client server application,now in this structure if i updates one DLL on the server. is it possible that, those updates automatic applied to client Application.

      Means it is possible that we share assembly across the network for windows based application.

      please reply me.

    Post a Comment

    Your email is never published nor shared. Required fields are marked *

    *
    *