You are on page 1of 14

Define .Net Assembly.

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 applications 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 do you understand by side-by-site execution of assembly?


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

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

What is AL.EXE and RESGEN.EXE?


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.

Explain the concepts and capabilities of Assembly in .NET.


An assembly is a collection of files (dlls, exes), group of resources that help in creating a logical unit of functionality. It forms the basic building block for deployment, reusability and security issues.

It provides a CLR environment. It helps in maintaining security as it grants grant or denial of permissions. When an application starts only assemblies the application initially calls must be present. Assemblies can be either static or dynamic. Assemblies help in resolving versioning issues.

What is Manifest in .NET?


Manifest in .NET helps to understand the relation between the elements of the assemblies. It contains the metadata of assembly that helps to specify the versions, security and helps to resolved references to resources and classes. The Manifest can be stored as an .exe or .dll. Information in the assembly manifest can be changed using the assembly attributes like Trademark, copyright, Company and other information.

What is .Net Web Service?



Web service is the way to publish application's function on web that can be accessible to the rest of the world. Web services are the components that can be used by other applications ASP.NET offers easy way to develop web services, just precede the functions with a special WebMethod ()> attribute in order them to work as Web Service. Web services are discovered using UDDI directory services.

Web services are built on XML standard and use SOAP protocol that allows them to communicate across different platforms and programming languages. Web services easily manage to work across corporate firewalls as they use HTTP protocol which is firewall friendly. Web services platform elements are SOAP (Simple Object Access Protocol) UDDI (Universal Description, Discovery and Integration) WSDL (Web Services Description Language) The web services are built on internet standards that are not platform or language specific. The .Net framework provides in-built classes to build and consume web services. The components offered by web services are reusable. The examples of web service components can be shipment tracking, translation utility, weather forecasting, sports scores etc.

What is SOAP?
SOAP, Simple Object Access Protocol is a communication protocol, a way to structure data before transmitting it, is based on XML standard. It is developed to allow communication between applications of different platforms and programming languages via internet. It can use range of protocols such as HTTP, FTP, SMTP, Post office protocal 3(POP3) to carry documents. Http-Get, Http-Post works with name/value pair which means transferring complex object is not possible with these protocols, whereas SOAP serializes complex structure, such as ASP.NET DataSets, complex arrays, custom types and XML nodes before transmitting and thus allows exchange of complex objects between applications. Two components can easily communicate using Remote Procedure Calls protocol. But because of their compatibility and security issues, most of firewalls and proxy server block this type of messages. SOAP uses HTTP channel to transport which makes it widely accepted protocal over the internet.

What is WSDL?
WSDL stands for Web Ser vices Description Language, an XML-based language that describes Web services and how to access and locate them.

What is UDDI?
UDDI stands for Universal Description, Discovery and Integration. It is an open, Internet-based specification that offers directory service for storing information about web services.

What is XML Web Server?


Web Server is a program components that allows us to develop loosely coupled and platform independent application. It enables distributed applications to exchange messages using protocol like HTTP, XML, and SOAP. Since it uses XML based messaging, it enables heterogeneous applications to interoperate with each other.

Describe the Components that help locate and consume XML Web Service.
Directories This is the place to store published information about the Web Services. The UDDI specifications define guidelines for publishing information about the Web Services. Microsoft provides directory service which is located at http://uddi.microsoft.com. Discovery Using Discovery process, the client can know the location of Web Service. Client can locate documents that describe Web Service using WSDL. Description This component allows client know what operations to perform on an XML Web service. Wire Formats XML Web Service uses Wire Formats protocol to enable heterogeneous applications to interoperate. This protocol can be understood by any system who knows standard protocol like HTTP and SOAP.

Describe the process of communication between Client and Web Service.


To communicate with Web Service, Client application creates an object of Web Service Proxy Class. The proxy object provides access to all methods and properties of Web Service to client. The client calls a method on the proxy object. The Web Service infrastructure serializes the method call and arguments into the SOAP message and sends to web service. The web service executes the method and returns the value

which gets serialized and send over network. The message then received by client infrastucture, deserializes it and sends to the proxy object. The proxy object returns the value to the client application.

What are the components published while deploying of Web Service?


