Tuesday, July 28, 2020

Interview Questions and Answers on Dot Net Framework C Sharp Dot Net (Part-3)

Question 61 – What is Runtime Host?

Ranging from Windows applications, Web applications to Mobile applications, CLR is designed to support various types of applications. .NET Framework provides different types of runtime hosts to manage the execution of application code(to load runtime in to process, create application domain within process, load user code in to application domain) and provides various services to the application. Runtime hosts included in .Net framework are : ASP.NET, Microsoft Internet Explorer and windows shell.


Question 62 – What is Connection Pooling?

  • A Connection Pool is a container of open and reusable connections. A Connection Pool is released from the memory when the last connection to the database is closed.
  • The Data Providers in ADO.NET have Connection Pooling turned on by default; if you need to turn it off, specify Pooling = false in the connection string being used.
  • Connection Pooling gives you an idle, open, reusable connection instead of opening a new one every time a connection request to the database is made. When the connection is closed or disposed, it is returned to the pool and remains idle until a request for a new connection comes in.
  • The pool can house connections up to the maximum limit as specified in the connection string that was used to connect to the database.
  • Advantage of using Connection Pooling is an improvement of performance and scalability
  • Disadvantage is that one or more database connections, even if they are currently not used, are kept open.


Question 63 – What are the main parameters used by Connection Pooling?

Connection Pooling is controlled and the parameters passed to a connection string comprises the following:

  • Connect Timeout
  • Min Pool Size
  • Max Pool Size
  • Pooling


Question 64 – What is Connection Pool Manager?

A Connection Pool is maintained internally by the Connection Pool Manager. When a request for a subsequent connection comes in, the Connection Pool Manager searches the pool for the availability of a free connection and returns it to the application if one is available. Connection Pools works as below

  • If any unused connection is available, it returns one.
  • If all connections are used up, a new connection is created and added to the pool.
  • If the number of connections reaches the maximum number of connections in the pool, the requests are queued until a connection becomes free for reuse.


Question 65 – What is Object Pooling?

It is something that tries to keep a pool of objects in memory to be re-used later and hence it will reduce the load of object creation to a great extent. Whenever there is a request for a new object, the pool manager will take the request and it will be served by allocating an object from the pool. Pooling basically means utilizing the resources efficiently, by limiting access of the objects to only the period the client requires it.

Question 66 – What are the Advantages of Object Pooling?

It minimizes the consumption of memory and the system’s resources by recycling and re-using objects as and when it is needed and serving the request for new objects from the pool of ready-to-be-used objects. The objects that the application is done with (the objects are no longer needed) are sent back to the pool rather than destroying them from the memory.

According to MSDN, “Once an application is up and running, memory utilization is affected by the number and size of objects the system requires. Object pooling reduces the number of allocations, and therefore the number of garbage collections, required by an application.


Question 67 – What is the Difference between Connection Pooling and Object Pooling?

Object Pooling is great in the sense that it can optimize access to expensive resources (like file handles or network connections) by pooling them in memory and reusing them as and when they are needed.

According to MSDN, “Object pooling lets you control the number of connections you use, as opposed to connection pooling, where you control the maximum number reached.”


Question 68 – What is an Indexer?

  • Indexers permit instances of a class or struct to be indexed in the same way as arrays.
  • Indexers are similar to properties except that their accessors take parameters.
  • The indexers are usually known as smart arrays in C#.
  • An indexer, also called an indexed property, is a class property that allows you to access a member variable of a class using the features of an array.
  • Defining an indexer allows you to create classes that act like virtual arrays. Instances of that class can be accessed using the [] array access operator.


Question 69 – What are the important points to remember on indexers?

  • Indexers are always created with this keyword.
  • Parameterized property are called indexer.
  • Indexers are implemented through get and set accessors for the [ ] operator.
  • ref and out parameter modifiers are not permitted in indexer.
  • Indexer is an instance member so can’t be static but property can be static.
  • Indexers are used on group of elements.
  • Indexer can be overloaded.


Question 70 – What is the Difference between Indexers and Properties?

Indexers

Properties

Indexers are created with this keyword

Properties don’t require this keyword

Indexers are identified by signature

Properties are identified by their names

Indexers are accessed using indexes

Properties are accessed by their names

Indexer are instance member, so can’t be static

Properties can be static as well as instance members

 

