Vous êtes sur la page 1sur 40

Q::Describe the role of inetinfo.exe, aspnet_isapi.dll and aspnet_wp.exe in the page loading process ? A:: inetinfo.

exe is the Microsoft IIS server running, handling ASP.NET requests among other things. When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request to the actual worker process aspnet_wp.exe. Q:: What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? A:: Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the clients browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the users browser to another page or site. This perform as a trip back to the client where the clients browser is redirected to the new page. The users browser history list is updated to reflect the new address. Q:: Should user input data validation occur server-side or client-side? Why? A;; All user input data validation should occur on the server at a minimum. Additionally, client-side validation can be performed where deemed appropriate and feasable to provide a richer, more responsive experience for the user. Q:: What is the Global.asax used for? A:: The Global.asax (including the Global.asax.cs file) is used to implement application and session level events. Q:: Can you explain the difference between an ADO.NET Dataset and an ADO Recordset? A:: Valid answers are: A DataSet can represent an entire relational database in memory, complete with tables, relations, and views. A DataSet is designed to work without any continuing connection to the original data source. Data in a DataSet is bulk-loaded, rather than being loaded on demand. Theres no concept of cursor types in a DataSet. DataSets have no current record pointer You can use For Each loops to move through the data. You can store many edits in a DataSet, and write them to the original data source in a single operation. Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.

Q:: What are the Application_Start and Session_Start subroutines used for? A:: This is where you can set the specific variables for the Application and Session objects. Q:: Can you explain what inheritance is and an example of when you might use it? A:: When you want to inherit (use the functionality of) another class. Example: With a base class named Employee, a Manager class could be derived from the Employee base class Q:: Whats the difference between Response.Write() and Response.Output.Write()? A:: Response.Output.Write() allows you to write formatted output. Q:: What methods are fired during the page load? A:: Init() - when the page is instantiated Load() - when the page is loaded into server memory PreRender() - the brief moment before the page is displayed to the user as HTML Unload() - when page finishes loading. Q:: Whats a bubbled event? A:: When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their event handlers, allowing the main DataGrid event handler to take care of its constituents. Q:: Suppose you want a certain ASP.NET function executed on MouseOver for a certain button. Where do you add an event handler? A:: Add an OnMouseOver attribute to the button. Example: btnSubmit.Attributes.Add(onmouseover,someClientCodeHere();); Q:; Whats an assembly? A:: Assemblies are the building blocks of the .NET framework. Q:: Describe the difference between inline and code behind.

A:: Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page Q:: Explain what a diffgram is, and a good use for one? A:: The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service. Q:: Whats MSIL, and why should my developers need an appreciation of it if at all? A:: MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL. MSIL also allows the .NET Framework to JIT compile the assembly on the installed computer. Q:: Which method do you invoke on the DataAdapter control to load your generated dataset with data? A:: The Fill() method. Q:: Can you edit data in the Repeater control? A:: No, it just reads the information from its data source. Q:: What is ViewState? A:: ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used to retain the state of server-side objects between post backs. Q:: What is the lifespan for items stored in ViewState? A:: Item stored in ViewState exist for the life of the current page. This includes postbacks (to the same page). Q:: Can a user browsing my Web site read my Web.config or Global.asax files? A:: No. The section of Machine.config, which holds the master configuration settings for ASP.NET, contains entries that map ASAX files, CONFIG files, and selected other file types to an HTTP handler named HttpForbiddenHandler, which fails attempts to retrieve the associated file. You can modify it by editing Machine.config or including an section in a local Web.config file.

Q:: Is it necessary to lock application state before accessing it? A:: Only if youre performing a multistep update and want the update to be treated as an atomic operation. Heres an example: Application.Lock (); Application[ItemsSold] = (int) Application[ItemsSold] + 1; Application[ItemsLeft] = (int) Application[ItemsLeft] - 1; Application.UnLock (); By locking application state before updating it and unlocking it afterwards, you ensure that another request being processed on another thread doesnt read application state at exactly the wrong time and see an inconsistent view of it. If I update session state, should I lock it, too? Are concurrent accesses by multiple requests executing on multiple threads a concern with session state? Concurrent accesses arent an issue with session state, for two reasons. One, its unlikely that two requests from the same user will overlap. Two, if they do overlap, ASP.NET locks down session state during request processing so that two threads cant touch it at once. Session state is locked down when the HttpApplication instance thats processing the request fires an AcquireRequestState event and unlocked when it fires a ReleaseRequestState event. Q:: How do I send e-mail from an ASP.NET application? A:: MailMessage message = new MailMessage (); message.From = ; message.To = ; message.Subject = Scheduled Power Outage; message.Body = Our servers will be down tonight.; SmtpMail.SmtpServer = localhost; SmtpMail.Send (message); MailMessage and SmtpMail are classes defined in the .NET Framework Class Librarys System.Web.Mail namespace. Due to a security change made to ASP.NET just before it shipped, you need to set SmtpMails SmtpServer property to localhost even though localhost is the default. In addition, you must use the IIS configuration applet to enable localhost (127.0.0.1) to relay messages through the local SMTP service. Q:: How does dynamic discovery work? A:: ASP.NET maps the file name extension VSDISCO to an HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files and returns a dynamically generated DISCO document. A client who requests a VSDISCO file gets back what appears to be a static DISCO document. Note that VSDISCO files are disabled in the release version of ASP.NET. You can reenable them by uncommenting the line in the section of

Machine.config that maps *.vsdisco to System.Web.Services.Discovery.DiscoveryRequestHandler and granting the ASPNET user account permission to read the IIS metabase. However, Microsoft is actively discouraging the use of VSDISCO files because they could represent a threat to Web server security. Q:: What does AspCompat=true mean and when should I use it? A:: AspCompat is an aid in migrating ASP pages to ASPX pages. It defaults to false but should be set to true in any ASPX file that creates apartmentthreaded COM objectsthat is, COM objects registered ThreadingModel=Apartment. That includes all COM objects written with Visual Basic 6.0. AspCompat should also be set to true (regardless of threading model) if the page creates COM objects that access intrinsic ASP objects such as Request and Response. The following directive sets AspCompat to true: <%@ Page AspCompat=true %> Setting AspCompat to true does two things. First, it makes intrinsic ASP objects available to the COM components by placing unmanaged wrappers around the equivalent ASP.NET objects. Second, it improves the performance of calls that the page places to apartment- threaded COM objects by ensuring that the page (actually, the thread that processes the request for the page) and the COM objects it creates share an apartment. AspCompat=true forces ASP.NET request threads into single-threaded apartments (STAs). If those threads create COM objects marked ThreadingModel=Apartment, then the objects are created in the same STAs as the threads that created them. Without AspCompat=true, request threads run in a multithreaded apartment (MTA) and each call to an STAbased COM object incurs a performance hit when its marshaled across apartment boundaries. Do not set AspCompat to true if your page uses no COM objects or if it uses COM objects that dont access ASP intrinsic objects and that are registered ThreadingModel=Free or ThreadingModel=Both. Q:: What does the EnableViewState property do? Why would I want it on or off? A:: It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in viewstate. Q:: What are the different types of Session state management options available with ASP.NET? A:: ASP.NET provides In-Process and Out-of-Process state management. InProcess stores the session in memory on the web server. This requires the a

sticky-server (or no load-balancing) so that the user is always reconnected to the same web server. Out-of-Process Session state management stores data in an external data source. The external data source may be either a SQL Server or a State Server service. Out-of-Process state management requires that all objects stored in session are serializable. Q:: What is CLS (Common Language Specificaiton)? A:: It provides the set of specificaiton which has to be adhered by any new language writer / Compiler writer for .NET Framework. This ensures Interoperability. For example: Within a ASP.NET application written in C#.NET language, we can refer to any DLL written in any other language supported by .NET Framework. As of now .NET Supports around 32 languages. Q:: What is CTS (Common Type System)? A:: It defines about how Objects should be declard, defined and used within .NET. CLS is the subset of CTS. Q:: What is Boxing and UnBoxing? A:: Boxing is implicit conversion of ValueTypes to Reference Types (Object). UnBoxing is explicit conversion of Reference Types (Object) to its equivalent ValueTypes. It requires type-casting. Q:: What is the difference between Value Types and Reference Types? A:: Value Types uses Stack to store the data where as the later uses the Heap to store the data. Q:: What are the different types of assemblies available and their purpose? A:: Private, Public/shared and Satellite Assemblies. Private Assemblies : Assembly used within an application is known as private assemblies. Public/shared Assemblies : Assembly which can be shared across applicaiton is known as shared assemblies. Strong Name has to be created to create a shared assembly. This can be done using SN.EXE. The same has to be registered using GACUtil.exe (Global Assembly Cache). Q:: What are user controls and custom controls?