Web Application Directory <WebService>.asmx file <WebService>.disco file Web.Config file \Bin directory

Describe .disco file.


It is discovery document that contains links of resourses that describes web service and its location. It is written in WSDL and describes the capability of web service.

Describe the step to be followed to access web service by client.


Add a web reference to the web service in the client application, Generate a proxy class, Create an object of the proxy class, Access the Web service by using a proxy object.

What is code security? What are the types?


Answer - .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.

Define Principal object.


Answer - The Principal object represents authenticated users. It contains information about users 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.

Define declarative and imperative security.


Answer - 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).

Define role-based security.


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

Explain code access security.


Answer - 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.

What is Code group?


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

Define the use of Caspol.exe.


Answer - It is DOS command to view and alter code access security policy.

What is AppSetting Section in Web.Config file?


AppSetting section in the configuration file is a section that allows us to keep configurable and application wide settings (for e.g.: ConnectionString) that an application requires in order to perform the tasks properly. This helps in easy maintenance and deployment of the application. Web.confg: <appsettings> <add key="ConnectionString" value="(your connection string)" /> </appsettings> Code behind: string strConnection = ConfigurationSettings.AppSettings["ConnectionString"];

Difference between Server.Transfer and response.Redirect.


Following are the major differences between them:Server.Transfer

The browser is directly redirected to another page There is no round trip A Server transfer is possible within a website Information can be preserved in Server transfer through a parameter called preserveForm

response.Redirect

The browser is requested to redirect to some other page through a message. There is a round trip. Response redirect is possible within two websites too. A state can be maintained in Response redirect but has a lot of drawbacks

What is Authorization in ASP.NET?


Usually after a user is authenticated by means of a login, the process of authorization is followed where the decision is made whether a user should be granted access to a specific resource. There are 2 ways to authorize access to a given resource: URL authorization: URL authorization is performed by the UrlAuthorizationModule It maps users and roles to URLs in ASP.NET applications. File authorization: File authorization is performed by the FileAuthorizationModule. It checks the access control list of the .aspx or .asmx handler file to determine whether a user should have access to the file.

What is Authentication in ASP.NET?


The process of identifying a user through the use of an ID and a password is known as Authentication. The ASP.Net authentication providers are as follows: Windows Authentication Provider: It is in conjunction with Microsoft Internet Information Services (IIS) authentication to secure ASP.NET applications Forms Authentication Provider It is an application-specific login form which performs authentication using user code.

Passport Authentication provider: It is a centralized authentication service provided by Microsoft that offers a single login and core profile service for member sites.

Describe how the ASP.NET authentication process works.


ASP.NET runs inside the process of IIS due to which there are two authentication layers which exist in the system. First authentication happens at the IIS level and the second at ASP.NET level per the WEB.CONFIG file. Working: At first, IIS ensures that the incoming request is from an authenticated IP address. Otherwise the request is rejected. By default IIS allows anonymous access due to which requests are automatically authenticated. However, if this is changed, IIS performs its own user authentication too. ASP.net checks if impersonation is enabled if a request is passed to ASP.net by an authenticated user. If it is enabled, ASP.net acts itself as an authenticated user else it acts with its own configured account. Finally the OS resources are requested by the identity obtained from previous step. The user is granted the resources if the authentication is successful else the resources are denied. Resources can include ASP.net page, code access security features to extend authorization step to disk files, registry keys, etc.

Explain how authorization works in ASP.NET.


ASP.NET impersonation is controlled by entries in the applications web.config file. Though the default setting is no impersonation, it can be explicitly set using: <identity impersonate=false/> With ASP.NET wont perform any authentication and would run with its own privileges. The default is an unprivileged account named ASPNET. It can be changed a setting in the processModel section of the machine.config file. Disabling impersonation runs the entire request in the context of the account running ASP.NET (ASPNET account or the system account). The second possible setting is to turn on impersonation. <identity impersonate =true/> Here, ASP.NET takes on the identity IIS passes to it. If anonymous access is allowed in IIS, then the IUSR_ComputerName account will be impersonated otherwise ASP.NET will take the authenticated user credentials and make requests for resources. A particular identity can be specified to use all authenticated requests as: <identity impersonate=true username=DOMAIN\username password=password/> With this, the requests are made as the specified user. The password is assumed to be correct. The drawback is that you must embed the users password in the web.config file in plain text which is a security risk.

