Some important Questions of Dot Net What is the common language runtime (CLR)? The common language runtime is the execution engine for .NET Framework applications. It provides a number of services, including the following: • • • • • • • • • • •
Code management (loading and execution) Application memory isolation Verification of type safety Conversion of IL to native code Access to metadata (enhanced type information) Managing memory for managed objects Enforcement of code access security Exception handling, including cross-language exceptions Interoperation between managed code, COM objects, and pre-existing DLLs (unmanaged code and data) Automation of object layout Support for developer services (profiling, debugging, and so on)
What is garbage collection? Garbage collection is a mechanism that allows the computer to detect when an object can no longer be accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a "finalizer," which is written by the user). Some garbage collectors, like the one used by .NET, compact memory and therefore decrease your program's working set. What is serialization? Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database). There are two separate mechanisms provided by the .NET class library XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses SoapFormatter/BinaryFormatter for Remoting. Both are available for use in your own code.
1
How does .NET Remoting work? .NET Remoting involves sending messages along channels. Two of the standard channels are HTTP and TCP. TCP is intended for LANs only - HTTP can be used for LANs or WANs (internet). Support is provided for multiple message serialization formats. Examples are SOAP (XML-based) and binary. By default, the HTTP channel uses SOAP (via the .NET runtime Serialization SOAP Formatter), and the TCP channel uses binary (via the .NET runtime Serialization Binary Formatter). But either channel can use either serialization format. There are a number of styles of remote access: • Single
Call. Each incoming request from a client is serviced by a new object. The object is thrown away when the request has finished. This (essentially stateless) model can be made stateful in the ASP.NET environment by using the ASP.NET state service to store application or session state. • Singleton. All incoming requests from clients are processed by a single server object. • Client-activated object. This is the old stateful (D)COM model whereby the client receives a reference to the remote object and holds that reference (thus keeping the remote object alive) until it is finished with it. Distributed garbage collection of objects is managed by a system called 'leased based lifetime'. Each object has a lease time, and when that time expires the object is disconnected from the .NET runtime remoting infrastructure. Objects have a default renew time - the lease is renewed when a successful call is made from the client to the object. The client can also explicitly renew the lease. What are callbacks and Asynchronous callbacks? A callback function is code within a managed application that helps an unmanaged DLL function complete a task. Calls to a callback function pass indirectly from a managed application, through a DLL function, and back to the managed implementation. Some of the many DLL functions called with platform invoke require a callback function in managed code to run properly. This topic describes the elements of a callback function, and how to implement and call one from managed code AsyncCallback provides a way for client applications to complete an asynchronous operation. This callback delegate is supplied to the client when the asynchronous operation is initiated. The event handler referenced by AsyncCallback contains program logic to finish processing the asynchronous task for the client. 2
What will happen if we build an application in Debug and Release? The Debug configuration of your program is compiled with full symbolic debug information and no optimization. (Optimization complicates debugging, since the relationship between source code and generated instructions is more complex.) The Release configuration of your program is fully optimized and contains no symbolic debug information. Debug information may be generated in separate PDB files. What is Tracing? The Trace class allows you to instrument your application. You can receive informative messages from your running application that can help diagnose problems or analyze performance. The following is an overall view of the major steps typically involved in using tracing to analyze and correct potential problems in deployed applications. You can use the properties and methods in the Trace class to instrument release builds. Instrumentation allows you to monitor the health of your application running in real-life settings. Tracing helps you isolate problems and fix them without disturbing a running system. What is the reflection and disadvantages? The process of obtaining information about assemblies and the types defined within them, and creating, invoking, and accessing type instances at run time. Reflection provides objects that encapsulate assemblies, modules, and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object. You can then invoke the type's methods or access its fields and properties. What are runtime hosts? The common language runtime has been designed to support a variety of different types of applications, from Web server applications to applications with a traditional rich Windows user interface. Each type of application requires a runtime host to start it. The runtime host loads the runtime into a process, creates the application domains within the process, and loads user code into the application domains. The .NET Framework ships with a number of different runtime hosts, including the hosts listed in the following table. 3
Runtime Host ASP.NET
Description Loads the runtime into the process that is to handle the Web request. ASP.NET also creates an application domain for each Web application that will run on a Web server.
Microsoft Internet Explorer
Creates application domains in which to run managed controls. The .NET Framework supports the download and execution of browser-based controls. The runtime interfaces with the extensibility mechanism of Microsoft Internet Explorer through a mime filter to create application domains in which to run the managed controls. By default, one application domain is created for each Web site.
Shell executables
Invokes runtime hosting code to transfer control to the runtime each time an executable is launched from the shell.
What is application domain
(AppDomain)
A boundary that the common language runtime establishes around objects created within the same application scope (that is, anywhere along the sequence of object activations beginning with the application entry point). Application domains help isolate objects created in one application from those created in other applications so that run-time behavior is predictable. Multiple application domains can exist in a single process. Why we go for ASP.NET when already we have ASP? An ASP.NET page can run significantly faster than an equivalent ASP page because an ASP.NET page runs as compiled code. Conversely, the Web server must interpret each ASP page. However, simply upgrading a page from ASP to ASP.NET does not guarantee improved performance. Code in an ASP.NET page does not call COM components directly. Instead, the .NET Framework creates a runtime callable wrapper (RCW) that serves as a proxy between the managed code in the ASP.NET page and the unmanaged code in the COM component. Because of the overhead from the wrapper converting every piece of data that passes through it, an ASP.NET page that uses COM objects is likely to have poorer performance than an equivalent ASP page. To improve the performance of an ASP.NET page that uses COM components, you can use an interop assembly, essentially an optimized RCW, for each COM 4
component. You can also use an equivalent .NET component instead of the COM component. The first approach is easier to do, while the second approach provides better performance.
What are static assemblies? Assemblies can be static or dynamic. Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in portable executable (PE) files. What is a dynamic assembly? You can also use the .NET Framework to create dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed. What are Overriding methods on Object? For performance reasons, the virtual methods on Object methods always execute locally in the application domain where they are called. Calls to any of the following methods will go only to the remote object when these methods have been overridden on the remote object: What an assembly manifest contains? The assembly's manifest contains assembly metadata that is used for resolving types and satisfying resource requests. It specifies the types and resources that are exposed outside the assembly. The manifest also enumerates other assemblies on which it depends. It forms a version boundary. The assembly is the smallest versionable unit in the common language runtime; all types and resources in the same assembly are versioned as a unit. The assembly's manifest describes the version dependencies you specify for any dependent assemblies. When will NullReferenceException Occurs? The exception that is thrown when there is an attempt to dereference a null object reference. What is bubbling event ?
5
The ASP.NET page framework provides a technique called event bubbling that allows a child control to propagate events up its containment hierarchy. Event bubbling enables events to be raised from a more convenient location in the controls hierarchy and allows event handlers to be attached to the original control as well as to the control that exposes the bubbled event. Event bubbling is used by the data-bound controls (Repeater, DataList, and DataGrid) to expose command events raised by child controls (within item templates) as top-level events. While ASP.NET server controls in the .NET Framework use event bubbling for command events (events whose event data class derives from CommandEventArgs), any event defined on a server control can be bubbled. What is Repeater control? Use the Repeater control to create a basic templated data-bound list. The Repeater control has no built-in layout or styles; you must explicitly declare all HTML layout, formatting, and style tags within the control's templates. The Repeater control is different from other data list controls in that it allows you to place HTML fragments in its templates. This allows you to create a complex HTML structure, such as a table. For example, to create a list within an HTML table, start the table by placing the
tag in the HeaderTemplate. Next, create the rows and columns of the table by placing tags, tags, and data-bound items in the ItemTemplate. If you want a different appearance for alternating items in the table, create an AlternatingItemTemplate with the same contents as the ItemTemplate, except with a different style specified. Finally, complete the table by placing the |
tag in the FooterTemplate. What is Datalist control? Note The DataList control differs from the Repeater control by supporting directional rendering (by use of the RepeatColumns and RepeatDirection properties) and the option to render within an HTML table. The Items collection contains the data-bound members of the DataList control. The collection is populated when the DataBind method is called on the DataList control. The header (if any) is added first, then one Item object for each data row. If a SeparatorTemplate exists, Separators are created and added between each item, but these are not added to the Items collection. After all items have been created for the rows in the DataSource, the Footer is added to the control (but not to the Items collection). Finally, the control raises the ItemCreated event for each item, including the header, footer, and separators. Unlike most collections, the Items collection does not expose Add
6
or Remove methods. However, you can modify the contents within an item by providing a handler for the ItemCreated event. Text is not HTML encoded before it is displayed in the DataList control. This makes it possible to imbed script within HTML tags in the text. If the values for the control come from user input, be sure to validate the values to prevent security vulnerabilities. What is cookie less session? Some mobile devices do not support cookies, so developers must find alternate techniques for scenarios that require persistent state. For example, if a user logs on to a page, the application could assign the developer a logon ID that is used for the remainder of the session. Typically, you use a cookie for this form of authentication, which is called cookie-based authentication. However, cookiebased authentication is not an option for devices that do not support cookies. Instead, the developer must rely on another state management mechanism. Briefly explain about urlEncode, urlDecode, htmlEncode, htmlDecode? • • • •
urlEncode - The urlEncode mode replaces URL reserved characters with encoded versions of those characters. urlDecode - The urlDecode mode replaces encoded URL characters with URL reserved characters. htmlEncode - The htmlEncode mode replaces HTML reserved characters with an encoded version of those characters. htmlDecode - The htmlDecode mode replaces encoded HTML characters with HTML reserved characters.
Required Parameter: • •
string - The string is the string of text to encode. mode - The mode is the function that the mgiInlineString tag performs. In "urlEncode" mode, the mgiInlineString tag replaces all URL reserved characters with an encoded version of the character (e.g., spaces in the URL are replaced with %20 characters).
What are the types of Errors? •
•
Compile-time errors These errors are usually in the syntax of the code and stop the ASP from compiling. You may have experienced this if you left the closing ”Next” statement off of a “For” loop. Runtime errors These happen when you try to execute the ASP page. For example, if you try setting a variable outside its allowed range.
7
•
Logic errors Logic errors are harder to detect. The problem lies within the structure of the code, and the computer cannot detect an error. These types require thorough testing before rolling out the application.
Difference between Debug.write and Trace.write ? The Debug.Write call won’t be compiled when the DEBUG symbol is not defined (when doing a release build). Trace.Write calls will be compiled. Debug.Write is for information you want only in debug builds, Trace.Write is for when you want it in release build as well. And in any case, you should use something like log4net because that is both faster and better Difference between Process vs. Thread ? “Process is unit of allocation while Thread is unit of execution. Each process has one or more threads. Each thread belong to one process” What is the difference between DATASET and DATAREADER? One can say Dataset as a Temporary Database for each client, filtered by that client on the server working on a disconnected architecture. Where as Datareader is similar to a Recordset of VB 6.0 or Classical ASP with Forwardonly cursor. While working with Dataset Connection is closed where as in Datareader Connection is maintained. DataReaader is connected object and one can process the rows that are returned by query, one at a time. It discards every row after you have gone through it and so it is extremely fast.It contains only read-only data, so no updates are allowed using DataReader objects. In DataReader you can not get the no. of records directly from RecordSet.This is similar to VB 6, ForwardOnly RecordSet. Meanwhile DataSet is disconnected object type.It is slow as compare to DataReader but you can do every type of operation by using this. Explaining Objects in ASP Intrinsic Objects Object
Used For
Request
Getting information from the User
Response
Sending information to the User
Session
Storing information about a User's Session
Application Sharing information for the entire application 8
Object
Used For
Server
Accessing the server resources
What is the difference between HTML Server controls and ASP.NET Server Controls ? ASP.NET Server Controls Advantages: 1. ASP .NET Server Controls can however detect the target browser's capabilities and render themselves accordingly. No issues for compatibility issues of Browsers i.e page that might be used by both HTML 3.2 and HTML 4.0 browsers code to be written by you. 2. Newer set of controls that can be used in the same manner as any HTMl control like Calender controls. (No need of Activex Control for doing this which would then bring up issues of Browser compatibility). 3. Processing would be done at the server side. In built functionality to check for few values(with Validation controls) so no need to choose between scripting language which would be incompatible with few browsers. 4. ASP .NET Server Controls have an object model different from the traditional HTML and even provide a set of properties and methods that can change the outlook and behavior of the controls. 5. ASP .NET Server Controls have higher level of abstraction. An output of an ASP .NET server control can be the result of many HTML tags that combine together to produce that control and its events. Disadvantages: 1. The control of the code is inbuilt with the web server controls so you have no much of direct control on these controls 2. Migration of ASP to any ASP.NET application is difficult. Its equivalent to rewriting your new application HTML Server Controls Advantages: 1. The HTML Server Controls follow the HTML-centric object model. Model similar to HTML 2. Here the controls can be made to interact with Client side scripting. Processing would be done at client as well as server depending on your code. 3. Migration of the ASP project thought not very easy can be done by giving each intrinsic HTML control a runat = server to make it HTML Server side control. 4. The HTML Server Controls have no mechanism of identifying the capabilities of the client browser accessing the current page. 9
5. A HTML Server Control has similar abstraction with its corresponding HTML tag and offers no abstraction. Disadvantages: 1. You would need to code for the browser compatibility. HTML Intrinsic Controls Advantages: 1. Model similar to HTML 2. Here the controls can be made to interact with Client side scripting Disadvantages: 1. You would need to code for the browser compatibility How can you validate XMLDocument file using C# and VB.NET? Validating XML Documents Using XmlValidatingReader To validate an XML document, you first load XmlValidatingReader for an XML document by using the Load method. The following code shows how to load XmlValidatingReader to validate an XML document. Code in Visual Basic .NET Dim XMLDoc as XmlDocument = new XmlDocument() Dim Reader as XmlTextReader = new XmlTextReader("emp.xml") Dim Validater as XmlValidatingReader = new XmlValidatingReader(Reader) XMLDoc.Load(Validater) Code in Visual C# XmlDocument XMLDoc = new XmlDocument(); XmlTextReader Reader = new XmlTextReader("emp.xml"); XmlValidatingReader Validater = new XmlValidatingReader(Reader); XMLDoc.Load(Validater); Difference between the ASP.NET Web services and .NET Remoting ? ASP.NET Web Services Protocol State Management Type System
.NET Remoting Can be accessed over any Can be accessed only over protocol (including TCP, HTTP, HTTP SMTP and so on) Provide support for both stateful Web services work in a and stateless environments stateless environment through Singleton and SingleCall objects Web services support only the Using binary communication, .NET datatypes defined in the XSD Remoting can provide support for 10
Interoperability
Reliability
Extensibility Ease-ofProgramming
type system, limiting the number of objects that can be rich type system serialized. Web services support .NET remoting requires the client interoperability across be built using .NET, enforcing platforms, and are ideal for homogenous environment. heterogeneous environments. Can also take advantage of IIS for Highly reliable due to the fact fault isolation. If IIS is not used, that Web services are always application needs to provide hosted in IIS plumbing for ensuring the reliability of the application. Provides extensibility by Very extensible by allowing us to allowing us to intercept the customize the different SOAP messages during the components of the .NET remoting serialization and framework. deserialization stages. Easy-to-create and deploy.
Complex to program.
What is an Authentication? Authentication is the process of discovering and verifying the identity of a principal by examining the user's credentials and validating those credentials against some authority. The information obtained during authentication is directly usable by your code. That is, once the identity of the principal is discovered, you can use .NET Framework role-based security to determine whether to allow that principal to access your code. A variety of authentication mechanisms are used today, many of which can be used with .NET Framework role-based security. Some of the most commonly used mechanisms are basic, digest, Passport, operating system (such as NTLM or Kerberos), or application-defined mechanisms Types of Authentications? Authentication: Basic and Digest Authentication .To use basic and digest authentication, an application must provide a user name and password in the Credentials property of the WebRequest object that it uses to request data from the Internet, When to choose DATASET or DATAREADER? When deciding whether your application should use a DataReader or a DataSet you should consider the type of functionality that your application requires. Use a DataSet to do the following: 11
• • • •
Remote data between tiers or from an XML Web service. Interact with data dynamically such as binding to a Windows Forms control or combining and relating data from multiple sources. Cache data locally in your application. Provide a hierarchical XML view of relational data and use tools like an XSL Transformation or an XML Path Language (XPath) Query on your data. Perform extensive processing on data without requiring an open connection to the data source, which frees the connection to be used by other clients.
If you do not require the functionality provided by the DataSet, you can improve the performance of your application by using the DataReader to return your data in a forward-only read-only fashion. Although the DataAdapter uses the DataReader to fill the contents of a DataSet, by using the DataReader you can receive performance gains because you will save memory that would be consumed by the DataSet, as well as saving the processing required to create and fill the contents of the DataSet. How Remoting or Marshaling Data between Tiers and Clients ? The design of the DataSet enables you to easily transport data to clients over the Web using XML Web services, as well as allowing you to marshal data between .NET components using .NET Remoting services. You can also remote a strongly typed DataSet in this fashion. For an overview of XML Web services. For an example of consuming a DataSet from an XML Web service, see Consuming a DataSet from an XML Web Service. DataTable objects can also be used with remoting services, but cannot be transported via an XML Web service. Describe about dataset ? The ADO.NET DataSet is the core component of the disconnected architecture of ADO.NET. The DataSet is explicitly designed for data access independent of any data source. As a result it can be used with multiple and differing data sources, used with XML data, or used to manage data local to the application. The DataSet contains a collection of one or more DataTable objects made up of rows and columns of data, as well as primary key, foreign key, constraint, and relation information about the data in the DataTable objects. ADO.NET Architecture and components? The ADO.NET components have been designed to factor data access from data manipulation. There are two central components of ADO.NET that accomplish this: the DataSet, and the .NET Framework data provider, which is a set of components including the Connection, Command, DataReader, and DataAdapter objects. 12
The other core element of the ADO.NET architecture is the .NET Framework data provider, whose components are explicitly designed for data manipulation and fast, forward-only, read-only access to data. The Connection object provides connectivity to a data source. The Command object enables access to database commands to return data, modify data, run stored procedures, and send or retrieve parameter information. The DataReader provides a highperformance stream of data from the data source. Finally, the DataAdapter provides the bridge between the DataSet object and the data source. The DataAdapter uses Command objects to execute SQL commands at the data source to both load the DataSet with data, and reconcile changes made to the data in the DataSet back to the data source. You can write .NET Framework data providers for any data source. The .NET Framework ships with two .NET Framework data providers: the .NET Framework Data Provider for SQL Server and the .NET Framework Data Provider for OLE DB. What is Custom Serialization and how will you implement ? You can customize the serialization process by implementing the ISerializable interface on an object. This is particularly useful in cases where the value of a member variable is invalid after deserialization, but you need to provide the variable with a value in order to reconstruct the full state of the object. In addition, you should not use default serialization on a class that is marked with the Serializable attribute and has declarative or imperative security at the class level or on its constructors. Instead, these classes should always implement the ISerializable interface. Implementing ISerializable involves implementing the GetObjectData method and a special constructor that is used when the object is deserialized. The sample code below shows how to implement ISerializable on the MyObject class from a previous section. What is an indexer? Defining an indexer allows you to create classes that act like "virtual arrays." Instances of that class can be accessed using the [] array access operator. Defining an indexer in C# is similar to defining operator [] in C++, but is considerably more flexible. For classes that encapsulate array- or collection-like functionality, using an indexer allows the users of that class to use the array syntax to access the class. For example, suppose you want to define a class that makes a file appear as an array of bytes. If the file were very large, it would be impractical to read the entire file into memory, especially if you only wanted to read or change a few bytes. By defining a FileByteArray class, you could make the file appear similar to an array of bytes, but actually do file input and output when a byte was read or written. 13
What is an abstract Class in C# and VB.net ? Abstract classes are closely related to interfaces. They are classes that cannot be instantiated, and are frequently either partially implemented, or not at all implemented. One key difference between abstract classes and interfaces is that a class may implement an unlimited number of interfaces, but may inherit from only one abstract (or any other kind of) class. A class that is derived from an abstract class may still implement interfaces. Abstract classes are useful when creating components because they allow you specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class is needed. They also version well, because if additional functionality is needed in derived classes, it can be added to the base class without breaking code. An abstract class is denoted in Visual Basic by the keyword MustInherit. In C#, the abstract modifier is used. Any methods that are meant to be invariant may be coded into the base class, but any methods that are to be implemented are marked in Visual Basic with the MustOverride modifier. In C#, the methods are marked abstract. What is polymorphism and types of polymorphism? Polymorphism is the ability for classes to provide different implementations of methods that are called by the same name. Polymorphism allows a method of a class to be called without regard to what specific implementation it provides. For example, you might have a class named Road which calls the Drive method of an additional class. This Car class may be SportsCar, or SmallCar, but both would provide the Drive method. Though the implementation of the Drive method would be different between the classes, the Road class would still be able to call it, and it would provide results that would be usable and interpretable by the Road class. Polymorphism in components can be implemented in a variety of ways: •
•
Interface polymorphism - Multiple classes may implement the same interface, and a single class may implement one or more interfaces. Interfaces are essentially definitions of how a class needs to respond. An interface describes the methods, properties, and events that a class needs to implement, and the type of parameters each member needs to receive and return, but leaves the specific implementation of these members up to the implementing class. Inheritance polymorphism - Multiple classes may inherit from a single base class. By inheriting, a class receives all of the methods, properties, and events of the base class in the same implementation as the base class. Additional members can then be implemented as needed, and base members can be overridden to provide different implementations. Note
14
•
that an inherited class may also implement interfaces — the techniques are not mutually exclusive. Polymorphism through abstract classes - Abstract classes provide elements of both inheritance and interfaces. An abstract class is a class that cannot be instantiated itself; it must be inherited. Some or all members of the class might be unimplemented, and it is up to the inheriting class to provide that implementation. Members that are implemented might still be overridden, and the inheriting class can still implement addition interfaces or other functionality.
How will you generate columns in DataGrid Control Dynamically ? Any time that you add controls to a page dynamically, you have the problem of persistence. Dynamically-added controls (or in this case, columns) are not automatically added to the page's view state, so you are obliged to add logic to the page to make sure the columns are available with each round trip. An excellent way to do this is to override the page's LoadViewState method, which gives you an early opportunity to reestablish columns in the DataGrid control. Because the LoadViewState method is called before the Page_Load event is raised, re-adding columns in the LoadViewState method assures that they are available for normal manipulation by the time any event code runs. How will you hide the columns Dynamically in a DataGrid Control ? You can hide and show columns if you know in advance what columns you need. Sometimes, however, you do not know that until run time. In that case, you can create columns dynamically and add them to the grid. To do so, you create an instance of one of the column classes supported by the grid — BoundColumn, EditCommandColumn, ButtonColumn, or HyperlinkColumn. (You can add template columns to the grid, but it is slightly more complex. Set the column's properties, and then add it to the grid's Columns collection. What is boxing and unboxing? The conversion of a value type instance to an object, which implies that the instance will carry full type information at run time and will be allocated in the heap. The Microsoft intermediate language (MSIL) instruction set's box instruction converts a value type to an object by making a copy of the value type and embedding it in a newly allocated object. The conversion of an object instance to a value type What is CCW and RCW what is the use of it?
15
COM callable wrapper (CCW) : A proxy object generated by the common language runtime so that existing COM applications can use managed classes, including .NET Framework classes, transparently. Runtime callable wrapper(RCW) : A .NET Framework object that acts as a proxy for a reference-counted COM object. What is Context? An ordered sequence of properties that define an environment for the objects resident inside it. Contexts are created during the activation process for objects that are configured to require certain automatic services such as synchronization, transactions, just-in-time activation, security, and so on. Multiple objects can live inside a context. What are the Web Custom Controls and Web User Controls ? 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 also includes user controls. Custom server controls are used in Web Forms (ASP.NET pages). Custom client controls are used in Windows Forms applications. User Controls : In ASP.NET: A server control that is authored declaratively using the same syntax as an ASP.NET page and is saved as a text file with an .ascx extension. User controls allow page functionality to be partitioned and reused. Upon first request, the page framework parses a user control into a class that derives from System.Web.UI.UserControl and compiles that class into an assembly, which it reuses on subsequent requests. User controls are easy to develop due to their page-style authoring and deployment without prior compilation. In Windows Forms: A composite control that provides consistent behavior and user interface within or across applications. The user control can be local to one application or added to a library and compiled into a DLL for use by multiple applications What is a Delegate? A reference type that is the managed version of a C++ function pointer. Delegates can reference both instance and static (in Visual Basic, Shared) methods, whereas function pointers can reference only static (in Visual Basic, Shared) methods. What is the functionality of Garbage Collector? The process of transitively tracing through all pointers to actively used objects in order to locate all objects that can be referenced, and then arranging to reuse any heap memory that was not found during this trace. The common 16
language runtime garbage collector also compacts the memory that is in use to reduce the working space needed for the heap. What is a GAC (Global Assembly Cache )? A machine-wide code cache that stores assemblies specifically installed to be shared by many applications on the computer. Applications deployed in the global assembly cache must have a strong name What is Globalization and Localization ? The process of designing and developing a software product to function in multiple locales. Globalization involves identifying the locales that must be supported, designing features that support those locales, and writing code that functions equally well in any of the supported locales. The process of customizing or translating the separated data and resources needed for a specific region or language. What is JIT? An acronym for "just-in-time," a phrase that describes an action that is taken only when it becomes necessary, such as just-in-time compilation or just-in-time object activation. What Managed code, Un Managed Code and Managed data? Managed code :Code that is executed by the common language runtime environment rather than directly by the operating system. Managed code applications gain common language runtime services such as automatic garbage collection, runtime type checking and security support, and so on. These services provide uniform platform- and language-independent behavior of managed-code applications Un Managed Code : Code that is executed directly by the operating system, outside the common language runtime environment. Unmanaged code must provide its own garbage collection, type checking, security support, and so on, unlike managed code, which receives these services from the common language runtime Managed data : Objects whose lifetimes are managed by the common language runtime. The runtime automatically handles object layout and manages references to these objects, releasing them when they are no longer being used What is a PostBack? The process in which a Web page sends data back to the same page on the server. What is ViewState and Private ViewState?
17
ViewState :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. Private ViewState : State information that is written as a hidden field, such as the form that is currently active or the pagination information for a form What is Roll Based Authention? In .NET Framework security, the process of determining whether a principal is allowed to perform a requested action. Authorization occurs after authentication and uses information about the principal's identity and its associated role to determine the resources a principal can access. What is Side-by-Side Execution ? The ability to install and use multiple versions of an assembly in isolation at the same time. Side-by-side execution can apply to applications and components as well as to the .NET Framework. Allowing assemblies to coexist and to execute simultaneously on the same computer is essential to support robust versioning in the common language runtime. What is Strong Name ? A name that consists of an assembly's identity — its simple text name, version number, and culture information (if provided) — strengthened by a public key and a digital signature generated over the assembly. Because the assembly manifest contains file hashes for all the files that constitute the assembly implementation, it is sufficient to generate the digital signature over just the one file in the assembly that contains the assembly manifest. Assemblies with the same strong name are expected to be identical. Differences between Typed and Un typed Dataset? A typed Data Set is a class that derives from a Dataset. As such, it inherits all the methods, events, and properties of a Dataset. Additionally, a typed DataSet provides strongly typed methods, events, and properties. This means you can access tables and columns by name, instead of using collection-based methods. Aside from the improved readability of the code, a typed DataSet also allows the Visual Studio .NET code editor to automatically complete lines as you type. Additionally, the strongly typed DataSet provides access to values as the correct type at compile time. With a strongly typed DataSet, type mismatch errors are caught when the code is compiled rather than at run time.
18
An untyped dataset, in contrast, has no corresponding built-in schema. As in a typed dataset, an untyped dataset contains tables, columns, and so on — but those are exposed only as collections. (However, after manually creating the tables and other data elements in an untyped dataset, you can export the dataset's structure as a schema using the dataset's WriteXmlSchema method.) Can we use the two dataReader for a single database in our application? No, we can allow using only one dataReader at once, if at all if we want to use another dataReader then we must close first dataReader and the open and use the Second dataReader in our application. We have 100 WebPages in our project, in that you have to allow users in only 20 WebPages. How will you achieve this? We can achieve this by modifying the web.config file. In order to achieve it, place all 20 WebPages which you want to show in a folder and give that folder path in the web.config. Briefly describe the role of global.asax? Answer - The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules. The Global.asax file resides in the root directory of an ASP.NET-based application. At run time, Global.asax is parsed and compiled into a dynamically generated .NET Framework class derived from the HttpApplication base class. The Global.asax file itself is configured so that any direct URL request for it is automatically rejected; external users cannot download or view the code written within it. Global.asax is responsible for handling higher-level application events such as Application_Start, Application_End, Session_Start, Session_End To which namespaces do Trace and Debug belong? Answer - Systems.Diagnostics
What’s the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created. What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
19
The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities. How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger. What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords). Which one is trusted and which one is untrusted? 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. What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings What’s the difference between struct and class in C#? Structs cannot be inherited. Structs are passed by value, not by reference. Struct is stored on the stack, not the heap What’s the difference between const and readonly? You can initialize readonly variables to some runtime values. Let’s say your program uses current date and time as one of the values that won’t change. This way you declare public readonly string DateT = new DateTime().ToString(). How do you turn off Session State in the Web.Config file? In the system.web section of web.config, you should locate the httpmodule tag and you simply disable session by doing a remove tag with attribute name set to session.