A:: Custom controls: A control authored by a user or a third-party software vendor that does not belong to the .NET Framework class library. This is a generic term that includes user controls. A custom server control is used in Web Forms (ASP.NET pages). A custom client control is used in Windows Forms applications. User Controls: In ASP.NET: A user-authored server control that enables an ASP.NET page to be re-used as a server control. An ASP.NET user control is authored declaratively and persisted as a text file with an .ascx extension. The ASP.NET page framework compiles a user control on the fly to a class that derives from the System.Web.UI.UserControl class. Q:: What are the validation controls? A:: A set of server controls included with ASP.NET that test user input in HTML and Web server controls for programmer-defined requirements. Validation controls perform input checking in server code. If the user is working with a browser that supports DHTML, the validation controls can also perform validation using client script. Q:: What is view state and use of it? A:: The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested for the first time versus when the form is posted (sent to the server), which allows you to program accordingly. Q:: What methods are fired during the page load? A:: Init() When the page is instantiated, Load() - when the page is loaded into server memory,PreRender () - the brief moment before the page is displayed to the user as HTML, Unload() - when page finishes loading. Q:: What are the different types of caching? A:: Caching is a technique widely used in computing to increase performance by keeping frequently accessed or expensive data in memory. In context of web application, caching is used to retain the pages or data across HTTP requests and reuse them without the expense of recreating them. ASP.NET has 3 kinds of caching strategies Output Caching, Fragment Caching, Data Caching. Output Caching: Caches the dynamic output generated by a request. Some times it is useful to cache the output of a website even for a minute, which will result in a better performance. For caching the whole page the page should have OutputCache directive.<%@ OutputCache Duration=60 VaryByParam=state %> Fragment Caching: Caches the portion of the page generated by the

request. Some times it is not practical to cache the entire page, in such cases we can cache a portion of page<%@ OutputCache Duration=120 VaryByParam=CategoryID;SelectedID%> Data Caching: Caches the objects programmatically. For data caching asp.net provides a cache object for eg: cache[States] = dsStates; Q:: What do you mean by authentication and authorization? A:: Authentication is the process of validating a user on the credentials (username and password) and authorization performs after authentication. After Authentication a user will be verified for performing the various tasks, Its access is limited it is known as authorization. Q:: What are different types of directives in .NET? A:: @Page: Defines page-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .aspx files <%@ Page AspCompat=TRUE language=C# %> @Control:Defines control-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .ascx files. <%@ Control Language=VB EnableViewState=false %> @Import: Explicitly imports a namespace into a page or user control. The Import directive cannot have more than one namespace attribute. To import multiple namespaces, use multiple @Import directives. <% @ Import Namespace=System.web %> @Implements: Indicates that the current page or user control implements the specified .NETframework interface. <%@ Implements Interface= System.Web.UI.IPostBackEventHandler %> @Register: Associates aliases with namespaces and class names for concise notation in custom server control syntax.<%@ Register Tagprefix=Acme Tagname=AdRotator xsrc=AdRotator.ascx %> @Assembly: Links an assembly to the current page during compilation, making all the assemblys classes and interfaces available for use on the page. <%@ Assembly Name=MyAssembly %> <%@Assembly xsrc=MySource.vb %> @OutputCache: Declaratively controls the output caching policies of an ASP.NET page or a user control contained in a page<%@ OutputCache Duration=#ofseconds Location=Any | Client | Downstream | Server | None Shared=True | False VaryByControl=controlname VaryByCustom=browser | customstring VaryByHeader=headers VaryByParam=parametername %>

@Reference: Declaratively indicates that another user control or page source file should be dynamically compiled and linked against the page in which this directive is declared. Q:: How do I debug an ASP.NET application that wasnt written with Visual Studio.NET and that doesnt use code-behind? A:: Start the DbgClr debugger that comes with the .NET Framework SDK, open the file containing the code you want to debug, and set your breakpoints. Start the ASP.NET application. Go back to DbgClr, choose Debug Processes from the Tools menu, and select aspnet_wp.exe from the list of processes. (If aspnet_wp.exe doesnt appear in the list,check the Show system processes box.) Click the Attach button to attach to aspnet_wp.exe and begin debugging. Be sure to enable debugging in the ASPX file before debugging it with DbgClr. You can enable tell ASP.NET to build debug executables by placing a <%@ Page Debug=true %> statement at the top of an ASPX file or a statement in a Web.config file. Q:: Explain the differences between Server-side and Client-side code? A:: Server side scripting means that all the script will be executed by the server and interpreted as needed. ASP doesnt have some of the functionality like sockets, uploading, etc. For these you have to make a custom components usually in VB or VC++. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Download time, browser compatibility, and visible code - since JavaScript and VBScript code is included in the HTML page, then anyone can see the code by viewing the page source. Also a possible security hazards for the client computer. Q:: What are ASP.NET Web Forms? How is this technology different than what is available though ASP? A:: Web Forms are the heart and soul of ASP.NET. Web Forms are the User Interface (UI) elements that give your Web applications their look and feel. Web Forms are similar to Windows Forms in that they provide properties, methods, and events for the controls that are placed onto them. However, these UI elements render themselves in the appropriate markup language required by the request, e.g. HTML. If you use Microsoft Visual Studio .NET, you will also get the familiar drag-and-drop interface used to create your UI for your Web application. Q:: How can you provide an alternating color scheme in a Repeater control?

A:: AlternatingItemTemplate Like the ItemTemplate element, but rendered for every other row (alternating items) in the Repeater control. You can specify a different appearance for the AlternatingItemTemplate element by setting its style properties. Q:: What event handlers can I include in Global.asax? A:: Application_Start,Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed, Application_EndRequest, Application_Error, Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute, Application_PreSendRequestContent, Application_PreSendRequestHeaders, Application_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache, Session_Start,Session_End You can optionally include On in any of method names. For example, you can name a BeginRequest event handler.Application_BeginRequest or Application_OnBeginRequest.You can also include event handlers in Global.asax for events fired by custom HTTP modules.Note that not all of the event handlers make sense for Web Services (theyre designed for ASP.NET applications in general, whereas .NET XML Web Services are specialized instances of an ASP.NET app). For example, the Application_AuthenticateRequest and Application_AuthorizeRequest events are designed to be used with ASP.NET Forms authentication. Q:: What is different b/w webconfig.xml & Machineconfig.xml A:: Web.config & machine.config both are configuration files.Web.config contains settings specific to an application where as machine.config contains settings to a computer. The Configuration system first searches settings in machine.config file & then looks in application configuration files.Web.config, can appear in multiple directories on an ASP.NET Web application server. Each Web.config file applies configuration settings to its own directory and all child directories below it. There is only Machine.config file on a web server. If Im developing an application that must accomodate multiple security levels though secure login and my ASP.NET web appplication is spanned across three web-servers (using round-robbin load balancing) what would be the best approach to maintain login-in state for the users? Use the state server or store the state in the database. This can be easily done through simple setting change in the web.config. StateConnectionString=tcpip=127.0.0.1:42424 sqlConnectionString=data source=127.0.0.1; user id=sa; password= cookieless=false timeout=30 /> You can specify mode as stateserver or sqlserver. Where would you use an iHTTPModule, and what are the limitations of any approach you might take in implementing one

