Answer - 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.
What does an assembly contain?
Answer - 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
Define private assembly and a shared assembly.
Answer - 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.
What are Satellite Assemblies?
Answer - Satellite assemblies provide an application the multilingual support. Satellite assemblies contain alternate sets of resources to be used in the application for different cultures.
What are Satellite Assemblies?
Answer - Satellite assemblies provide an application the multilingual support. Satellite assemblies contain alternate sets of resources to be used in the application for different cultures.
How do you create a resource-only assembly?
Answer - 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.
Explain how to retrieve resources using ResourceManager class.
Answer - 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.
Define Strong Name. How do you apply a strong name to assembly?
Answer - 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.
Define Global Assembly Cache.
Answer - 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.
How do you install assembly to the Global Assembly Cache?
Answer - 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
Explain the .Net Framework.
Answer - 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.
Describe the .Net Framework Architecture.
Answer - 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.
What are the components of the .Net Framework.
Answer - Class Loader, Compiler, Garbage Collection, Type checker, Debug engine, Exception Manager, Security engine, Thread manager, COM Marshallar, Class Library.
Explain the role of assembly in the .Net Framework.
Answer - .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.
Describe the GAC in the .Net Framework.
Answer - .Net Framework provides Global Assembly cache, a machine-wide cache. It stores shared assemblies that can be accessed by multiple languages.
Define Authentication and Authorization.
Answer - Authentication is the process of verifying user's identity. Authorization is the process of granting privilege to authenticated user. The user is validated using authenticated process and then the authorization process identifies if the user has access to a given resource. In ASP.NET, you can authenticate user in code or allow the user to be authenticated by other party such as MS Passport. You have two layer of authentication in ASP.NET i.e. IIS layer and ASP.net authentication process layer. IIS performs authentication if it is configured to do so. By default, IIS allows anonymous access which means all the users are authenticated. All the requests pass through IIS layer and then to ASP.NET authentication process. If any user requests IIS layer for anonymous access, the user is treated as authenticated and pass to ASP.NET process. ASP.NET checks if impersonation is enabled in the web configuaration file i.e. web.config file. If impersonation is enabled, ASP.net acts as though it were the authenticated user otherwise it process with its own configured account.
To enable the application to authenticate users,
you need to add
What is the authentication mode available in ASP.NET?
Answer - ASP.NET supports three authentication modes through the System.Web.Security namespace.
Windows Authentication
The windows authentication authenticates users based on their windows accounts. In short, it uses windows network security. It uses IIS to perform authentication.
Passport authentication
The Passport authentication uses Microsoft's passport service to authenticate users. The new user is directed to the Microsoft site where he can register his identity. This facilitates user to access multiple sites using single user name and password. You need to install the Passport SDK to enable the Passport classes in the System.Web.Security namespace.
Form authentication
The Form authentication collects user's credential and lets the application use own logic to authenticate users. The collected user's credential is validated using the list maintained by the application. The application maintains its own user list either using
How do you set authentication mode in the ASP.NET application?
Answer - You can set authentication mode using web.config file.
List out the difference between windows authentication and form authentication.
Answer - Windows authentication uses windows account whereas form authentication maintains its own user list. Windows authentication is best suited for the application which is meant for a corporate users whereas form authentication is preferable for the applications which have diversified users from several places.
User lists for windows authentication are found in
How do you impersonate the authenticated user in ASP.NET?
Answer - Impersonation means delegating one user identity to another user. In ASP.NET, the anonymous users impersonate the ASPNET user account by default. You can use
How do you provide secured communication in ASP.NET?
Answer - ASP.NET provides secured communication using Secure Sockets Layer. The application to use SSL need to have an encryption key called a server certificate configured in IIS. When a user requests a secured page, the server generates an encryption key for the user’s session. The encrypted response is then sent along with encryption key generated. In the client side, the response is then decrypted using same encryption key.
What is Constructor?
Answer - It is the first method that are called on instantiation of a type. It provides way to set default values for data before the object is available for use. Performs other necessary functions before the object is available for use.
What is Destructor?
Answer - It is called just before an object is destroyed. It can be used to run clean-up code. You can't control when a destructor is called since object clean up by common language runtime.
Define Abstract class in C#.NET.
Answer - Abstract class cannot be instantiated.
Same concept in C++ known as pure virtual method.
A class that must be inherited and have the methods over-ridden.
A class without any implementation.
Explain serialization?
Answer - Serialization is a process of converting an object into a stream of bytes. .Net has 2 serializers namely XMLSerializer and SOAP/BINARY Serializer. Serialization is maily used in the concept of .Net Remoting.
C#.Net support multiple inheritance, comment.
Answer - No, but we can use interface instead.
Can private virtual methods be overridden in C#.NET?
Answer - No, moreover, you cannot access private methods in inherited classes,
They have to be protected in the base class to allow any sort of access.
How to prevent your class from being inherited?
Answer - You can use keyword 'sealed' in the class definition to prevent class from being inherited.
List down difference between overriding and overloading.
Answer - When overriding, you change the method behavior for a derived class.
Overloading simply involves having a method with the same name within the class.
What does the keyword virtual mean in the method definition?
Answer - The method can be over-ridden.
How to allow class to be inherited, but prevent the method from being over-ridden?
Answer - You can do so by declaring the class public and making the method sealed.
When do we declare a class as abstract in C#.NET?
Answer - When at least one of the methods in the class is abstract.
Define Interface class in C#.NET.
Answer - It is an abstract class with public abstract methods with no implimentation.
Define Satellite Assembly.
Answer - When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.
Namespaces to create a localized application.
Answer - System.Globalization, System.Resources.
List out difference between the Debug class and Trace class.
Answer - Use debug class for debug builds, use Trace class for both debug and release builds.
What are three test cases you should go through in unit testing?
Answer - Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).
No comments:
Post a Comment