Question 71 – What are the different Access Modifiers available?

  • Public – Access to same assembly or another assembly that references it.
  • Private – Access to same class or struct.
  • Protected – Access to same class or struct, or in a class that is derived.
  • Internal – Access to any code in the same assembly, but not from another assembly.
  • Protected Internal – Access to any code in the assembly in which it is declared, or from within a derived class in another assembly.

Interview Questions and Answers on .Net Framework C#.Net (Part-2)

Interview Questions and Answers on .Net Framework and C#.Net

Question 40 – What are the Advantages of XML Serialization? 
• Serialization is of XML based. 
• Support for cross-platform programming. 
• Easily readable and editable. 

Question 41 – What is Custom Serialization? 
• In some cases, the default serialization techniques provided by .NET may not be sufficient in real life. • This is when we require implementing custom serialization. 
• It is possible to implement custom serialization in .NET by implementing the ISerializable interface. 
• This interface allows an object to take control of its own serialization and de-serialization process. 
• It gives us a great deal of flexibility in the way we can save and restore objects. 

Question 42 – What is a Namespace? 
• Containers of objects which contain classes, unions, structures, interfaces, enumerators, delegates. 
• Main goal is for creating a hierarchical organization of the program. 
• Developers do not need to worry about the naming conflicts of classes, functions, variables etc. 

Question 43 – What is GUID? 
It is a Short form of Globally Unique Identifier, A unique 128-bit number that is produced by the Windows OS or Windows app to identify a particular component, application, file, database entry, and/or user. 

Question 44 – What is a Formatter? 
• A formatter is used to determine the serialization format for objects. 
• In other words, it is used to control the serialization of an object to and from a stream. 
• They are the objects that are used to encode and serialize data into an appropriate format before they are transmitted over the network. 
• They expose an interface called the IFormatter interface. IFormatter’s significant methods are Serialize and De-serialize which perform the actual serialization and de-serialization. 
• There are two formatter classes provided within .NET, the BinaryFormatter and the SoapFormatter. Both these classes extend the IFormatter interface. 

Question 45 – What is a Binary Formatter? 
The Binary formatter provides support for serialization using binary encoding. The BinaryFormater class is responsible for binary serialization and is used commonly in .NET’s Remoting technology. This class is not appropriate when the data is supposed to be transmitted through a firewall. 

Question 46 – What is SOAP Formatter? 
The SOAP formatter provides formatting that can be used to serialize objects using the SOAP protocol. It is used to create a Soap envelope and it uses an object graph to generate the result. It is responsible for serializing objects into SOAP messages or parsing the SOAP messages and extracting these serialized objects from the SOAP messages. SOAP formatters in .NET are widely used by Web Services. 

Question 47 – What is Reflection? 
• It is a collection of classes which allow u to query assembly (class/object) metadata at runtime. 
• Using reflection we can also create new types and their instances at runtime and invoke methods on these new instances. 
• At runtime, the Reflection mechanism uses the PE file to read information about the assembly. 
• We can dynamically invoke methods using the System.Type.Invokemember 
• We can dynamically create types at runtime using System.Reflection.Emit.TypeBuilder 
• With reflection we can do the below 
• we can dynamically create an instance of a type 
• bind the type to an existing object 
• get the type from an existing object 
• invoke its methods or access its fields and properties 

Question 48 – What are Thread and Process? 
• Threads are basically lightweight processes responsible for multitasking within a single application. 
• The base class used for threading is System.Threading. 
• Threads are implemented when situations in which you want to perform more than one task at a time. • A Process is an instance of a running application. 
• A thread is the Execution stream of the Process. 
• A process can have multiple Threads. 
• Example: A Microsoft Word is an Application. When you open a word file, an instance of the Word starts and a process is allocated to this instance which has one thread. 
• Create Thread – use System.Thread() class and create an instance. 
• Join Thread – use object.Join() to join threads. 
• Suspend Thread – use object.Sleep() to suspend a thread. 
• Kill Thread – use object.Abort() to abort a thread. 

 Question 49 – What are the difference between a DLL and an Exe? 

DLL

EXE

Create an object of dll

Not in exe

Multiple Uses

Single use

Cannot be started as stand alone

Can be started as stand alone


Question 50 – What are Globalization and Localization? 
To implementing a multilingual user interface, you design the user interface to open in the default UI language and offer the option to change to other languages. Globalization is the first step in the process. A globalized application supports localized user interfaces and regional data for all users. Truly global applications should be culture-neutral and language-neutral. A globalized application can correctly accept, process, and display a worldwide assortment of scripts, data formats, and languages. Accommodating these cultural differences in an application is called localization. 