One of ASP.NETs most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and postprocessing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a custom HTTP module. Q:: How do you create a permanent cookie? A:: Permanent cookies are available until a specified expiration date, and are stored on the hard disk.So Set the Expires property any value greater than DataTime.MinValue with respect to the current datetime. If u want the cookie which never expires set its Expires property equal to DateTime.maxValue. Q:: Should validation (did the user enter a real date) occur serverside or client-side? Why? A:: It should occur both at client-side and Server side.By using expression validator control with the specified expression ie.. the regular expression provides the facility of only validatating the date specified is in the correct format or not. But for checking the date where it is the real data or not should be done at the server side, by getting the system date ranges and checking the date whether it is in between that range or not. Q:: What does the EnableViewState property do? Why would I want it on or off? A:: Enable ViewState turns on the automatic state management feature that enables server controls to re-populate their values on a round trip without requiring you to write any code. This feature is not free however, since the state of a control is passed to and from the server in a hidden form field. You should be aware of when ViewState is helping you and when it is not. For example, if you are binding a control to data on every round trip, then you do not need the control to maintain its view state, since you will wipe out any re-populated data in any case. ViewState is enabled for all server controls by default. To disable it, set the EnableViewState property of the control to false. Q:: What are the advantages and disadvantages of viewstate? A:: The primary advantages of the ViewState feature in ASP.NET are: 1. Simplicity. There is no need to write possibly complex code to store form data between page submissions. 2. Flexibility. It is possible to enable, configure, and disable ViewState on a control-by-control basis, choosing to persist the values of some fields but not others.

There are, however a few disadvantages that are worth pointing out: 1. Does not track across pages. ViewState information does not automatically transfer from page to page. With the session approach, values can be stored in the session and accessed from other pages. This is not possible with ViewState, so storing data into the session must be done explicitly. 2. ViewState is not suitable for transferring data for back-end systems. That is, data still has to be transferred to the back end using some form of data object. Q:: What method do you use to explicitly kill a user s session? A;; You can dump (Kill) the session yourself by calling the method Session.Abandon. ASP.NET automatically deletes a users Session object, dumping its contents, after it has been idle for a configurable timeout interval. This interval, in minutes, is set in the section of the web.config file. The default is 20 minutes. Q:: How do you turn off cookies for one page in your site? A:: Use Cookie.Discard property, Gets or sets the discard flag set by the server. When true, this property instructs the client application not to save the Cookie on the users hard disk when a session ends. Q:: Which two properties are on every validation control? A:: We have two common properties for every validation controls 1. Control to Validate, 2. Error Message Q:: How do you create a permanent cookie? A:: Permanent cookies are the ones that are most useful. Permanent cookies are available until a specified expiration date, and are stored on the hard disk. The location of cookies differs with each browser, but this doesnt matter, as this is all handled by your browser and the server. If you want to create a permanent cookie called Name with a value of Nigel, which expires in one month, youd use the following code Response.Cookies (Name) = Nigel Response.Cookies (Name). Expires = DateAdd (m, 1, Now ()) Q:: How do you register JavaScript for webcontrols ? A:: You can register javascript for controls using Attribtues.Add(scriptname,scripttext) method. Q:: When do you set ?

A:: Identity is a webconfig declaration under System.web, which helps to control the application Identity of the web applicaton. Which can be at any level (Machine,Site, application, subdirectory , or page) , attribute impersonate with true as value specifies that client impersonation is used. Q:: What are different templates available in Repeater,DataList and Datagrid ? A:: Templates enable one to apply complicated formatting to each of the items displayed by a control.Repeater control supports five types of templates.HeaderTemplate controls how the header of the repeater control is formatted.ItemTemplate controls the formatting of each item displayed.AlternatingItemTemplate controls how alternate items are formatted and the SeparatorTemplate displays a separator between each item displyed.FooterTemplate is used for controlling how the footer of the repeater control is formatted.The DataList and Datagrid supports two templates in addition to the above five.SelectedItem Template controls how a selected item is formatted and EditItemTemplate controls how an item selected for editing is formatted. Q:: What is ViewState ? and how it is managed ? A:: ASP.NET ViewState is a new kind of state service that developers can use to track UI state on a per-user basis. Internally it uses an an old Web programming trick-roundtripping state in a hidden form field and bakes it right into the page-processing framework.It needs less code to write and maintain state in your Web-based forms. Q:: What is validationsummary server control?where it is used? A:: The ValidationSummary control allows you to summarize the error messages from all validation controls on a Web page in a single location. The summary can be displayed as a list, a bulleted list, or a single paragraph, based on the value of the DisplayMode property. The error message displayed in the ValidationSummary control for each validation control on the page is specified by the ErrorMessage property of each validation control. If the ErrorMessage property of the validation control is not set, no error message is displayed in the ValidationSummary control for that validation control. You can also specify a custom title in the heading section of the ValidationSummary control by setting the HeaderText property. You can control whether the ValidationSummary control is displayed or hidden by setting the ShowSummary property. The summary can also be displayed in a message box by setting the ShowMessageBox property to true. Q:: What are the various ways of securing a web site that could prevent from hacking etc .. ?

A:: 1) Authentication/Authorization 2) Encryption/Decryption 3) Maintaining web servers outside the corporate firewall. etc., Q:: What is the difference between in-proc and out-of-proc? A:: An inproc is one which runs in the same process area as that of the client giving tha advantage of speed but the disadvantage of stability becoz if it crashes it takes the client application also with it.Outproc is one which works outside the clients memory thus giving stability to the client, but we have to compromise a bit on speed. Q:: What is the difference between HTTP-Post and HTTP-Get? A:: As their names imply, both HTTP GET and HTTP POST use HTTP as their underlying protocol. Both of these methods encode request parameters as name/value pairs in the HTTP request. The GET method creates a query string and appends it to the scripts URL on the server that handles the request. The POST method creates a name/value pairs that are passed in the body of the HTTP request message. Q:: How do you implement Paging in .Net? A:: The DataGrid provides the means to display a group of records from the data source (for example, the first 10), and then navigate to the page containing the next 10 records, and so on through the data. Using Ado.Net we can explicit control over the number of records returned from the data source, as well as how much data is to be cached locally in the DataSet. 1.Using DataAdapter.fill method give the value of Maxrecords parameter (Note: - Dont use it because query will return all records but fill the dataset based on value of maxrecords parameter). 2.For SQL server database, combines a WHERE clause and a ORDER BY clause with TOP predicate. 3.If Data does not change often just cache records locally in DataSet and just take some records from the DataSet to display. Q:: Can you create an app domain? A:: Yes, We can create user app domain by calling on of the following overload static methods of the System.AppDomain class

1. Public static AppDomain CreateDomain(String friendlyName) 2. Public static AppDomain CreateDomain(String friendlyName, Evidence securityInfo) 3. Public static AppDomain CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info) 4. Public static AppDomain CreateDomain(String friendlyName, Evidence securityInfo, String appBasePath, String appRelativeSearchPath, bool shadowCopyFiles) Q:: Whats the difference between an interface and abstract class? A:: In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers. Q:: What is the difference between a Struct and a Class? A:: Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit. Q:: How is method overriding different from method overloading? A:: When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class. Q:: Can you declare an override method to be static if the original method is not static? A:: No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override) Q:: What does assert() method do? A:: In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true. Q:: Why are there five tracing levels in System.Diagnostics.TraceSwitcher? A:: The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.

Q:: What is the role of the DataReader class in ADO.NET connections? A:: It returns a read-only, forward-only rowset from the data source. A DataReader provides fast access when a forward-only sequential read is needed. Q:: What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? A:: SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix. OLE-DB.NET is a .NET layer on top of the OLE layer, so its not as fastest and efficient as SqlServer.NET. Q:: What is the wildcard character in SQL? A:: Lets say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve La% Q:: Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted? A:: Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction. Q:: What is a pre-requisite for connection pooling? A:: Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings. The connection string must be identical. Q:: Explain acid properties? A:: The term ACID conveys the role transactions play in mission-critical applications. Coined by transaction processing pioneers, ACID stands for atomicity, consistency, isolation, and durability. These properties ensure predictable behavior, reinforcing the role of transactions as all-or-none propositions designed to reduce the management load when there are many variables. Atomicity A transaction is a unit of work in which a series of operations occur between the BEGIN TRANSACTION and END TRANSACTION statements of an application. A transaction executes exactly once and is atomic all the work is done or none of it is. Operations associated with a transaction usually share a common intent and are interdependent. By performing only a subset