Explain the various authentication mechanisms in ASP.NET.


ASP.NET supports 3 authentication mechanisms: a. Windows Authentication: This is used for an intranet based application. Used to authenticate domain users within a network. By default windows authentication is used.

b. Form Authentication: Its a custom security based on roles and user accounts created specifically for an application. c. Passport Authentication: This is based on hotmail passport account.

Windows authentication.
If windows authentication mode is selected for an ASP.NET application, then authentication also needs to be configured within IIS since it is provided by IIS. IIS provides a choice for four different authentication methods: Anonymous: IIS doesnt perform any authentication. All are allowed to access the ASP.NET application. Basic: users must provide a windows username and password to connect. This information is plain text which makes this mode insecure. Digest: Users need to provide a password which is sent over the network. However in this case the password is hashed. It also requires that all users be using IE 5 or later versions. Windows integrated: passwords are not sent over the network. The application uses either the Kerberos or challenge/response protocols authenticate the user. Users need to be running IE 3.01 or later.

Passport authentication
Passport authentication provides authentication using Microsofts passport service. If passport authentication is configured and users login using passport then the authentication duties are off-loaded to the passport servers. Passport uses an encrypted cookie mechanism to indicate authenticated users. The passport users are considered authenticated while the rest are redirected to the passport servers to log in, after which they are redirected back to the site. Passport Software Development Kit can be downloaded and installed http:// msdn.microsoft.com/library/default.asp?url=/downloads/list/websrvpass.aps.

Forms authentication
Using form authentication, ones own custom logic can be used for authentication. ASP.NET checks for the presence of a special session cookie when a user requests a page for the application. Authentication is assumed if the cookie is present else the user is redirected to a web form.

Difference between authentication and authorization.


Authentication is the process of verifying the identity of a user. Authorization is process of checking whether the user has access rights to the system. Authorization is the process of allowing an authenticated user access to resources. Authentication always proceeds to Authorization.

What is event bubbling in .NET?


The passing of the control from the child to the parent is called as bubbling. Controls like DataGrid, Datalist, Repeater, etc can have child controls like Listbox, etc inside them. An event generated is passed on to the parent as an ItemCommand.

Question - What is Globalization and Localization in ASP.NET?

Answer - Localization is the process of adapting a software application for a specific locale. Globalization is the process of identifying the localizable resources of the application. You can provide support for Localization and

Globalization to the application using System.Globalization, System.Resources and System.Threading namespaces. The developer can define culture specific information using the System.Globalization namespace. The System.Resources namespace contains ResourceManager class that allows access to resources either from the main assembly or from the Satellite Assemblies. The System.Threading namespace supports for multithreaded programming. A web form has two culture values, Culture and UICulture. Culture value is used for date and number formatting and UICulture values are used to determine culture specific resources. You can set culture and UICulture values in the application as follows. Using <globalization> element of Web.Config. Using @Page directive in the Page. In Code-Behind Page e.g. Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture ("en-GB"); Thread.CurrentThread.CurrentUICulture=new CultureInfo("en-GB");

Question - What are the Globalization approaches possible in ASP.NET?

Answer - You can follow many approaches to have globalized application. You can create separate web application for each culture. You can create an application that can detect the users culture and adjusts output at run time using format specifiers and other tools. You can store culture-dependent strings in resource files that are compiled into satellite assemblies.
Question - Implementing ASP.NET Globalization.

Answer - Create resource files and compile them into a binary resource file. Create satellite assembly for each of the resource file for each culture. Store them in separate folders for easy access and replacement. Read the resources from the satellite assembly that is stored in different folders based on the locale and culture.
Question - Define Resource Files and Satellite Assemblies.