Question 51 – What is a Resource File?
Resource files are the files containing data that is logically deployed with an application. These files can contain data in a number of formats including strings, images and persisted objects. It has the main advantage of If we store data in these files then we don’t need to compile these if the data get changed. In .NET we basically require them storing culture-specific information’s by localizing application’s resources. You can deploy your resources using satellite assemblies. 

Question 52 – What is Code Access Security(CAS)?
CLR allows code to perform only those operations that the code has permission to perform. So CAS is the CLR’s security system that enforces security policies by preventing unauthorized access to protected resources and operations. Using the Code Access Security, you can do the following: 
• Restrict what your code can do 
• Restrict which code can call your code 
• Identify code Code access security consists of the following elements: 
• Permissions – represent access to a protected resource or the ability to perform a protected operation. 
• Permission sets – A permission set is a collection of permissions. 
• Code groups – a logical grouping of code that has a specified condition for membership Evidence 
• Policy – Security policy is the configurable set of rules that the CLR follows when determining the permissions to grant to code. 
• There are four policy levels – Enterprise, Machine, User, and Application Domain, each operating independently from each other. Syntax 
• See CAS objects — Run ‘caspol -lg’ from command line. 
• Add CAS objects — caspol -ag 1.3 -site www.mydomain.com FullTrust 
• Change CAS obj — caspol -cg 1.3 FullTrust 
• Turn Off — caspol -s off 

Question 53 – What is difference between Code Based Security and Role Based Security? 
CAS is the approach of using permissions and permission sets for a given code to run. Example, Admin can disable running executables off the Internet or restrict access to corporate database to only few applications. 
• Role security most of the time involves the code running with the privileges of the current user. This way the code cannot supposedly do more harm than mess up a single user account. 
• Neither is better. It depends on the nature of the application; both code-based and role-based security could be implemented to an extent. 

Question 54 – What is difference between Invoke and Begin Invoke 
• Delegate.Invoke: Executes synchronously, on the same thread. 
• Delegate.BeginInvoke: Executes asynchronously, on a thread pool thread. 
• Control.Invoke: Executes on the UI thread, but calling thread waits for completion before continuing. • Control.BeginInvoke: Executes on the UI thread, and calling thread doesn’t wait for completion. 
• BeginInvoke is asynchronous. When BeginInvoke is called from the UI thread the request will be executed in parallel with the UI thread. Which means it may not execute until after the currently executing method has returned. So in this case the text box will never appear to update because the for loop will not be interrupted, as the calling thread will not wait for this event to be completed before continuing. 
• Alternatively, Invoke is synchronous. The text box will be updated because the calling thread will wait for the call to complete before continuing execution. 

Question 55 – What is the difference between Debug and Trace? 
Tracing is actually the process of collecting information about the program’s execution. Debugging is the process of finding & fixing errors in our program. Tracing is the ability of an application to generate information about its own execution. Trace and Debug work in a similar way, the difference is that tracing from the Debug class only works in builds that have the DEBUG symbol defined, whereas tracing from the Trace class only works in builds that have the TRACE symbol defined. 
• Use System.Diagnostics.Trace.WriteLine for tracing that you want to work in debugging and release builds 
• Use System.Diagnostics.Debug.WriteLine for tracing that you want to work only in debug builds.

 Question 56 – What is a Debug version of code? 
• Preprocessor(Debugging Diagnostic) macro _DEBUG is enabled. 
• More memory size. 
• Support files required. (MFC Dll’s) 
• No Code Optimization 
• Uses MFC Debug Library 
• ASSERT is enabled. 
• Execution takes more time 

Question 57 – What is a Release version of a code? 
• Preprocessor(Debugging Diagnostic) macro NDEBUG is enabled. 
• Less memory size. 
• Support files not required. (MFC Dll’s) 
• Code Optimization 
• Uses MFC Release Library 
• ASSERT is disabled anything inside of ASSERT will not be executed. 
• Execution takes less time 

Question 58 – What is an IDisposable Interface? 
• The primary use of this interface is to release unmanaged resources. The garbage collector automatically releases the memory allocated to a managed object when that object is no longer used. 
• However, it is not possible to predict when garbage collection will occur. 
• Furthermore, the garbage collector has no knowledge of unmanaged resources such as window handles, or open files and streams. 
• The consumer of an object can call this method when the object is no longer needed. 