of these operations, the system could compromise the overall intent of the transaction. Atomicity eliminates the chance of processing a subset of operations. Consistency A transaction is a unit of integrity because it preserves the consistency of data, transforming one consistent state of data into another consistent state of data.Consistency requires that data bound by a transaction be semantically preserved. Some of the responsibility for maintaining consistency falls to the application developer who must make sure that all known integrity constraints are enforced by the application. For example, in developing an application that transfers money, you should avoid arbitrarily moving decimal points during the transfer.Isolation A transaction is a unit of isolation allowing concurrent transactions to behave as though each were the only transaction running in the system. Isolation requires that each transaction appear to be the only transaction manipulating the data store, even though other transactions may be running at the same time. A transaction should never see the intermediate stages of another transaction. Transactions attain the highest level of isolation when they are serializable. At this level, the results obtained from a set of concurrent transactions are identical to the results obtained by running each transaction serially. Because a high degree of isolation can limit the number of concurrent transactions, some applications reduce the isolation level in exchange for better throughput. Durability A transaction is also a unit of recovery. If a transaction succeeds, the system guarantees that its updates will persist, even if the computer crashes immediately after the commit. Specialized logging allows the systems restart procedure to complete unfinished operations, making the transaction durable. Q:: Explain the ADO . Net Architecture ( .Net Data Provider) A:: ADO.Net is the data access model for .Net based applications. It can be used to access relational database systems such as SQL SERVER 2000, Oracle, and many other data sources for which there is an OLD DB or ODBC provider. To a certain extent, ADO.NET represents the latest evolution of ADO technology. However, ADO.NET introduces some major changes and innovations that are aimed at the loosely coupled and inherently disconnected nature of web applications. A .Net Framework data provider is used to connecting to a database, executing commands, and retrieving results. Those results are either processed directly, or placed in an ADO.NET DataSet in order to be exposed to the user in an ad-hoc manner, combined with data from multiple sources, or remoted between tiers. The .NET Framework data provider is designed to be lightweight, creating a minimal layer between the data source and your code, increasing performance without sacrificing functionality. Following are the 4 core objects of .Net Framework Data provider: Connection: Establishes a connection to a specific data source Command: Executes a command against a data source. Exposes Parameters and can execute within the scope of a Transaction from a Connection. DataReader: Reads a forward-only, read-only stream of data from a data

source. DataAdapter: Populates a DataSet and resolves updates with the data source. The .NET Framework includes the .NET Framework Data Provider for SQL Server (for Microsoft SQL Server version 7.0 or later), the .NET Framework Data Provider for OLE DB, and the .NET Framework Data Provider for ODBC. The .NET Framework Data Provider for SQL Server: The .NET Framework Data Provider for SQL Server uses its own protocol to communicate with SQL Server. It is lightweight and performs well because it is optimized to access a SQL Server directly without adding an OLE DB or Open Database Connectivity (ODBC) layer. The following illustration contrasts the .NET Framework Data Provider for SQL Server with the .NET Framework Data Provider for OLE DB. The .NET Framework Data Provider for OLE DB communicates to an OLE DB data source through both the OLE DB Service component, which provides connection pooling and transaction services, and the OLE DB Provider for the data source The .NET Framework Data Provider for OLE DB: The .NET Framework Data Provider for OLE DB uses native OLE DB through COM interoperability to enable data access. The .NET Framework Data Provider for OLE DB supports both local and distributed transactions. For distributed transactions, the .NET Framework Data Provider for OLE DB, by default, automatically enlists in a transaction and obtains transaction details from Windows 2000 Component Services. The .NET Framework Data Provider for ODBC: The .NET Framework Data Provider for ODBC uses native ODBC Driver Manager (DM) through COM interoperability to enable data access. The ODBC data provider supports both local and distributed transactions. For distributed transactions, the ODBC data provider, by default, automatically enlists in a transaction and obtains transaction details from Windows 2000 Component Services. The .NET Framework Data Provider for Oracle: The .NET Framework Data Provider for Oracle enables data access to Oracle data sources through Oracle client connectivity software. The data provider supports Oracle client software version 8.1.7 and later. The data provider supports both local and distributed transactions (the data provider automatically enlists in existing distributed transactions, but does not currently support the EnlistDistributedTransaction method). The .NET Framework Data Provider for Oracle requires that Oracle client software (version 8.1.7 or later) be installed on the system before you can use it to connect to an Oracle data source. .NET Framework Data Provider for Oracle classes are located in the System.Data.Oracle Client namespace and are contained in the System.Data.OracleClient.dll assembly. You will need to reference both the System.Data.dll and the System.Data.OracleClient.dll when compiling an application that uses the data provider. Choosing a .NET Framework Data Provider .NET Framework Data Provider for SQL Server: Recommended for middle-tier applications using Microsoft SQL Server 7.0 or later. Recommended for single-tier applications using Microsoft Data Engine (MSDE) or Microsoft SQL

Server 7.0 or later. Recommended over use of the OLE DB Provider for SQL Server (SQLOLEDB) with the .NET Framework Data Provider for OLE DB. For Microsoft SQL Server version 6.5 and earlier, you must use the OLE DB Provider for SQL Server with the .NET Framework Data Provider for OLE DB. .NET Framework Data Provider for OLE DB: Recommended for middle-tier applications using Microsoft SQL Server 6.5 or earlier, or any OLE DB provider. For Microsoft SQL Server 7.0 or later, the .NET Framework Data Provider for SQL Server is recommended. Recommended for single-tier applications using Microsoft Access databases. Use of a Microsoft Access database for a middle-tier application is not recommended. .NET Framework Data Provider for ODBC: Recommended for middle-tier applications using ODBC data sources. Recommended for single-tier applications using ODBC data sources. .NET Framework Data Provider for Oracle: Recommended for middle-tier applications using Oracle data sources. Recommended for single-tier applications using Oracle data sources. Supports Oracle client software version 8.1.7 and later. The .NET Framework Data Provider for Oracle classes are located in the System.Data.OracleClient namespace and are contained in the System.Data.OracleClient.dll assembly. You need to reference both the System.Data.dll and the System.Data.OracleClient.dll when compiling an application that uses the data provider. Q::Is Your Glass Half Full? A:: There are three common techniques for managing what happens when users try to modify the same data at the same time: pessimistic, optimistic, and last-in wins. They each handle concurrency issues differently.The pessimistic approach says: Nobody can cause a concurrency violation with my data if I do not let them get at the data while I have it. This tactic prevents concurrency in the first place but it limits scalability because it prevents all concurrent access. Pessimistic concurrency generally locks a row from the time it is retrieved until the time updates are flushed to the database. Since this requires a connection to remain open during the entire process, pessimistic concurrency cannot successfully be implemented in a disconnected model like the ADO.NET DataSet, which opens a connection only long enough to populate the DataSet then releases and closes, so a database lock cannot be held. Another technique for dealing with concurrency is the last-in wins approach. This model is pretty straightforward and easy to implement-whatever data modification was made last is what gets written to the database. To implement this technique you only need to put the primary key fields of the row in the UPDATE statements WHERE clause. No matter what is changed, the UPDATE statement will overwrite the changes with its own changes since all it is looking for is the row that matches the primary key values. Unlike the pessimistic model, the last-in wins approach allows users to read the data while it is being edited on screen. However, problems can occur when users try to modify the same data at the same time because users can overwrite each others changes without being notified of the collision. The last-in wins approach does not

detect or notify the user of violations because it does not care. However the optimistic technique does detect violations. In optimistic concurrency models, a row is only locked during the update to the database. Therefore the data can be retrieved and updated by other users at any time other than during the actual row update operation. Optimistic concurrency allows the data to be read simultaneously by multiple users and blocks other users less often than its pessimistic counterpart, making it a good choice for ADO.NET. In optimistic models, it is important to implement some type of concurrency violation detection that will catch any additional attempt to modify records that have already been modified but not committed. You can write your code to handle the violation by always rejecting and canceling the change request or by overwriting the request based on some business rules. Another way to handle the concurrency violation is to let the user decide what to do. The sample application that is shown in Figure 1 illustrates some of the options that can be presented to the user in the event of a concurrency violation. Q:: How you will set the datarelation between two columns? A:: ADO.NET provides DataRelation object to set relation between two columns.It helps to enforce the following constraints,a unique constraint, which guarantees that a column in the table contains no duplicates and a foreign-key constraint,which can be used to maintain referential integrity.A unique constraint is implemented either by simply setting the Unique property of a data column to true, or by adding an instance of the UniqueConstraint class to the DataRelation objects ParentKeyConstraint. As part of the foreign-key constraint, you can specify referential integrity rules that are applied at three points,when a parent record is updated,when a parent record is deleted and when a change is accepted or rejected. Q:: How is the DLL Hell problem solved in .NET? A:: Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly. Q::: What is a satellite assembly? A:: 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. Q:: When should you call the garbage collector in .NET? A:: As a good rule, you should not call the garbage collector. However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. However, this is usually not a good practice.