Answer - Resource Files: A resource file contains non-executable data that are used by the application and deployed along with it. Bitmaps, Icons etc are the examples of resource files. In ASP.NET, resource files are used to make application to support multiple cultures. You can create resource files each of them correspond to specific locale or culture of the application. You can use resgen utility to compile resource file into an assembly. You can create a satellite assembly from a compiled resource file using the AL utility provided with Microsoft .NET SDK. Advantages of resource files are as follows. It supports Globalization features in ASP.NET. You can have culture based information separate from the content and logic of the application. You can change resource content without effecting application's code. Satellite Assemblies Satellite Assemblies are the special kinds of assemblies that exist as DLL and contain culture-specific resources in a binary format. They store compiled localized application resources. They can be created using the AL utility and can be deployed even after deployment of the application. Satellite Assemblies encapsulate resources into binary format and thus make resources lighter and consume lesser space on the disk.

Note: Resource-only assemblies can contain any resource, such as images and text. Satellite assemblies contain only culture-specific resources.

Caching is defined as temporary storage of data for faster retrieval on subsequent requests. In ASP .NET 2.0, the caching support is integrated with the DataSource controls to cache data in a web page.

Question - Define Caching in ASP.NET.

Answer - Caching technique allows to store/cache page output or application data on the client. The cached information is used to serve subsequent requests that avoid the overhead of recreating the same information. This enhances performance when same information is requested many times by the user.
Question - Advantages of Caching

Answer - It increases performance of the application by serving user with cached output. It decreases server round trips for fetching data from database by persisting data in the memory. It greatly reduces overhead from server resources.
Question - What are the types of Caching in ASP.NET?

Answer - Caching in ASP.NET can be of the following types Page Output Caching Page Fragment Caching Data Caching
Question - Explain in brief each kind of caching in ASP.NET.

Answer - Page Output Caching This type of caching is implemented by placing OutputCache directive at the top of the .aspx page at design time. For example: <%@OutputCache Duration= "30" VaryByParam= "DepartmentId"%> The duration parameter specifies for how long the page would be in cache and the VaryByParam parameter is used to cache different version of the page. The VaryByParam parameter is useful when we require caching a page based on certain criteria. Page Fragment Caching This technique is used to store part of a Web form response in memory by caching a user control. Data Caching Data Caching is implemented by using Cache object to store and quick retrieval of application data. Cache object is just like application object which can be access anywhere in the application. The lifetime of the cache is equivalent to the lifetime of the application.
Question - Define Exception handling in ASP.NET.

Answer - Exceptions or errors are unusual occurrences that happen within the logic of an application. The CLR has provided structured way to deal with exceptions using Try/Catch block. ASP.NET also supports exception handling through server events such as Page_Error and Application_Error events.
Question - What are the ways of handling exceptions in ASP.NET?

Answer - There are three ways to handle exceptions in ASP.NET Try/catch/finally block. Using Events like Page_Error and Application_Error Using Custom error page
Question - Explain Try/catch block of exception handling.

Answer - You can enclose code in Try/Catch/Finally block. You can catch all exceptions in the catch block. The third part of this block is finally. It is executed irrespective of the fact that an exception has been raised.
Question - Define Error Events.

Answer - ASP.NET supports events that occur when any unhandled exception occurs in an application. These events are called as Error Events. ASP.NET provides two such events to handle exceptions

Page_Error : This is page event and is raised when any unhandled exception occur in the page. Application_Error: This is application event and is raised for all unhandled exceptions in the ASP.NET application and is implemented in global.asax

The Error events have two methods to handle the exception:



GetLastError: Returns the last exception that occurred on the server. ClearError: This method clear error and thus stop the error to trigger subsequent error event. .

Question - Define Custom Error Pages.


Answer - There are many errors that cant be trapped in the application code like page not found. To intercept this kind of error, ASP.NET supports Custom Error Pages that can be specified at two places:

Specify application-wide error page settings in the customErrors section of the Web.config file. Specify an error page for a specific Web form in the ErrorPage attribute of the Web forms @ Page directive

Question - Why is exception handling important for an application?


Answer - .Exception handling is used to prevent application from being stuck due to unusual occurrences. If the exceptions are handled properly, the application will never get terminated abruptly.

Question - When can you use tracing with exception handling?


Answer - You can use tracing with exception handling to log unanticipated exception to the trace log. The log file can be used to diagnose unanticipated problems and thus can be corrected. ASP.NET 2.0 introduces a new concept known as master pages, in which a common base master file contains the common look and feel and standard behavior for all the pages in your application. Once the common content is placed in the master page, the content pages (child pages) can inherit content from the master pages apart from adding their content to the final output..........