Question 59 – What is Finalize block in .net? 
• Finalize() is called by the runtime 
• Is a C# equivalent of destructor, called by Garbage Collector when the object goes out of scope. 
• Implement it when you have unmanaged resources in your code, and want to make sure that these resources are freed when the Garbage collection happens. 
• Finalize() can NOT be overridden or called in C#. 
• Since, Finalize() is called by the Garbage Collector, it is non-deterministic. 

Question 60 – What is Dispose block in .net? 
• Dispose() is called by the user 
• Same purpose as finalize, to free unmanaged resources. However, implement this when you are writing a custom class, that will be used by other users. 
• Overriding Dispose() provides a way for user code to free the unmanaged objects in your custom class. 
• Dispose() has to be implemented in classes implementing IDispose interface. 
• Dispose() method is called explicitly in the code itself.

Sunday, July 26, 2020

Interview Questions and Answers on Dot Net Framework C Sharp Dot Net (Part-1)

Interview Questions and Answers on .Net Framework 
 
Question 1 – What Is CLR? 
CLR is Common Language Runtime is the runtime that converts an MSIL code into the host machine language code. It is the execution engine for .NET Framework applications. It provides a number of services, including:  
• Code management (loading and execution)  
• Memory Management  
• Thread Management 
• Conversion of IL to native code.  
• Access to metadata (enhanced type information)  
• Managing memory for managed objects (Garbage collection)  
• Enforcement of code access security (Security Management)  
• Exception handling, including cross-language exceptions 
• Interoperation btw managed code, COM objects, and pre-existing DLL’s (unmanaged code and data)
• Support for developer services (profiling, debugging, and so on). 
• Type safety. 

Question 2 – What is CLR HOST? 
A CLR host is an application that is responsible for loading the CLR into a process, creating application domains within the process, and executing user code within the application domains. 
Examples of hosts that ship with the .NET Framework includes: 
• ASP.Net – An ISAPI filter that ships with ASP.NET load the CLR and does the initialization necessary to handle web requests. 
• Internet Explorer: – A MIME filter hooks into IE versions 5.01 and higher to execute managed controls referenced from HTML pages. 

Question 3 – What is CTS? 
CTS is Common Type System, which describes how types are declared, used, and managed. CTS facilitate cross-language integration, type safety, and high-performance code execution. Example in VB you have “Integer” and in C++ you have “long” these data types are not compatible so the interfacing between them is very complicated. In order that these two different languages communicate Microsoft introduced the Common Type System. So “Integer” data type in VB and “int” data type in C++ will convert it to System.int32, which is the data type of CTS. 

Question 4 – What is CLS? 
CLS Is Common Language Specification, is a specification that defines the rules to support language integration. This is done in such a way, that programs written in any language (.NET compliant) can interoperate with one another. This also can take full advantage of inheritance, polymorphism, exceptions, and other features. It was always a dream of Microsoft to unite all different languages in to one umbrella and CLS is one-step towards that. 

