Frequently Asked .net Interview Questions Part – 7
Types Of Serialization
1. Binary Serialization –
preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application.
2. 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.
What Is Serialization?
It is 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 de-serialized, an exact clone of the original object is created.
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.
What Is Namespace?
It is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. Such a naming scheme is completely under control of the developer. This concept is not related to that of an assembly.
What Is Gac? How To Put Assembly In Gac?
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. Assemblies deployed in the global assembly cache must have a strong name.
When an assembly is added to the global assembly cache, 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.
To install a strong-named assembly into the global assembly cache At the command prompt, type the following command: gacutil I In this command, assembly name is the name of the assembly to install in the global assembly cache.
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. Assembly Major Version .Assembly Minor Version .Assembly Name
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 the 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.
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.
Example:
(“”System .Xml .Xml Document, System .Xml, Version =1.0.3300.0, Culture =neutral, PublicKey Token = b77 a5c561934 e089″”)
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.
We can make partial references to an assembly in your code one of the following ways:
-> Use a method such as System.Reflection.Assembly.Load and specify only a partial reference. The runtime checks for the assembly in the application directory.
-> Use the System.Reflection.Assembly.LoadWithPartialName method and specify only a partial reference. The runtime checks for the assembly in the application directory and in the global assembly cache.
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.
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
What Are The Types Of Assembly Available
1.Private-
The assembly is intended only for one application
2.Shared-
If the assembly is to be made into a Shared Assembly
3.Static-
These are the .NET PE files that you create at compile time.
4.Dynamic-
These are PE-formatted, in-memory assemblies
What Are Attributes?
Attributes are declarative tags in code that insert additional metadata into an assembly. There exist two types of attributes in the .NET
Framework:
Predefined attributes such as Assembly Version, which already exist and are accessed through the Runtime Classes; and 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 {}
What Is Manifest?
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 (Portable Executable) file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE (Portable Executable) file that contains only assembly manifest information.
What Is Jit Compiler
It is a compiler which converts MS IL code to Native Code (ie.. 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.
What Debugging Tools Come With The .net Sdk?
1.CorDBG –
command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch.
2.DbgCLR –
graphic debugger. Visual Studio .NET uses the DbgCLR
What’s The .net Collection Class That Allows An Element To Be Accessed Using A Unique Key?
HashTable
Ho We Can See Assembly Information?
We can see the assembly information using ILDASM Tool
What Is Private And Shared Assembly?
The assembly which is used only by a single application is called as private assembly. Thus the assembly is private to your application.Suppose that you are creating a general purpose DLL which provides functionality which will be used by variety of applications.
Now, instead of each client application having its own copy of DLL you can place the DLL in ‘global assembly cache’. Such assemblies are called as shared assemblies.
What Is Type Safety?
Type safe code can access only the memory locations that it has permission to execute. Type safe code can never access any private members of an object. Type safe code ensures that objects are isolated from each other.
What Is The Difference Between Datareader And Dataadapter?
1. Data Reader is read only forward only and much faster than DataAdapter.
2. If you use DataReader you have to open and close connection explicitly where as if you use DataAdapter the connection is automatically opened and closed.
3. DataReader is connection oriented where as Data Adapter is disconnected
What Is Func In .net 3.5?
Func is a delegate in .Net that returns a value.
The return type is specified using the TResult argument.
There are 5 versions of Func in .Net.
Func Func<T,TResult>
Func<T1,T2,TResult>
Func<T1,T2,T3,TResult>
Func<T1,T2,T3,T4,TResult>
What Is Action In C# 3.5?
Action is a built-in delegate which returns void.
There are 5 versions of Action
Action Action
Action<T1,T2>
Action<T1,T2,T3>
Action<T1,T2,T3,T4>
What Is The Advantage Of Mvc?
More Manageability, Multiple View Support, More unit testing compatibility.
Advantages Of Vb.net And C#
Advantages VB.NET :-
* Has support for optional parameters which makes COM interoperability much easy.
* With Option Strict off late binding is supported.Legacy VB functionalities can be used by using Microsoft.VisualBasic namespace.
* Has the WITH construct which is not in C#.
* The VB.NET part of Visual Studio .NET compiles your code in the background.
While this is considered an advantage for small projects, people creating very large projects have found that the IDE slows down considerably as the project gets larger.
Advantages of C#
* XML documentation is generated from source code but this is now been incorporated in Whidbey.
*Operator overloading which is not in current VB.NET but is been introduced in Whidbey.
* The using statement, which makes unmanaged resource disposal simple.
* Access to Unsafe code. This allows pointer arithmetic etc, and can improve performance in some situations. However, it is not to be used lightly, as a lot of the normal safety of C# is lost (as the name implies).This is the major difference that you can access unmanaged code in C# and not in VB.NET