.Net Interview Questions

Qus:- Explain the .Net Framework.

Ans:- The .Net framework allows infrastructural services to all the applications developed in .net compliant language. It is an engine that provides runtime services using its component like Common Runtime Language. It consists of two main components such as Common Language Runtime and Framework Class Library.



Qus:- Describe the .Net Framework Architecture. 

Ans:- The .Net Framework has two main components:
.Net Framework Class Library: It provides common types such as data types and object types that can be shared by all .Net compliant language.

The Common language Runtime: It provides services like code execution, type safety, security, thread management, interoperability services.


Qus:- What are the components of the .Net Framework?

Ans:- Class Loader, Compiler, Garbage Collection, Type checker, Debug engine, Exception Manager, Security engine, Thread manager, COM Marshallar, Class Library.


Qus:- Explain the role of assembly in the .Net Framework.

Ans:- .Net Framework keeps executable code or DLL in the form of assembly. .Net Framework maintains multiple versions of the application in the system through assembly. The assemblies have MSIL code and manifest that contains metadata. The metadata contains version information of the assembly.


Qus:- Describe the GAC in the .Net Framework. 

Ans:- .Net Framework provides Global Assembly cache, a machine-wide cache. It stores shared assemblies that can be accessed by multiple languages.


Explain GAC.

GAC stands for global assembly cache. It is an area of memory reserved to store the assemblies of all .NET applications that are running on a certain machine. It shares assemblies among multiple .NET applications. The assemblies must have a strong name and must be publicly shared to be installed in the GAC.


Qus:- What is the advantage of packaging over xcopy in .NET?

Ans:- The most trivial technique to publish a website is to simply copy your web application files to the production server and create a virtual directory there through xcopy command. With packaging it creates a self executable MSI which is very easy and convenient to deploy and install. This allows the end users to install a web application with ease. You could also include custom license needs, agreements, registry entries and other custom tasks such as installation folder etc for ease of the end users. The MSI can also be rolled out to many computers at once by the administrator which is a very big advantage.


Qus:- Define .Net Assembly.

Ans:- It is a primary unit of deployment in a Microsoft .NET Framework application. It is called as building block of an application which provides all required execution information to common language runtime.

An assembly perform following functions:
It contains IL code that gets executed by common language runtime.
It forms a security boundary.
An assembly is the unit at which permissions are requested and granted.
It ensures type safety by establishing name scope for types at the runtime.
It contains version information.
It allows side-by-side execution of multiple versions of same assembly.

Assemblies can be static or dynamic.
Static assemblies are created when the program is compiled using .Net compiler. It exists as PE file either in .exe or .dll. However, dynamic assemblies are created at runtime and run from the memory without getting saved on the disk.

Define Assembly.

An Assembly is a collection, either an executable (.exe) or a dynamic link library (.dll), that forms a logical unit of functionality and built to efficiently work together. .NET Framework can be used to compile assemblies.


Qus:- What does an assembly contain?

Ans:- An assembly contains following information:
Assembly manifest: Information about the assembly.
Type metadata: Information about the types.
IL Code
Resource files.

An assembly manifest contains the following information:

Identity of the assembly
Types and resources
Files
Security permissions


Qus:- Define private assembly and a shared assembly.

Ans:- A private assembly is stored in the application’s directory and used by a single application. A share assembly can be used by multiple applications and is stored in the Global assembly cache, a repository of assemblies maintained by the .Net Framework.

Qus:- What is a Satellite assembly?

Ans:- A satellite assembly contains resources specific to a given language.
With the help of these, the resources of different languages can be kept in different assemblies. However, at the runtime the chosen option generates the output in the desired language. The implementation code is kept different from the resource files that are used for conversion.


Qus:- What do you understand by side-by-site execution of assembly?

Ans:- This means multiple version of same assembly to run on the same computer. This feature enables to deploy multiple versions of the component.


Qus:- How do you create a resource-only assembly?

Ans:- Resources are nonexecutable data in an application and the data can be updated without recompiling application. Resource assemblies can be created as follows:
Add resource files to an empty project.
Built the project.
The resource will get compiled into assembly.