Question 5 – What is an Intermediate Language? 
(IL) Intermediate Language Or (CIL) Common Intermediate Language Or (MSIL) Microsoft Intermediate Language, is one of the Core components of the .NET Framework. Any .NET source codes written in any .net supportive language (C#,VB.net etc), when compiled are converted to MSIL. This MSIL, when installed or at the Runtime, gets converted to machine code. The Runtime conversion of MSIL code to the machine code is handled by a component called the Just In Time (JIT) Compiler. 

Question 6 – What is Just In Time Compiler? 
It is a compiler which converts MS IL (Microsoft Intermediate Language) code to Native Code (i.e. CPU-specific code that runs on the same computer architecture). Just-In-Time compiler- it converts the language that you write in .Net into machine language that a computer can understand. 
There are 3 types of JITs 
• Pre-JIT compiler (Compiles entire code into native code completely in a single Operation) 
• Econo JIT compiler (Compiles only methods(Code) called at Runtime) 
• Normal JIT compiler (Compiles only that part of code called at Runtime and places in cache) 

Question 7 – 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. Windows PE is divided into 2 main sections. 
• The first section includes the PE/COFF headers that reference the contents within the PE file. 
• The second section is the native image section which contains .data, .rdata, .rsrc, and .text sections. 

Question 8 – What is the Managed Code? 
Managed code runs inside the environment of CLR i.e. .NET runtime. In short, all IL are managed code. However, if you are using some third party software example VB6 or VC++ component they are unmanaged code, as .NET runtime (CLR) does not have control over the source code execution of these languages. A runtime-aware the compiler compiles the IL into native executable code within a managed execution environment that ensures type safety, array bound and index checking, exception handling, and garbage collection. Also, many unproductive programming tasks are automatically taken care of, such as type safety checking, memory management, and destruction of unneeded objects. You can therefore focus on the business logic of your applications and write them using fewer lines of code. The result is shorter development time and more secure and stable applications. 

Question 9 – What is UnManaged Code? 
As mentioned above the Unmanaged code will be one where 
• The CLR cannot able to understand the code. 
• The CLR cannot instruct the code. 
• The second time compilation is unmanaged code. It is understood only by the machine not by the user. 

Question 10 – What is Garbage Collector? 
Garbage collection is a process of releasing the memory used by the objects, which are no longer referenced. This is done in different ways and different manners in various platforms and languages. When an program is loaded in the memory there will be a bunch of memory allocated for that particular program alone and loaded with memory. This bunch of memory is called Managed Heap(is nothing but a bunch of memory allocated for the program at run time). This amount of memory will only be used when an object is to be loaded in to the memory for that particular program. This memory is separated in to three parts: 
• Generation Zero – Smaller size 
• Generation One – Medium size 
• Generation Two – Larger size When we try to create an object by using a NEW keyword the system will, 
• Calculate the number of bytes required for the object or type to be loaded in to the managed heap. 
• The CLR then checks that the bytes required to allocate the object are available in the reserved region. IF the object fits, it is allocated at the address pointed to by NextObjPtr. 
• These processes will happen at the Generation zero level. 

Question 11 – What is a Strong Name? 
A strong name is a .NET assembly name combined with its version number and other information to uniquely identify the assembly. This allows multiple versions of the same assembly to peacefully co-exist in the global assembly cache, where shared assemblies are typically stored. It consists of five parts as mentioned below 
• Simple Name – Usually the name of the file (without the extension) that contains the assembly 
• Public Key – RSA cryptographic public key that helps verify the assembly’s authenticity 
• Version – Four-part version number, in the form of Major.Minor.Build.Revision 
• Culture – Target audience for the assembly, such as “neutral” (default audience), “en-us” (English – United States) or “fr” (France) etc. 
• Processor Architecture – Defines the assembly’s format, such as MSIL (intermediate language) or x86 (binary for Intel x86 processors) 

Question 12 – What are the steps to create Strong Name?
 We have a set of steps that should be followed to create a strong name as shown below. 
• Open .net command prompt. 
• Go to the folder containing DLL. 
• Type sn -k test.snk, This will create test .snk file in that folder. 
• Open the assemblyinfo.cs file of project. 
• Type file path in this tag [assembly:AssemblyKeyFile@”E:\Code\practice\HP\bin\Debug\HP.snk”)]
• Build application, finally your strong name created for your DLL. 

Question 13 – What are the Problems faced using Strong Name? 
• Requires Exact Match. If you use strong names, your application or library must load the assembly with the exact strong name that you specify, including version and culture. 
• Cannot Lose Private Key. If your private key is lost or stolen, the security of your assembly is compromised. You will be forced to re-issue a new assembly signed with a new public-private key pair. 

Question 14 – What is Program Database? 
A program database files holds debugging and project state information that allows incremental linking of debug configuration of your program. A PDB file can be up to 2GB. 

Question 15 – What is Delay Signing?
 It is signing an assembly with its strong name public key, which is freely distributable, instead of using the private key as usual. This allows developers to use and test a strong-named assembly without access to the private key. Then at a later stage (typically just before shipping the assembly), a manager or trusted key holder must sign the assembly with the corresponding private key. 

Question 16 – 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. 

Question 17 – What are the Contents of an Assembly 
• Type metadata.
 • The assembly manifest, which contains assembly metadata. 
• Microsoft intermediate language (MSIL) code that implements the types. 
• A set of resources 

Question 18 – What are the Types of Assemblies? 
Assemblies are of four types 
• Private – The assembly is intended only for one application 
• Shared – If the assembly is to be made into a Shared Assembly(GAC) 
• Static – These are the .NET PE files that you create at compile time. 
• Dynamic – These are PE-formatted, in-memory assemblies that you dynamically create at runtime 