Q:: What happens in memory when you Box and Unbox a value-type? A:: Boxing converts a value-type to a reference-type, thus storing the object on the heap. Unboxing converts a reference-type to a value-type, thus storing the value on the stack. Q:: When was .NET announced? A:: Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET vision. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET. Q:: When was the first version of .NET released? A:: The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on 15-Jan-2002. At the same time, the final version of Visual Studio.NET was made available to MSDN subscribers. Q:: What is the CLR?

A:: CLR = Common Language Runtime. The CLR is a set of standard resources that (in theory) any .NET program can take advantage of, regardless of programming language. Robert Schmidt (Microsoft) lists the following CLR resources in his MSDN PDC# article:Object-oriented programming model (inheritance, polymorphism, exception handling, garbage collection) Security model Type system All .NET base classes Many .NET framework classes Development, debugging, and profiling tools Execution and code management IL-to-native translators and optimizers What this means is that in the .NET world, different programming languages will be more equal in capability than they have ever been before, although clearly not all languages will support all CLR services. Q:: What is the CTS? A:: CTS = Common Type System. This is the range of types that the .NET runtime understands, and therefore that .NET applications can use. However note that not all .NET languages will support all the types in the CTS. The CTS is a superset of the CLS. Q:: What is the CLS? A:: CLS = Common Language Specification. This is a subset of the CTS which all .NET languages are expected to support. The idea is that any program which uses CLS-compliant types can interoperate with any .NET program

written in any language. In theory this allows very tight interop between different .NET languages - for example allowing a C# class to inherit from a VB class. Q:: What is IL? A:: IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL. The IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler. Q:: What does managed mean in the .NET context? A:: The term managed is the cause of much confusion. It is used in various places within .NET, meaning slightly different things.Managed code: The .NET framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. Such code is called managed code. All C# and Visual Basic.NET code is managed by default. VS7 C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/com+). Managed data: This is data that is allocated and de-allocated by the .NET runtimes garbage collector. C# and VB.NET data is always managed. VS7 C++ data is unmanaged by default, even when using the /com+ switch, but it can be marked as managed using the __gc keyword.Managed classes: This is usually referred to in the context of Managed Extensions (ME) for C++. When using ME C++, a class can be marked with the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector, but it also means more than that. The class becomes a fully paid-up member of the .NET community with the benefits and restrictions that brings. An example of a benefit is proper interop with classes written in other languages - for example, a managed C++ class can inherit from a VB class. An example of a restriction is that a managed class can only inherit from one base class. Q:: What is reflection? A:: All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly. Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries. Reflection can also be used to dynamically invoke methods (see