Question - What is Master Page in ASP.NET?

Answer - A Master page offers a template for one or more web forms. It defines placeholders for the content, which can be overridden by the content pages. The content pages contains only content. When users request the content page, ASP.NET merges the layout of the master page with the content of the content page and produce output.
Question - Advantages of using Master Page in ASP.NET

Answer - Master pages enables consistent and standardized layout to the website. You can make layout changes of the site in the master page instead of making change in the pages. It is very easy to implement.
Question - Define Multiple Master Page.

Answer - In ASP.NET, you can have multiple master pages each for a different purpose. You can provide users several layout options using Multiple Master Page. You can define Master Page at multiple places in the web application. You can specify page-level using the @Page dierective. You can specify using the Web.config. Remember that the definition closest to the user wins that means page-level definition supersedes site-level definition.
Question - How do you create Master Page?

Answer - Steps to create Master Page Right-click your web project in the Solution Explorer window Select Add New Item. Select the Master Page item type from the Add New Item dialog. Following is an example of Master Page and a Content Page. <%@ Master %> <html> <body> <Title>Title of the Pages</Title> <asp:ContentPlaceHolder id="Content1" runat="server"> </asp:ContentPlaceHolder> </body> </html> This is simple HTML page that serves template for other pages. The @ Master directive at the top of the page defines that the page is Master Page. A placeholder tag <asp:ContentPlaceHolder> is overridden by the content page to place the content. You can have many placeholders tag each of them with different id. Content Page Example %@ Page MasterPageFile="master1.master" %> <asp:Content ContentPlaceHolderId="Content1" runat="server"> <h1>ASP Interview Questions</h1> </asp:Content> When you request this page, ASP.NET merges layout specified in the Master Page and content of content page to produce page result.
Question - Define Session, SessionId and Session State in ASP.NET.

Answer - A session is the duration of connectivity between a client and a server application.

SessionId is used to identify request from the browser. By default, value of SessionId is stored in a cookie. You can configure the application to store SessionId in the URL for a "cookieless" session.
Question - What is Session Identifier?

Answer - Session Identifier is used to identify session. It has SessionID property. When a page is requested, browser sends a cookie with a session identifier. This identifier is used by the web server to determine if it belongs to an existing session. If not, a Session ID (120 - bit string) is generated by the web server and sent along with the response.
Question - Advantages and disadvantages of using Session State.

Answer - The advantages of using session state are as follows: It is easy to implement. It ensures data durability, since session state retains data even if ASP.NET work process restarts as data in Session State is stored in other process space. It works in the multi-process configuration, thus ensures platform scalability. The disadvantages of using session state are: Since data in session state is stored in server memory, it is not advisable to use session state when working with large sum of data. Session state variable stays in memory until you destroy it, so too many variables in the memory effect performance.

Question - What are the Session State Modes? Define each Session State mode supported by ASP.NET.

Answer - ASP.NET supports three Session State modes.



InProc State Server SQL Server

InProc Mode This mode stores the session data in the ASP.NET worker process. This is the fastest among all of the storage modes. This mode effects performance if the amount of data to be stored is large. If ASP.NET worker process recycles or application domain restarts, the session state will be lost. State Server mode In this mode, the session state is serialized and stored in memory in a separate process. State Server can be maintained on a different system. State Server mode involves overhead since it requires serialization and de-serialization of objects. State Server mode is slower than InProc mode as this stores data in an external process. SQL Server Mode In this storage mode, the Session data is serialized and stored in a database table in the SQL Server database. This is reliable and secures storage of a session state. This mode can be used in the web farms. It involves overhead in serialization and de-serialization of the objects. SQL Server is more secure than the InProc or the State server mode.
Explain how to access ViewState value of this page in the next page.

PreviousPage property is set to the page property of the nest page to access the viewstate value of the page in the next page. Page poster = this.PreviousPage; Once that is done, a control can be found from the previous page and its state can be read. Label posterLabel = poster.findControl("myLabel"); string lbl = posterLabel.Text;

What are the concepts of DISPOSE method?