Question 19 – What is a Satellite assembly? 
• A .NET Framework assembly containing resources specific to a given language. 
• Using satellite assemblies, you can place the resources for different languages in different assemblies. • The correct assembly is loaded into memory only if the user elects to view in that language. 
• Culture is maintained in a text file which acts like a resource to the assembly. 

Question 20 – What are the Steps to Create Satellite Assembly? 
Below are the steps to create a satellite assembly 
• Set the paths for resgen and al.exe: 
• Create a .resources file. 
• Create the satellite assembly.
 The assembly should have the naming convention for .NET to be able to search for it.
• Specify the settings for culture. 
• Put the satellite assembly in the appropriate folder. 
• Once the satellite assembly is created, physically copy it to the appropriate directory.
• Repeat the process for each language in which you are creating an assembly. 

Question 21 – What is an Assembly Loader? 
• Checks if the assembly is Strongly signed. 
• If yes it will search in the GAC 
• Loader will search the policy file name in the format of
 • Policy.AssemblyMajorVersion.AssemblyMinorVersion.AssemblyName 
• Eg. MyPolicy.1.2.Assembly1 
• If such a file exists it will look inside of it if the version of the assembly that we are trying to load matches the version/versions range written in the policy file. If it does, it will try to load the assembly with the version specified there. If no such policy file exists, it will try to load an assembly from the GAC. 
• If it will fail to find it in the GAC, it will start to search in the system’s search path. In web applications it will also include the application’s Bin directory in the search path. 

Question 22 – What is Multi-Module Assembly or Assembly Linker?
 We like to combine Hello.dll with GoodBye.dll and put them into a Private Assembly we call GreetAssembly.dll. DotNet> al /t:library /out:bin\Hellowroldassembly.dll bin\GoodDay.dll bin\GoodMorning.dll For this purpose we use the Assembly Linker. As /t (target) we generate here a library referencing the two other DLLs. This is also called a Multi-Module Assembly. Again, we store all the binaries in a bin folder. 

Question 23 – What is an Assembly Manifest? 
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) with Microsoft intermediate language (MSIL) code or in a standalone PE file that contains only assembly manifest information. 

Question 24 – What is a Metadata? 
Metadata is data that describes the state of the assembly and a detailed description of each type, attribute within the assembly. Metadata stores the following information: 
• Description of the assembly. 
• Identity (name, version, culture, public key).
• The types that are exported. 
• Other assemblies that this assembly depends on. 
• Security permissions needed to run. 
• Description of types. 
• Name, visibility, base class, and interfaces implemented. 
• Members (methods, fields, properties, events, nested types). 
• Attributes. 
• Additional descriptive elements that modify types and members. 

Question 25 – What is a Base class in .Net? 
Base class is the one from which the object and references are being inherited in .net 
• System.object is for .Net 
• System.Web.UI is for asp.net 

Question 26 – What is Full Assembly Reference? 
A full assembly reference includes the assembly’s text name, version, culture, and public key token (if the assembly has a strong name). A full assembly reference is required if you reference any assembly that is part of the common language runtime or any assembly located in the global assembly cache. 

Question 27 – What is Partial Assembly Reference? 
We can dynamically reference an assembly by providing only partial information, such as specifying only the assembly name. When you specify a partial assembly reference, the runtime looks for the assembly only in the application directory. 

Question 28 – What is an Assembly Qualified Name? 
An assembly qualified name isn’t the filename of the assembly; it’s the internal name of the assembly combined with the assembly version, culture, and public key, thus making it unique. 

Question 29 – What is ILDASM (Intermediate Language Disassembler)?
 It is a tool provided in C# to view and read the assembly content in manifest view. This tool is supplied along with the Visual Studio .NET you are using. It is also available along with .NET SDK. To access this tool, you have to run the ildasm.exe 

Question 30 – What is Global Assembly Cache? 
• The GAC stores assemblies specifically designated to be shared by several applications on the computer. 
• Assemblies deployed in the GAC must have a strong name. 
• When an assembly is added to the GAC, integrity checks are performed on all files that make up the assembly. The cache performs these integrity checks to ensure that an assembly has not been tampered with, for example, when a file has changed but the manifest does not reflect the change. 
• Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK or Use Windows Explorer to drag assemblies into the cache. 