Qus:- Explain how to retrieve resources using ResourceManager class.

Ans:- ResourceManager class is used to retrieve resources at run time.
Create a ResourceManager with resource file name and the resource assembly as parameters.
After having created, you can use ResourceManager.GetString method to retrieve a string.
Use the ResourceManager.GetObject method to retrieve images and objects from a resource file.


Qus:- Define Strong Name. How do you apply a strong name to assembly?

Ans:- A strong name means generating public key in order to provide unique name to the assembly.
The name is used to provide global name to the assembly and allows it to be shared amongst several different applications.
The key generated include assembly's name, the version number, the developer's identity, and a hash number.
The developer's identity identifies the author of the assembly.
The hash checks if the assembly is tempered since it is created.
The key pair that defines the strong name is created using the Strong Name utility, Sn.exe.

To sign an assembly with a strong name

Create Key pair using the Strong Name utility, Sn.exe.
Open the AssemblyInfo file of your project.
Use the AssemblyKeyFileAttribute to specify the path to the key file for your project.
Build your assembly. The strong name will be generated and signed to the assembly.


Qus:- Define Global Assembly Cache. 

Ans:- Global Assembly Cache is the place holder for shared assembly. If an assembly is installed to the Global Assembly Cache, the assembly can be accessed by multiple applications. In order to install an assembly to the GAC, the assembly must have to be signed with strong name.

Qus:- How do you install assembly to the Global Assembly Cache?

Ans:- Followings are the steps to install assembly to the GAC.
Sign assembly with a strong name using strong name utility, sn.exe.
Open the AssemblyInfo file for your project.
Use the AssemblyKeyFileAttribute to specify the path to the key file for your project.
Build your assembly. Install the assembly to GAC by using gacutil utility e.g. gacutil -i abc.dll


Qus:- What is AL.EXE and RESGEN.EXE?

Ans:- Resgen.exe performs conversion of .txt / .restext files to .resources / .resx files and vice-versa. These (.resources/.resx) files can be embedded in a runtime binary executable or compiled into satellite assemblies.

Assembly Linker (Al.exe) generates a file that has an assembly manifest from modules or resource files. A module does not have an assembly manifest.

Qus:- What is code security? What are the types?

Ans:- Framework provides the security features to secure code from unauthorized users and unauthorized uses.
There are two types of code security:
Role based security: This authorizes user.
Code access security: This protects system resources from unauthorized calls.

Qus:- Define Principal object.

Ans:- The Principal object represents authenticated users. It contains information about user’s identity and role. You have PrincipalPermission object in .Framework that specifies user and its role. It has Demand method that checks the current user or Principal against the name and role specified in the PrincipalPermission.


Qus:- Define declarative and imperative security.

Ans:- Security checks can be applied imperatively or declaratively. Declarative security is applied by associating attribute declarations that specify a security action with classes or methods. Imperative security is applied by calling the appropriate methods of a Permission object that represents the Principal (for role-based security) or system resource (for code access security).


Qus:- What are the differences between declarative and imperative security.

Ans:- Declarative and imperative are the different syntax schemes used to implement security declarations in .NET Framework. In declarative security, attribute syntax is used. The security constraints are stored in the assembly at compile time. The disadvantage of declarative security is that there are tools which extract security requirements from the metadata in the assembly.

In imperative implementation, the attribute syntax is not used. It is implemented by writing the regular code to provide restrictions


Qus:- Define role-based security.

Ans:- Role-based security is to verify the role and/or identity of the current Principal object.


Qus:- Explain role-based and code based security.

Ans:- Based on the credentials of the user, the access is provided to the user.

Role-based authorization is provided by the CLR to an account. It mostly involves the code running with the privileges of the current user.

Code security is about granting and denying permissions from the permission sets.


Qus:- Explain code access security.

Ans:- Code access security protects code from unauthorized calls. You can prevent access to the system resources using Permission object. The permission object specifies user and its role. The demand method of permission object checks if specified user and role matches with the current user.


Qus:- What is Code group?

Ans:- Code groups represent collections of code and each code group has an associated set of permissions. 

0 comments:

Post a Comment