System.Type.Invoke Member ) , or even create types dynamically at runtime (see System.Reflection.Emit.TypeBuilder). Q:: What is the difference between Finalize and Dispose (Garbage collection) ? A:: Class instances often encapsulate control over resources that are not managed by the runtime, such as window handles (HWND), database connections, and so on. Therefore, you should provide both an explicit and an implicit way to free those resources. Provide implicit control by implementing the protected Finalize Method on an object (destructor syntax in C# and the Managed Extensions for C++). The garbage collector calls this method at some point after there are no longer any valid references to the object. In some cases, you might want to provide programmers using an object with the ability to explicitly release these external resources before the garbage collector frees the object. If an external resource is scarce or expensive, better performance can be achieved if the programmer explicitly releases resources when they are no longer being used. To provide explicit control, implement the Dispose method provided by the IDisposable Interface. The consumer of the object should call this method when it is done using the object. Dispose can be called even if other references to the object are alive. Note that even when you provide explicit control by way of Dispose, you should provide implicit cleanup using the Finalize method. Finalize provides a backup to prevent resources from permanently leaking if the programmer fails to call Dispose. Q:: What is Partial Assembly References? A:: Full Assembly reference: A full assembly reference includes the assemblys 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. Q:: Changes to which portion of version number indicates an incompatible change? A:: Major or minor. Changes to the major or minor portion of the version number indicate an incompatible change. Under this convention then, version 2.0.0.0 would be considered incompatible with version 1.0.0.0. Examples of an incompatible change would be a change to the types of some method parameters or the removal of a type or method altogether. Build. The Build number is typically used to distinguish between daily builds or smaller compatible releases. Revision. Changes to the revision number are typically reserved for an incremental build needed to fix a particular bug. Youll sometimes hear this referred to as the emergency bug fix number in that the revision is what is often changed when a fix to a specific bug is shipped to a customer.

Q:: What is the property available to check if the page posted or not? A:: The Page_Load event handler in the page checks for IsPostBack property value, to ascertain whether the page is posted. The Page.IsPostBack gets a value indicating whether the page is being loaded in response to the client postback, or it is for the first time. The value of Page.IsPostBack is True, if the page is being loaded in response to the client postback; while its value is False, when the page is loaded for the first time. The Page.IsPostBack property facilitates execution of certain routine in Page_Load, only once (for e.g. in Page load, we need to set default value in controls, when page is loaded for the first time. On post back, we check for true value for IsPostback value and then invoke serverside code to update data). Q:: What is managed and unmanaged code? A:: The .NET framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. i.e., code executing under the control of the CLR is called managed code. For example, any code written in C# or Visual Basic .NET is managed code. Code that runs outside the CLR is referred to as unmanaged code. COM components, ActiveX components, and Win32 API functions are examples of unmanaged code. Q:: What is Globalizationa and Localization ? A:: Globalization is the process of creating an application that meets the needs of users from multiple cultures. It includes using the correct currency, date and time format, calendar, writing direction, sorting rules, and other issues. Accommodating these cultural differences in an application is called localization.Using classes of System.Globalization namespace, you can set applications current culture. This can be achieved by using any of the following 3 approaches. 1.Detect and redirect 2.Run-time adjustment 3.Using Satellite assemblies. Q:: What are Resource Files ? How are they used in .NET? A:: 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 dont need to compile these if the data get changed. In .NET we basically require them storing culture specific

informations by localizing applications resources. You can deploy your resources using satellite assemblies. Q:: Difference between Dispose and Finallize method? A:: Finalize method is used to free the memory used by some unmanaged resources like window handles (HWND). Its similar to the destructor syntax in C#. The GC calls this method when it founds no more references to the object. But, In some cases we may need release the memory used by the resources explicitely.To release the memory explicitly we need to implement the Dispose method of IDisposable interface. Q:: What is encapsulation ? A:: Encapsulation is the ability to hide the internal workings of an objects behavior and its data. For instance, lets say you have a object named Bike and this object has a method named start(). When you create an instance of a Bike object and call its start() method you are not worried about what happens to accomplish this, you just want to make sure the state of the bike is changed to running afterwards. This kind of behavior hiding is encapsulation and it makes programming much easier. Q:: What is GUID and why we need to use it and in what condition? How this is created. A:: A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated. Visual Studio .NET IDE has a utility under the tools menu to generate GUIDs. Q:: Why do you need to serialize.? A:: We need to serialize the object,if you want to pass object from one computer/application domain to another.Process of converting complex objects into stream of bytes that can be persisted or transported.Namespace for serialization is System.Runtime.Serialization.The ISerializable interface allows you to make any class Serializable..NET framework features 2 serializing method. 1.Binary Serialization 2.XML Serialization Q:: What is inline schema, how does it works? A:: Schemas can be included inside of XML file is called Inline Schemas.This is useful when it is inconvenient to physically seprate the schema and the XML document.A schema is an XML document that defines the structure, constraints, data types, and relationships of the elements that constitute the data contained inside the XML document or in another XML

document.Schema can be an external file which uses the XSD or XDR extension called external schema. Inline schema can take place even when validation is turned off. Q:: Can a nested object be used in Serialization ? A:: Yes. If a class that is to be serialized contains references to objects of other classes, and if those classes have been marked as serializable, then their objects are serialized too. Q:: Difference between int and int32 ? A:: Both are same. System.Int32 is a .NET class. Int is an alias name for System.Int32. Q:: Describe the difference between a Thread and a Process? A:: A Process is an instance of an running application. And a thread is the Execution stream of the Process. A process can have multiple Thread. When a process starts a specific memory area is allocated to it. When there is multiple thread in a process, each thread gets a memory for storing the variables in it and plus they can access to the global variables which is common for all the thread. Eg.A Microsoft Word is a 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. Q:: What is a PID? How is it useful when troubleshooting a system? A:: PID is the process Id of the application in Windows. Whenever a process starts running in the Windows environment, it is associated with an individual process Id or PID. Q:: The PID (Process ID) a unique number for each item on the Process Tab, Image Name list. How do you get the PID to appear? A:: In Task Manger, select the View menu, then select columns and check PID (Process Identifier).In Linux, PID is used to debug a process explicitly. However we cannot do this in a windows environment. Microsoft has launched a SDK called as Microsoft Operations Management (MOM). This uses the PID to find out which dlls have been loaded by a process in the memory. This is essentially helpful in situations where the Process which has a memory leak is to be traced to a erring dll. Personally I have never used a PID, our Windows debugger does the things required to find out.

Q:: How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization? A:: The hugely simplistic version is that every time it garbage-collects, it starts by assuming everything to be garbage, then goes through and builds a list of everything reachable. Those become not-garbage, everything else doesnt, and gets thrown away. What makes it generational is that every time an object goes through this process and survives, it is noted as being a member of an older generation (up to 2, right now). When the garbagecollector is trying to free memory, it starts with the lowest generation (0) and only works up to higher ones if it cant free up enough space, on the grounds that shorter-lived objects are more likely to have been freed than longer-lived ones. Non-deterministic finalization implies that the destructor (if any) of an object will not necessarily be run (nor its memory cleaned up, but thats a relatively minor issue) immediately upon its going out of scope. Instead, it will wait until first the garbage collector gets around to finding it, and then the finalisation queue empties down to it; and if the process ends before this happens, it may not be finalised at all. (Although the operating system will usually clean up any process-external resources left open - note the usually there, especially as the exceptions tend to hurt a lot.) Q:: How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?

A:: The using() pattern is useful because it ensures that Dispose() will always be called when a disposable object (defined as one that implements IDisposable, and thus the Dispose() method) goes out of scope, even if it does so by an exception being thrown, and thus that resources are always released. Q:: What are PDBs? Where must they be located for debugging to work? A:: A program database (PDB) files holds debugging and project state information that allows incremental linking of debug configuration of your program.There are several different types of symbolic debugging information. The default type for Microsoft compiler is the so-called PDB file. The compiler setting for creating this file is /Zi, or /ZI for C/C++(which creates a PDB file with additional information that enables a feature called Edit and Continue) or a Visual Basic/C#/JScript .NET program with /debug. A PDB file is a separate file, placed by default in the Debug project subdirectory, that has the same name as the executable file with the extension .pdb. Note that the Visual C++ compiler by default creates an additional PDB file called VC60.pdb for VisulaC++6.0 and VC70.PDB file for

VisulaC++7.0. The compiler creates this file during compilation of the source code, when the compiler isnt aware of the final name of the executable. The linker can merge this temporary PDB file into the main one if you tell it to, but it wont do it by default. The PDB file can be useful to display the detailed stack trace with source files and line numbers. Q:: What is FullTrust? Do GACed assemblies have FullTrust? A:: Before the .NET Framework existed, Windows had two levels of trust for downloaded code. This old model was a binary trust model. You only had two choices: Full Trust, and No Trust. The code could either do anything you could do, or it wouldnt run at all. The permission sets in .NET include FullTrust, SkipVerification, Execution, Nothing, LocalIntranet, Internet and Everything. Full Trust Grants unrestricted permissions to system resources. Fully trusted code run by a normal, nonprivileged user cannot do administrative tasks, but can access any resources the user can access, and do anything the user can do. From a security standpoint, you can think of fully trusted code as being similar to native, unmanaged code, like a traditional ActiveX control. GAC assemblies are granted FullTrust. In v1.0 and 1.1, the fact that assemblies in the GAC seem to always get a FullTrust grant is actually a side effect of the fact that the GAC lives on the local machine. If anyone were to lock down the security policy by changing the grant set of the local machine to something less than FullTrust, and if your assembly did not get extra permission from some other code group, it would no longer have FullTrust even though it lives in the GAC. Q:: Explain the importance and use of each, Version, Culture and PublicKeyToken for an assembly. A:: This three alongwith name of the assembly provide a strong name or fully qualified name to the assembly. When a assebly is referenced with all three. PublicKeyToken: Each assembly can have a public key embedded in its manifest that identifies the developer. This ensures that once the assembly ships, no one can modify the code or other resources contained in the assembly. Culture: Specifies which culture the assembly supports Version: The version number of the assembly.It is of the following form major.minor.build.revision. Q:: Explain the differences between public, protected, private and internal.?

A:: These all are access modifier and they governs the access level. They can be applied to class, methods, fields. Public: Allows class, methods, fields to be accessible from anywhere i.e. within and outside an assembly. Private: When applied to field and method allows to be accessible within a class. Protected: Similar to private but can be accessed by members of derived class also. Internal: They are public within the assembly i.e. they can be accessed by anyone within an assembly but outside assembly they are not visible. Q:: What is the use of Internal keyword? A:: Internal keyword is one of the access specifier available in .Net framework , that makes a type visible in a given assembly , for e.g : a single dll can contain multiple modules , essentially a multi file assembly , but it forms a single binary component , so any type with internal keyword will be visible throughout the assembly and can be used in any of the modules . Q:: Why only boxed types can be unboxed? A:: Unboxing is the process of converting a Reference type variable to Value type and thus allocating memory on the stack . It happens only to those Reference type variables that have been earlier created by Boxing of a Value Type , therefore internally they contain a value type , which can be obtained through explicit casting . For any other Reference type , they dont internally contain a Value type to Unboxed via explicit casting . This is why only boxed types can be unboxed . Q:: What is side-by-side execution? A:: Can two application one using private assembly and other using Shared assembly be stated as a side-by-side executables? Side-by-side execution is the ability to run multiple versions of an application or component on the same computer. You can have multiple versions of the common language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time. Since versioning is only applied to shared assemblies, and not to private assemblies, two application one using private assembly and one using shared assembly cannot be stated as side-by-side executables. Q:: Why doesnt the .NET runtime offer deterministic destruction? A:: Because of the garbage collection algorithm. The .NET garbage collector works by periodically running through a list of all the objects that are currently being referenced by an application. All the objects that it doesnt find during this search are ready to be destroyed and the memory reclaimed. The implication of this algorithm is that the runtime doesnt get notified

immediately when the final reference on an object goes away - it only finds out during the next sweep of the heap. Futhermore, this type of algorithm works best by performing the garbage collection sweep as rarely as possible. Normally heap exhaustion is the trigger for a collection sweep. Q:: Is the lack of deterministic destruction in .NET a problem? A:: Its certainly an issue that affects component design. If you have objects that maintain expensive or scarce resources (e.g. database locks), you need to provide some way for the client to tell the object to release the resource when it is done. Microsoft recommend that you provide a method called Dispose() for this purpose. However, this causes problems for distributed objects - in a distributed system who calls the Dispose() method? Some form of reference-counting or ownership-management mechanism is needed to handle distributed objects - unfortunately the runtime offers no help with this. Q:: Can I customise the serialization process? A:: Yes. XmlSerializer supports a range of attributes that can be used to configure serialization for a particular class. For example, a field or property can be marked with the [XmlIgnore] attribute to exclude it from serialization. Another example is the [XmlElement] attribute, which can be used to specify the XML element name to be used for a particular property or field. Serialization via SoapFormatter/BinaryFormatter can also be controlled to some extent by attributes. For example, the [NonSerialized] attribute is the equivalent of XmlSerializers [XmlIgnore] attribute. Ultimate control of the serialization process can be acheived by implementing the the ISerializable interface on the class whose instances are to be serialized Q:: Why is XmlSerializer so slow? A:: There is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize or deserialize an object of a given type in an application, there is a significant delay. This normally doesnt matter, but it may mean, for example, that XmlSerializer is a poor choice for loading configuration settings during startup of a GUI application. Q:: What are attributes? A:; There are at least two types of .NET attribute. The first type I will refer to as a metadata attribute - it allows some data to be attached to a class or method. This data becomes part of the metadata for the class, and (like other class metadata) can be accessed via reflection. The other type of attribute is a context attribute. Context attributes use a similar syntax to metadata attributes but they are fundamentally different. Context attributes

provide an interception mechanism whereby instance activation and method calls can be pre- and/or post-processed. Q:: How can I stop my code being reverse-engineered from IL? A:: There is currently no simple way to stop code being reverse-engineered from IL. In future it is likely that IL obfuscation tools will become available, either from MS or from third parties. These tools work by optimising the IL in such a way that reverse-engineering becomes much more difficult. Of course if you are writing web services then reverse-engineering is not a problem as clients do not have access to your IL. Q:: Differnce between Managed code and unmanaged code ? A:: Managed Code: Code that runs under a contract of cooperation with the common language runtime. Managed code must supply the metadata necessary for the runtime to provide services such as memory management, cross-language integration, code access security, and automatic lifetime control of objects. All code based on Microsoft intermediate language (MSIL) executes as managed code. Un-Managed Code:Code that is created without regard for the conventions and requirements of the common language runtime. Unmanaged code executes in the common language runtime environment with minimal services (for example, no garbage collection, limited debugging, and so on). Q:: What is MSIL, IL, CTS and, CLR ? A:: MSIL: (Microsoft intermediate language) When compiling to managed code, the compiler translates your source code into Microsoft intermediate language (MSIL), which is a CPU-independent set of instructions that can be efficiently converted to native code. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations. Before code can be executed, MSIL must be converted to CPU-specific code, usually by a just-in-time (JIT) compiler. Because the common language runtime supplies one or more JIT compilers for each computer architecture it supports, the same set of MSIL can be JIT-compiled and executed on any supported architecture. When a compiler produces MSIL, it also produces metadata. Metadata describes the types in your code, including the definition of each type, the signatures of each types members, the members that our code references, and other data that the runtime uses at execution time. The MSIL and metadata are contained in a portable executable (PE) file that is based on and extends the published Microsoft PE and Common Object File Format (COFF) used historically for executable content. This file format, which accommodates

MSIL or native code as well as metadata, enables the operating system to recognize common language runtime images. The presence of metadata in the file along with the MSIL enables your code to describe itself, which means that there is no need for type libraries or Interface Definition Language (IDL). The runtime locates and extracts the metadata from the file as needed during execution. IL: (Intermediate Language)A language used as the output of a number of compilers and as the input to a just-in-time (JIT) compiler. The common language runtime includes a JIT compiler for converting MSIL to native code. CTS: (Common Type System) The specification that determines how the common language runtime defines, uses, and manages types CLR: (Common Language Runtime) The engine at the core of managed code execution. The runtime supplies managed code with services such as crosslanguage integration, code access security, object lifetime management, and debugging and profiling support. Q:: What is Reference type and value type ? A:; Reference Type: Reference types are allocated on the managed CLR heap, just like object types. A data type that is stored as a reference to the values location. The value of a reference type is the location of the sequence of bits that represent the types data. Reference types can be self-describing types, pointer types, or interface types Value Type: Value types are allocated on the stack just like primitive types in VBScript, VB6 and C/C++. Value types are not instantiated using new go out of scope when the function they are defined within returns. Value types in the CLR are defined as types that derive from system.valueType. A data type that fully describes a value by specifying the sequence of bits that constitutes the values representation. Type information for a value type instance is not stored with the instance at run time, but it is available in metadata. Value type instances can be treated as objects using boxing. Q:: What is difference between constants, readonly and, static ? A:; Constants: The value cant be changed Read-only: The value will be initialized only once from the constructor of the class. Static: Value can be initialized once. Q:: What are the types of authentication in .net?

A:: We have three types of authentication: . Form authenticatio . Windows authentication . Passport This has to be declared in web.config file. Q:: What is the difference between a Struct and a Class ? A:: The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects, you will allocate additional memory for referencing each object. In this case, the struct is less expensive. When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized. It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values. It is an error to initialize an instance field in a struct. There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do. A struct is a value type, while a class is a reference type. Q:: Whats the difference between Java and .NET garbage collectors? A:: Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE youre using. Microsoft standardized on their garbage collection. Q:: Can multiple catch blocks be executed? A:: Its a delegate that points to and eventually fires off several methods. Q:: Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to solve? A:: The XML Information Set (Infoset) defines a data model for XML. The Infoset describes the abstract representation of an XML Document. Infoset is the generalized representation of the XML Document, which is primarily meant to act as a set of definitions used by XML technologies to formally describe what parts of an XML document they operate upon. The Document Object Model (DOM) is one technology for representing an XML Document in memory and to programmatically read, modify and manipulate a xml document. Infoset helps defining generalized standards on how to use XML that is not dependent or tied to a particular XML specification

or API. The Infoset tells us what part of XML Document should be considered as significant information. Q:: Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why? A:: Document Type Definition (DTD) describes a model or set of rules for an XML document. XML Schema Definition (XSD) also describes the structure of an XML document but XSDs are much more powerful. The disadvantage with the Document Type Definition is it doesnt support data types beyond the basic 10 primitive types. It cannot properly define the type of data contained by the tag. An Xml Schema provides an Object Oriented approach to defining the format of an xml document. The Xml schema support most basic programming types like integer, byte, string, float etc., We can also define complex types of our own which can be used to define a xml document. Xml Schemas are always preferred over DTDs as a document can be more precisely defined using the XML Schemas because of its rich support for data representation. Q:: Can you declare a C++ type destructor in C# like ~MyClass()? A:: Yes, but whats the point, since it will call Finalize(), and Finalize() has no guarantees when the memory will be cleaned up, plus, it introduces additional load on the garbage collector. Q:: What is ADO .NET and what is difference between ADO and ADO.NET? A:: ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch. Q:: What technology enables out-of-proc communication in .NET? A:: Most usually Remoting;.NET remoting enables client applications to use objects in other processes on the same computer or on any other computer available on its network.While you could implement an out-of-proc component in any number of other ways, someone using the term almost always means Remoting. Q:: Are private class-level variables inherited? A:: Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited. Q:: What is a formatter?

A:: A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end. Q;; Different b/w .NET & J2EE ? A:: Differences between J2EE and the .NET Platform Vendor Neutrality The .NET platform is not vendor neutral, it is tied to the Microsoft operating systems. But neither are any of the J2EE implementations Many companies buy into J2EE believing that it will give them vendor neutrality. And, in fact, this is a stated goal of Suns vision: A wide variety of J2EE product configurations and implementations, all of which meet the requirements of this specification, are possible. A portable J2EE application will function correctly when successfully deployed in any of these products. (ref : Java 2 Platform Enterprise Edition Specification, v1.3, page 2-7 available at http://java.sun.com/j2ee/) Overall Maturity Given that the .NET platform has a three year lead over J2EE, it should be no surprise to learn that the .NET platform is far more mature than the J2EE platform. Whereas we have high volume highly reliable web sites using .NET technologies (NASDAQ and Dell being among many examples) Interoperability and Web Services The .NET platform eCollaboration model is, as I have discussed at length, based on the UDDI and SOAP standards. These standards are widely supported by more than 100 companies. Microsoft, along with IBM and Ariba, are the leaders in this area. Sun is a member of the UDDI consortium and recognizes the importance of the UDDI standards. In a recent press release, Suns George Paolini, Vice President for the Java Community Development, says:Sun has always worked to help establish and support open, standards-based technologies that facilitate the growth of networkbased applications, and we see UDDI as an important project to establish a registry framework for business-to-business e-commerce But while Sun publicly says it believes in the UDDI standards, in reality, Sun has done nothing whatsoever to incorporate any of the UDDI standards into J2EE. Framework Support The .NET platform includes such an eCommerce framework called Commerce Server. At this point, there is no equivalent vendor-neutral framework in the J2EE space. With J2EE, you should assume that you will be building your new eCommerce solution from scratch Moreover, no matter what [J2EE] vendor you choose, if you expect a

component framework that will allow you to quickly field complete e-business applications, you are in for a frustrating experience Language In the language arena, the choice is about as simple as it gets. J2EE supports Java, and only Java. It will not support any other language in the foreseeable future. The .NET platform supports every language except Java (although it does support a language that is syntactically and functionally equivalent to Java, C#). In fact, given the importance of the .NET platform as a language independent vehicle, it is likely that any language that comes out in the near future will include support for the .NET platform. Some companies are under the impression that J2EE supports other languages. Although both IBMs WebSphere and BEAs WebLogic support other languages, neither does it through their J2EE technology. There are only two official ways in the J2EE platform to access other languages, one through the Java Native Interface and the other through CORBA interoperability. Sun recommends the later approach. As Suns Distinguished Scientist and Java Architect Rick Cattell said in a recent interview. Portability The reason that operating system portability is a possibility with J2EE is not so much because of any inherent portability of J2EE, as it is that most of the J2EE vendors support multiple operating systems. Therefore as long as one sticks with a given J2EE vendor and a given database vendor, moving from one operating system to another should be possible. This is probably the single most important benefit in favor of J2EE over the .NET platform, which is limited to the Windows operating system. It is worth noting, however, that Microsoft has submitted the specifications for C# and a subset of the .NET Framework (called the common language infrastructure) to ECMA, the group that standardizes JavaScript. J2EE offers an acceptable solution to ISVs when the product must be marketed to non-Windows customers, particularly when the J2EE platform itself can be bundled with the ISVs product as an integrated offering. If the primary customer base for the ISV is Windows customers, then the .NET platform should be chosen. It will provide much better performance at a much lower cost. Client device independence The major difference being that with Java, it is the presentation tier programmer that determines the ultimate HTML that will be delivered to the client, and with .NET, it is a Visual Studio.NET control. This Java approach has three problems. First, it requires a lot of code on the presentation tier, since every possible thin client system requires a different code path. Second, it is very difficult to test the code with every possible thin client system. Third, it is very difficult to add new thin clients to an existing application, since to do so involves searching through, and modifying a tremendous amount of presentation tier logic. The .NET Framework approach is to write device independent code that

interacts with visual controls. It is the control, not the programmer, that is responsible for determining what HTML to deliver, based on the capabilities of the client device.. In the .NET Framework model, one can forget that such a thing as HTML even exists! Conclusion Suns J2EE vision is based on a family of specifications that can be implemented by many vendors. It is open in the sense that any company can license and implement the technology, but closed in the sense that it is controlled by a single vendor, and a self contained architectural island with very limited ability to interact outside of itself. One of J2EEs major disadvantages is that the choice of the platform dictates the use of a single programming language, and a programming language that is not well suited for most businesses. One of J2EEs major advantages is that most of the J2EE vendors do offer operating system portability. Microsofts .NET platform vision is a family of products rather than specifications, with specifications used primarily to define points of interoperability. The major disadvantage of this approach is that if is limited to the Windows platform, so applications written for the .NET platform can only be run on .NET platforms. Their are several important advantages to the .NET platform: * The cost of developing applications is much lower, since standard business languages can be used and device independent presentation tier logic can be written. * The cost of running applications is much lower, since commodity hardware platforms (at 1/5 the cost of their Unix counterparts) can be used. * The ability to scale up is much greater, with the proved ability to support at least ten times the number of clients any J2EE platform has shown itself able to support. * Interoperability is much stronger, with industry standard eCollaboration built into the platform. Q:: What are delegates?where are they used ? A:: A delegate defines a reference type that can be used to encapsulate a method with a specific signature. A delegate instance encapsulates a static or an instance method. Delegates are roughly similar to function pointers in C+ +; however, delegates are type-safe and secure. Q:: What is namespaces? A:: Namespace is a logical naming scheme for group related types.Some class types that logically belong together they can be put into a common namespace. They prevent namespace collisions and they provide scoping. They are imported as using in C# or Imports in Visual Basic. It seems as if these directives specify a particular assembly, but they dont. A namespace can span multiple assemblies, and an assembly can define multiple

namespaces. When the compiler needs the definition for a class type, it tracks through each of the different imported namespaces to the type name and searches each referenced assembly until it is found. Namespaces can be nested. This is very similar to packages in Java as far as scoping is concerned. Q:: What is global assembly cache? A:: Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer. There are several ways to deploy an assembly into the global assembly cache: Use an installer designed to work with the global assembly cache. This is the preferred option for installing assemblies into the global assembly cache. Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK. Use Windows Explorer to drag assemblies into the cache. Q:: What is Jit compilers?.how many are available in clr? A:; Just-In-Time compiler- it converts the language that you write in .Net into machine language that a computer can understand. there are tqo types of JITs one is memory optimized & other is performace optimized. Q:: How does VB.NET/C# achieve polymorphism? A:; Polymorphism is also achieved through interfaces. Like abstract classes, interfaces also describe the methods that a class needs to implement. The difference between abstract classes and interfaces is that abstract classes always act as a base class of the related classes in the class hierarchy. For example, consider a hierarchy-car and truck classes derived from fourwheeler class; the classes two-wheeler and four-wheeler derived from an abstract class vehicle. So, the class vehicle is the base class in the class hierarchy. On the other hand dissimilar classes can implement one interface. For example, there is an interface that compares two objects. This interface can be implemented by the classes like box, person and string, which are unrelated to each other. C# allows multiple interface inheritance. It means that a class can implement more than one interface. The methods declared in an interface are implicitly abstract. If a class implements an interface, it becomes mandatory for the class to override all the methods declared in the interface, otherwise the derived class would become abstract. Can you explain what inheritance is and an example of when you might use it? The savingaccount class has two data members-accno that stores account number, and trans that keeps track of the number of transactions. We can create an object of savingaccount class as shown below. savingaccount s = new savingaccount ( Amar, 5600.00f ) ;

From the constructor of savingaccount class we have called the twoargument constructor of the account class using the base keyword and passed the name and balance to this constructor using which the data members name and balance are initialised. We can write our own definition of a method that already exists in a base class. This is called method overriding. We have overridden the deposit( ) and withdraw( ) methods in the savingaccount class so that we can make sure that each account maintains a minimum balance of Rs. 500 and the total number of transactions do not exceed 10. From these methods we have called the base classs methods to update the balance using the base keyword. We have also overridden the display( ) method to display additional information, i.e. account number. Working of currentaccount class is more or less similar to that of savingaccount class. Using the derived classs object, if we call a method that is not overridden in the derived class, the base class method gets executed. Using derived classs object we can call base classs methods, but the reverse is not allowed. Unlike C++, C# does not support multiple inheritance. So, in C# every class has exactly one base class. Now, suppose we declare reference to the base class and store in it the address of instance of derived class as shown below. account a1 = new savingaccount ( Amar, 5600.00f ) ; account a2 = new currentaccount ( MyCompany Pvt. Ltd., 126000.00f) ; Such a situation arises when we have to decide at run-time a method of which class in a class hierarchy should get called. Using a1 and a2, suppose we call the method display( ), ideally the method of derived class should get called. But it is the method of base class that gets called. This is because the compiler considers the type of reference (account in this case) and resolves the method call. So, to call the proper method we must make a small change in our program. We must use the virtual keyword while defining the methods in base class as shown below. public virtual void display( ) { } We must declare the methods as virtual if they are going to be overridden in derived class. To override a virtual method in derived classes we must use the override keyword as given below. public override void display( ) { } Now it is ensured that when we call the methods using upcasted reference, it is the derived classs method that would get called. Actually, when we declare a virtual method, while calling it, the compiler considers the contents of the reference rather than its type. If we dont want to override base classs virtual method, we can declare it with new modifier in derived class. The new modifier indicates that the method is new to this class and is not an override of a base class method. Q:: And if they have conflicting method names? A:: Its up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a

higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares youre okay. Q:: Whats the difference between System.String and System.StringBuilder classes?

A:: System.String is immutable, System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed. Q:: Hows the DLL Hell problem solved in .NET? A:: Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly. Q:: Whats the difference between the Debug class and Trace class? A:; Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds. Q:: What are three test cases you should go through in unit testing? A:: 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).

Vous aimerez peut-être aussi