Question 31 – What is an Attribute? 
Attributes are declarative tags in code that insert additional metadata into an assembly. Attributes are of Two types: 
• Predefined attributes such as Assembly Version, which already exist and accessed through Runtime Classes; 
• Custom attributes, which you write yourself by extending the System.Attribute class.
 • Example – Custom Attribute for entire assembly 1. using System; 2. [assembly : MyAttributeClass] class X {} 

Question 32 – What is Serialization & DeSerialization? 
It is a process of taking an object and converting into a form so that it can be transported across the network or can be persisted in the storage location. This storage location can be physical file, database or ASP.NET Cache. The form contains the state of the object so that by this format, we can construct the same object a later point in time, which is called De-serialization. When the object is subsequently de-serialized, an exact clone of the original object is created. Remoting and Web Services depend heavily on this process. 

Question 33 – Where Serialization is used? 
• Used to save session state in ASP.NET. 
• Copy objects to the Clipboard in Windows Forms 
 Remoting to pass objects by value from one application domain to another.

Question 34 – What are the types of Serialization available in .net? 
Serialization of 3 types and are as follows. 
• Binary Serialization : Light and compact used in Remoting 
• SOAP Serialization : interoperable use SOAP and used in web Services 
• XML Serialization : Custom Serialization 

Question 35 – What is Binary Serialization? 
Binary serialization is a mechanism which writes the data to the output stream such that it can be used to re-construct the object automatically. The term binary in its name implies that the necessary information that is required to create an exact binary copy of the object is saved onto the storage media. 

Question 36 – What are the Advantages & Disadvantages of Binary Serialization? 
Advantages: Object can be de-serialized from the same data you serialized it to. It has enhanced performance as it is faster and even more powerful in the sense that it provides support for complex objects, read only properties and even circular references. Disadvantage: It is not easily portable to another platform. 

Question 37 – What is SOAP Serialization? 
The SOAP protocol is ideal for communicating between applications that use heterogeneous architectures. In order to use SOAP serialization in .NET we have to add a reference to System.Runtime.Serialization.Formatters.Soap in the application. 

Question 38 – What are the Advantages of SOAP Serialization? 
The basic advantage of SOAP serialization is portability. The SoapFormatter serializes objects into SOAP messages or parses SOAP messages and extracts serialized objects from the message. 

Question 39 – What is a XML Serialization? 
XML serialization converts (serializes) the public fields and properties of an object or the parameters and returns values of methods, into an XML stream that conforms to a specific XML Schema definition language (XSD) document. XML serialization results in strongly typed classes with public properties and fields that are converted to a serial format (in this case, XML) for storage or transport. Because XML is an open standard, the XML stream can be processed by any application, as needed, regardless of platform.” Implementing XML Serialization in .Net is quite simple.

System.Collections.Generic in Dot Net

/Interface
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService" in both code and config file together.
[ServiceContract]
public interface IService
{

[OperationContract]
[FaultContract(typeof(MyReason))]
string GetData(int value);


}

public class MyReason
{
private string Reason;
public string MyCause { get; set; }
}

//class to implement interface

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data.SqlClient;
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service" in code, svc and config file together.
public class Service : IService
{
SqlConnection con;
string ret;
public string GetData(int r)
{
try
{
con = new SqlConnection("initial catalog=cac;data source=windows-pc\\sqlexpress;integrated security=yes");
SqlCommand cmd = new SqlCommand("select name from student where seat_no=" + r + "", con);
con.Open();
SqlDataReader rd = cmd.ExecuteReader();
bool b = rd.Read();
if (b == false)
{
ret = null;
}
else
{
ret = rd["name"].ToString();
}

}

catch (Exception e1)
{
MyReason m = new MyReason();
m.MyCause = "he has internal pain in stomach";
throw new FaultException<MyReason>(m);
}
finally
{
con.Close();

}

return ret;
}
}

//At Client Side
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ServiceModel;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
int s1 = Convert.ToInt32(TextBox1.Text);
ServiceReference1.ServiceClient s = new ServiceReference1.ServiceClient();
string y = s.GetData(s1);
if (y == null)
{
Label1.Text = "Rec not found";
}
else
{
Label1.Text = y;
}
}
catch (FaultException<ServiceReference1.MyReason> m)
{

Label1.Text = m.Detail.MyCause;
}
}
}
/