Dispose method belongs to IDisposable interface. It is used to free unmanaged resources like files, network connection etc. it manages and handles this by an instance of the class that implements this interface. Dispose methods must be called explicitly and hence the any object using IDisposable must also implement finalizer to free resources in situations wherein Dispose is not called. Multiple calls to dispose method must be ignored when called once. The objects disposable methods must be called in the order of containment.

What is Finalize method in .NET?


Object.Finalize method in .NET is typically used to clean and release unmanaged resources like OS files, window etc. Even though Garbage collector in .NET has the ability to determine the life time of such objects, however, with no knowledge how to clean them. The Finalize method allows an object to clean up such unmanaged resources when the garbage collector wishes to reclaim the memory. However, Finalize method should be avoided until necessary as it affects the performance because reclaiming the memory used by objects with Finalize methods requires at least two garbage collections.

Similarities and difference between Class and structure in .NET.


Similarities:

Both Class and Structures can have methods, variables and objects. Both can have constructor. Both are user defined types.

Differences:

Structure being value type, the variables cannot be assigned to NULL. On the other hand, classes being reference type, a class variable can be assigned to NULL. Structure is allocated on a stack when instantiated, while Class is allocated on a heap. When a method is passed to a class, pass by reference is used. Pass by value is used for struts. A class can have a destructor.

What is a CLR (Common Language Runtime)?


Often there is a need for different languages to communicate with each other at run time. For e.g. A class may be written in one language and its derived class may be written in a different language. Common Language Runtime is a run time environment for .NET. These different languages are integrated and can communicate easily because language compilers and tools that target the runtime use a common type system defined by the runtime. Features or Functionalities offered by CLR:-

Garbage collection for managing life of objects. Enables Cross language inheritance as explained in example above. Syntax and keywords similar to C and C++

Explain the concepts of CTS and CLS(Common Language Specification).


CTS When different languages are integrated and want to communicate, it is certain that the languages have their own data types and different declaration styles. CTS define how these different variables are declared and used in run time. E.g. VB offers an Integer data type while C++ offers long data type. Using CTS, these data types are converted to System32 which itself a data type of CLS. CLS

Any language(s) that intend to use the Common Language Infrastructure needs to communicate with other CLS-Compliant language. This communication is based on set of rules laid by CLS. These rules define a subset of CTS.

What is connection pooling and what is the maximum Pool Size in ADO.NET Connection String?
A connection pool is created when a connection is opened the first time. The next time a connection is opened, the connection string is matched and if found exactly equal, the connection pooling would work. Otherwise, a new connection is opened, and connection pooling won't be used. Maximum pool size is the maximum number of connection objects to be pooled. If the maximum pool size is reached, then the requests are queued until some connections are released back to the pool. It is therefore advisable to close the connection once done with it. Connection pooling in ADO.NET - June 06, 2009 at 10:30 AM by Shuchi Gauri

What is connection pooling and what is the maximum Pool Size in ADO.NET Connection String?
Connection pooling is a method of reusing the active database connections instead of creating new ones every time the user request one. Connection pool manager keeps track of all the open connections. When a new request comes in, the pool manager checks if there exists any unused connections and returns one if available. If all connections are busy and the maximum pool size has not been reached, a new connection is formed and added to the pool. And if the max pool size is reached, then the requests gets queued up until a connection in the pool becomes available or the connection attempt times out. Connection pooling behavior is controlled by the connection string parameters. The following are four parameters that control most of the connection pooling behavior: Default max pool size is 100.

Can you explain how to enable and disable connection pooling?


Set Pooling=true. However, it is enabled by default in .NET. To disable connection pooling set Pooling=false in connection string if it is an ADO.NET Connection. If it is an OLEDBConnection object set OLEDB Services=-4 in the connection string. Enable and disable connection pooling in ADO.NET - June 06, 2009 at 10:30 AM by Shuchi Gauri

Can you explain how to enable and disable connection pooling?


To enable connection pooling: SqlConnection myConnection = new SqlConnection(@"Data Source=(local)\SQLEXPRESS;Initial Catalog=TEST;Integrated Security=SSPI;"); This has connection pooling on by default To disable connection pooling: SqlConnection myConnection = new SqlConnection(@"Data Source=(local)\SQLEXPRESS;Initial Catalog=TEST;Integrated Security=SSPI;Pooling=false;");

You might also like