Friday, October 23, 2009

.Net Interview Questions

How many languages .NET is supporting now?
When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.


How is .NET able to support multiple languages?
A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.


How ASP .NET different from ASP?
Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.


What is smart navigation?
The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.


What is view state?
The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control

How do you validate the controls in an ASP .NET page?
Using special validation controls that are meant for this. We have Range Validator, Email Validator.


Can the validation be done in the server side? Or this can be done only in the Client side?
Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.


How to manage pagination in a page?
Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.


What is ADO .NET and what is difference between ADO and ADO.NET?
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.

Observations between VB.NET and VC#.NET?
Choosing a programming language depends on your language experience and the scope of the application you are building. While small applications are often created using only one language, it is not uncommon to develop large applications using multiple languages.
For example, if you are extending an application with existing XML Web services, you might use a scripting language with little or no programming effort. For client-server applications, you would probably choose the single language you are most comfortable with for the entire application. For new enterprise applications, where large teams of developers create components and services for deployment across multiple remote sites, the best choice might be to use several languages depending on developer skills and long-term maintenance expectations.
The .NET Platform programming languages - including Visual Basic .NET, Visual C#, and Visual C++ with managed extensions, and many other programming languages from various vendors - use .NET Framework services and features through a common set of unified classes. The .NET unified classes provide a consistent method of accessing the platform's functionality. If you learn to use the class library, you will find that all tasks follow the same uniform architecture. You no longer need to learn and master different API architectures to write your applications.
In most situations, you can effectively use all of the Microsoft programming languages. Nevertheless, each programming language has its relative strengths and you will want to understand the features unique to each language. The following sections will help you choose the right programming language for your application.


Visual Basic .NET
Visual Basic .NET is the next generation of the Visual Basic language from Microsoft. With Visual Basic you can build .NET applications, including Web services and ASP.NET Web applications, quickly and easily. Applications made with Visual Basic are built on the services of the common language runtime and take advantage of the .NET Framework.
Visual Basic has many new and improved features such as inheritance, interfaces, and overloading that make it a powerful object-oriented programming language. Other new language features include free threading and structured exception handling. Visual Basic fully integrates the .NET Framework and the common language runtime, which together provide language interoperability, garbage collection, enhanced security, and improved versioning support. A Visual Basic support single inheritance and creates Microsoft intermediate language (MSIL) as input to native code compilers.
Visual Basic is comparatively easy to learn and use, and Visual Basic has become the programming language of choice for hundreds of thousands of developers over the past decade. An understanding of Visual Basic can be leveraged in a variety of ways, such as writing macros in Visual Studio and providing programmability in applications such as Microsoft Excel, Access, and Word.
Visual Basic provides prototypes of some common project types, including:
• Windows Application.
• Class Library.
• Windows Control Library.
• ASP.NET Web Application.
• ASP.NET Web Service.
• Web Control Library.
• Console Application.
• Windows Service.
• Windows Service.

Visual C# .NET
Visual C# (pronounced C sharp) is designed to be a fast and easy way to create .NET applications, including Web services and ASP.NET Web applications. Applications written in Visual C# are built on the services of the common language runtime and take full advantage of the .NET Framework.
C# is a simple, elegant, type-safe, object-oriented language recently developed by Microsoft for building a wide range of applications. Anyone familiar with C and similar languages will find few problems in adapting to C#. C# is designed to bring rapid development to the C++ programmer without sacrificing the power and control that are a hallmark of C and C++. Because of this heritage, C# has a high degree of fidelity with C and C++, and developers familiar with these languages can quickly become productive in C#. C# provides intrinsic code trust mechanisms for a high level of security, garbage collection, and type safety. C# supports single inheritance and creates Microsoft intermediate language (MSIL) as input to native code compilers.
C# is fully integrated with the .NET Framework and the common language runtime, which together provide language interoperability, garbage collection, enhanced security, and improved versioning support. C# simplifies and modernizes some of the more complex aspects of C and C++, notably namespaces, classes, enumerations, overloading, and structured exception handling. C# also eliminates C and C++ features such as macros, multiple inheritance, and virtual base classes. For current C++ developers, C# provides a powerful, high-productivity language alternative.


Visual C# provides prototypes of some common project types, including:
• Windows Application.
• Class Library.
• Windows Control Library.
• ASP.NET Web Application.
• ASP.NET Web Service.
• Web Control Library.
• Console Application.
• Windows Service.

Advantages of migrating to VB.NET ?
Visual Basic .NET has many new and improved language features — such as inheritance, interfaces, and overloading that make it a powerful object-oriented programming language. As a Visual Basic developer, you can now create multithreaded, scalable applications using explicit multithreading. Other new language features in Visual Basic .NET include structured exception handling, custom attributes, and common language specification (CLS) compliance.

The CLS is a set of rules that standardizes such things as data types and how objects are exposed and interoperate. Visual Basic .NET adds several features that take advantage of the CLS. Any CLS-compliant language can use the classes, objects, and components you create in Visual Basic .NET. And you, as a Visual Basic user, can access classes, components, and objects from other CLS-compliant programming languages without worrying about language-specific differences such as data types. CLS features used by Visual Basic .NET programs include assemblies, namespaces, and attributes. These are the new features to be stated briefly:

Inheritance
Visual Basic .NET supports inheritance by allowing you to define classes that serve as the basis for derived classes. Derived classes inherit and can extend the properties and methods of the base class. They can also override inherited methods with new implementations. All classes created with Visual Basic .NET are inheritable by default. Because the forms you design are really classes, you can use inheritance to define new forms based on existing ones.

Exception Handling
Visual Basic .NET supports structured exception handling, using an enhanced version of the Try...Catch...Finally syntax supported by other languages such as C++.
Structured exception handling combines a modern control structure (similar to Select Case or While) with exceptions, protected blocks of code, and filters. Structured exception handling makes it easy to create and maintain programs with robust, comprehensive error handlers.

Overloading
Overloading is the ability to define properties, methods, or procedures that have the same name but use different data types. Overloaded procedures allow you to provide as many implementations as necessary to handle different kinds of data, while giving the appearance of a single, versatile procedure. Overriding Properties and Methods The Overrides keyword allows derived objects to override characteristics inherited from parent objects. Overridden members have the same arguments as the members inherited from the base class, but different implementations. A member's new implementation can call the original implementation in the parent class by preceding the member name with MyBase.

Constructors and Destructors
Constructors are procedures that control initialization of new instances of a class. Conversely, destructors are methods that free system resources when a class leaves scope or is set to Nothing. Visual Basic .NET supports constructors and destructors using the Sub New and Sub Finalize procedures.

Data Types
Visual Basic .NET introduces three new data types. The Char data type is an unsigned 16-bit quantity used to store Unicode characters. It is equivalent to the .NET Framework System. Char data type. The Short data type, a signed 16-bit integer, was named Integer in earlier versions of Visual Basic. The Decimal data type is a 96-bit signed integer scaled by a variable power of 10. In earlier versions of Visual Basic, it was available only within a Variant.

Interfaces
Interfaces describe the properties and methods of classes, but unlike classes, do not provide implementations. The Interface statement allows you to declare interfaces, while the Implements statement lets you write code that puts the items described in the interface into practice.

Delegates
Delegates objects that can call the methods of objects on your behalf are sometimes described as type-safe, object-oriented function pointers. You can use delegates to let procedures specify an event handler method that runs when an event occurs. You can also use delegates with multithreaded applications. For details, see Delegates and the AddressOf Operator.

Shared Members
Shared members are properties, procedures, and fields that are shared by all instances of a class. Shared data members are useful when multiple objects need to use information that is common to all. Shared class methods can be used without first creating an object from a class.

References
References allow you to use objects defined in other assemblies. In Visual Basic .NET, references point to assemblies instead of type libraries. For details, see References and the Imports Statement. Namespaces Namespaces prevent naming conflicts by organizing classes, interfaces, and methods into hierarchies.

Assemblies
Assemblies replace and extend the capabilities of type libraries by, describing all the required files for a particular component or application. An assembly can contain one or more namespaces.

Attributes
Attributes enable you to provide additional information about program elements. For example, you can use an attribute to specify which methods in a class should be exposed when the class is used as a XML Web service. Multithreading
Visual Basic .NET allows you to write applications that can perform multiple tasks independently. A task that has the potential of holding up other tasks can execute on a separate thread, a process known as multithreading. By causing complicated tasks to run on threads that are separate from your user interface, multithreading makes your applications more responsive to user input.

Advantages of VB.NET
First of all, VB.NET provides managed code execution that runs under the Common Language Runtime (CLR), resulting in robust, stable and secure applications. All features of the .NET framework are readily available in VB.NET.
VB.NET is totally object oriented. This is a major addition that VB6 and other earlier releases didn't have.
The .NET framework comes with ADO.NET, which follows the disconnected paradigm, i.e. once the required records are fetched the connection no longer exists. It also retrieves the records that are expected to be accessed in the immediate future. This enhances Scalability of the application to a great extent.
VB.NET uses XML to transfer data between the various layers in the DNA Architecture i.e. data are passed as simple text strings.
Error handling has changed in VB.NET. A new Try-Catch-Finally block has been introduced to handle errors and exceptions as a unit, allowing appropriate action to be taken at the place the error occurred thus discouraging the use of ON ERROR GOTO statement. This again credits to the maintainability of the code.
Another great feature added to VB.NET is free threading against the VB single-threaded apartment feature. In many situations developers need spawning of a new thread to run as a background process and increase the usability of the application. VB.NET allows developers to spawn threads wherever they feel like, hence giving freedom and better control on the application.
Security has become more robust in VB.NET. In addition to the role-based security in VB6, VB.NET comes with a new security model, Code Access security. This security controls on what the code can access. For example you can set the security to a component such that the component cannot access the database. This type of security is important because it allows building components that can be trusted to various degrees.
The CLR takes care of garbage collection i.e. the CLR releases resources as soon as an object is no more in use. This relieves the developer from thinking of ways to manage memory. CLR does this for them.

Using ActiveX Control in .Net
ActiveX control is a special type of COM component that supports a User Interface. Using ActiveX Control in your .Net Project is even easier than using COM component. They are bundled usually in .ocx files. Again a proxy assembly is made by .Net utility AxImp.exe (which we will see shortly) which your application (or client) uses as if it is a .Net control or assembly.
Making Proxy Assembly For ActiveX Control: First, a proxy assembly is made using AxImp.exe (acronym for ActiveX Import) by writing following command on Command Prompt:
C:>AxImp C:MyProjectsMyControl.ocx
This command will make two dlls, e.g., in case of above command
MyControl.dll
AxMyControl.dll
The first file MyControl.dll is a .Net assembly proxy, which allows you to reference the ActiveX as if it were non-graphical object.
The second file AxMyControl.dll is the Windows Control, which allows u to use the graphical aspects of activex control and use it in the Windows Form Project.
Adding Reference of ActiveX Proxy Assembly in your Project Settings: To add a reference of ActiveX Proxy Assembly in our Project, do this:
o Select ProjectàAdd Reference (Select Add Reference from Project Menu).
o This will show you a dialog box, select .Net tab from the top of window.
o Click Browse button on the top right of window.
o Select the dll file for your ActiveX Proxy Assembly (which is MyControl.dll) and click OK o Your selected component is now shown in the ‘Selected Component’ List Box. Click OK again Some More On Using COM or ActiveX in .Net
.Net only provides wrapper class or proxy assembly (Runtime Callable Wrapper or RCW) for COM or activeX control. In the background, it is actually delegating the tasks to the original COM, so it does not convert your COM/activeX but just imports them.
A good thing about .Net is that when it imports a component, it also imports the components that are publically referenced by that component. So, if your component, say MyDataAcsess.dll references ADODB.dll then .Net will automatically import that COM component too!
The Visual Studio.NET does surprise you in a great deal when u see that it is applying its intellisense (showing methods, classes, interfaces, properties when placing dot) even on your imported COM components!!!! Isn’t it a magic or what?
When accessing thru RCW, .Net client has no knowledge that it is using COM component, it is presented just as another C# assembly.
U can also import COM component thru command prompt (for reference see Professional C# by Wrox) U can also use your .Net components in COM, i.e., export your .net components (for reference see Professional C# by Wrox)

What is Machine.config?
Machine configuration file: The machine.config file contains settings that apply to the entire computer. This file is located in the %runtime install path%Config directory. There is only one machine.config file on a computer. The Machine.Config file found in the "CONFIG" subfolder of your .NET Framework install directory (c:WINNTMicrosoft.NETFramework{Version Number}CONFIG on Windows 2000 installations). The machine.config, which can be found in the directory $WINDIR$Microsoft.NETFrameworkv1.0.3705CONFIG, is an XML-formatted configuration file that specifies configuration options for the machine. This file contains, among many other XML elements, a browserCaps element. Inside this element are a number of other elements that specify parse rules for the various User-Agents, and what properties each of these parsings supports.
For example, to determine what platform is used, a filter element is used that specifies how to set the platform property based on what platform name is found in the User-Agent string. Specifically, the machine.config file contains:
platform=Win95
platform=Win98
platform=WinNT
...
That is, if in the User-Agent string the string "Windows 95" or "Win95" is found, the platform property is set to Win95. There are a number of filter elements in the browserCaps element in the machine.config file that define the various properties for various User-Agent strings.
Hence, when using the Request.Browser property to determine a user's browser features, the user's agent string is matched up to particular properties in the machine.config file. The ability for being able to detect a user's browser's capabilities, then, is based upon the honesty in the browser's sent User-Agent string. For example, Opera can be easily configured to send a User-Agent string that makes it appear as if it's IE 5.5. In this case from the Web server's perspective (and, hence, from your ASP.NET Web page's perspective), the user is visiting using IE 5.5, even though, in actuality, he is using Opera.

What is Web.config?
In classic ASP all Web site related information was stored in the metadata of IIS. This had the disadvantage that remote Web developers couldn't easily make Web-site configuration changes. For example, if you want to add a custom 404 error page, a setting needs to be made through the IIS admin tool, and you're Web host will likely charge you a flat fee to do this for you. With ASP.NET, however, these settings are moved into an XML-formatted text file (Web.config) that resides in the Web site's root directory. Through Web.config you can specify settings like custom 404 error pages, authentication and authorization settings for the Web sitempilation options for the ASP.NET Web pages, if tracing should be enabled, etc.
The Web.config file is an XML-formatted file. At the root level is the tag. Inside this tag you can add a number of other tags, the most common and useful one being the system.web tag, where you will specify most of the Web site configuration parameters. However, to specify application-wide settings you use the tag.
For example, if we wanted to add a database connection string parameter we could have a Web.config file like so.

What is the difference between ADO and ADO.NET?
ADO uses Recordsets and cursors to access and modify data. Because of its inherent design, Recordset can impact performance on the server side by tying up valuable resources. In addition, COM marshalling - an expensive data conversion process - is needed to transmit a Recordset. ADO.NET addresses three important needs that ADO doesn't address:
1. Providing a comprehensive disconnected data-access model, which is crucial to the Web environment
2. Providing tight integration with XML, and
3. Providing seamless integration with the .NET Framework (e.g., compatibility with the base class library's type system). From an ADO.NET implementation perspective, the Recordset object in ADO is eliminated in the .NET architecture. In its place, ADO.NET has several dedicated objects led by the DataSet object and including the DataAdapter, and DataReader objects to perform specific tasks. In addition, ADO.NET DataSets operate in disconnected state whereas the ADO RecordSet objects operated in a fully connected state.
In ADO, the in-memory representation of data is the recordset. In ADO.NET, it is the dataset. A recordset looks like a single table. If a recordset is to contain data from multiple database tables, it must use a JOIN query, which assembles the data from the various database tables into a single result table. In contrast, a dataset is a collection of one or more tables. The tables within a dataset are called data tables; specifically, they are DataTable objects. If a dataset contains data from multiple database tables, it will typically contain multiple DataTable objects. That is, each DataTable object typically
corresponds to a single database table or view. In this way, a dataset can mimic the structure of the underlying database. In ADO you scan sequentially through the rows of the recordset using the ADO MoveNext method. In ADO.NET, rows are represented as collections, so you can loop through a table as you would through any collection, or access particular rows via ordinal or primary key index. A cursor is a database element that controls record navigation, the ability to update data, and the visibility of changes made to the database by other users. ADO.NET does not have an inherent cursor object, but instead includes data classes that provide the functionality of a traditional cursor. For example, the functionality of a forward-only, read-only cursor is available in the ADO.NET DataReader object.
There is one significant difference between disconnected processing in ADO and ADO.NET. In ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter object), which makes calls to an OLE DB provider or the APIs provided by the underlying data source.

What is the difference between VB and VB.NET?
Now VB.NET is object-oriented language. The following are some of the differences:
Data Type Changes
The .NET platform provides Common Type System to all the supported languages. This means that all the languages must support the same data types as enforced by common language runtime. This eliminates data type incompatibilities between various languages. For example on the 32-bit Windows platform, the integer data type takes 4 bytes in languages like C++ whereas in VB it takes 2 bytes. Following are the main changes related to data types in VB.NET:
. Under .NET the integer data type in VB.NET is also 4 bytes in size.
. VB.NET has no currency data type. Instead it provides decimal as a replacement.
. VB.NET introduces a new data type called Char. The char data type takes 2 bytes and can store Unicode characters.
. VB.NET do not have Variant data type. To achieve a result similar to variant type you can use Object data type. (Since every thing in .NET including primitive data types is an object, a variable of object type can point to any data type).
. In VB.NET there is no concept of fixed length strings.
. In VB6 we used the Type keyword to declare our user-defined structures. VB.NET introduces the structure keyword for the same purpose.
Declaring Variables

What is a Manifest?
An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes. The assembly manifest can be stored in either a PE (Portable Executable) file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE (Portable Executable) file that contains only assembly manifest information. The following table shows the information contained in the assembly manifest. The first four items the assembly name, version number, culture, and strong name information make up the assembly's identity. Assembly name: A text string specifying the assembly's name. Version number: A major and minor version number, and a revision and build number. The common language runtime uses these numbers to enforce version policy.
Culture: Information on the culture or language the assembly supports. This information should be used only to designate an assembly as a satellite assembly containing culture- or language-specific information. (An assembly with culture information is automatically assumed to be a satellite assembly.) Strong name information: The public key from the publisher if the assembly has been given a strong name. List of all files in the assembly: A hash of each file contained in the assembly and a file name. Note that all files that make up the assembly must be in the same directory as the file containing the assembly manifest. Type reference information: Information used by the runtime to map a type reference to the file that contains its declaration and implementation. This is used for types that are exported from the assembly.
Information on referenced assemblies: A list of other assemblies that are statically referenced by the assembly. Each reference includes the dependent assembly's name, assembly metadata (version, culture, operating system, and so on), and public key, if the assembly is strong named.

Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.

inetinfo.exe is theMicrosoft 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 tothe actual worker process aspnet_wp.exe.

What’s the difference between Response.Write() andResponse.Output.Write()?

Response.Output.Write() allows you to write formatted output.

What methods are fired during the page load?

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.

When during the page processing cycle is ViewState available?

After the Init() and before the Page_Load(), or OnLoad() for a control.

What namespace does the Web page belong in the .NET Framework class hierarchy?

System.Web.UI.Page

Where do you store the information about the user’s locale?

System.Web.UI.Page.Culture

What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?

CodeBehind is relevant to Visual Studio.NET only.

What’s a bubbled event?

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 eventhandlers, allowing the main DataGrid event handler to take care of its constituents.

Suppose you want a certain ASP.NET function executed on MouseOver for a certain button. Where do you add an event handler?

Add an OnMouseOver attribute to the button. Example: btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();");

What data types do the RangeValidator control support?

Integer, String, and Date.

Explain the differences between Server-side and Client-side code?

Server-side code executes on the server. Client-side code executes in the client's browser.

What type of code (server or client) is found in a Code-Behind class?

The answer is server-side code since code-behind is executed on the server. However, during the code-behind's execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser. But just to be clear, code-behind executes on the server, thus making it server-side code.

Should user input data validation occur server-side or client-side? Why?

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.

What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?

Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's 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 user's browser to another page or site. This performas a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.

Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?

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.

· There's 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.

What is the Global.asax used for?

The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.

What are the Application_Start and Session_Start subroutines used for?

This is where you can set the specific variables for the Application and Session objects.

Can you explain what inheritance is and an example of when you might use it?

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.

Whats an assembly?

Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN

Describe the difference between inline and code behind.

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.

Explain what a diffgram is, and a good use for one?

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.

Whats MSIL, and why should my developers need an appreciation of it if at all?

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.

Which method do you invoke on the DataAdapter control to load your generated dataset with data?

The Fill() method.

Can you edit data in the Repeater control?

No, it just reads the information from its data source.

Which template must you provide, in order to display data in a Repeater control?

ItemTemplate.

How can you provide an alternating color scheme in a Repeater control?

Use the AlternatingItemTemplate.

What property must you set, and what method must you call in your code, in order to bind the data from a data source to the Repeater control?

You must set the DataSource property and call the DataBind method.

What base class do all Web Forms inherit from?

The Page class.

Name two properties common in every validation control?

ControlToValidate property and Text property.

Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?

DataTextField property.

Which control would you use if you needed to make sure the values in two different controls matched?

CompareValidator control.

How many classes can a single .NET DLL contain?

It can contain many classes.

Web Service Questions

What is the transport protocol you use to call a Web service?

SOAP (Simple Object Access Protocol) is the preferred protocol.

True or False: A Web service can only be written in .NET?

False

What does WSDL stand for?

Web Services Description Language.

Where on the Internet would you look for Web services?

http://www.uddi.org

True or False: To test a Web service you must create a Windows application or Web application to consume this service?

False, the web service comes with a test page and it provides HTTP-GET method to test.

State Management Questions

What is ViewState?

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 the retain the state of server-side objects between postabacks.

What is the lifespan for items stored in ViewState?

Item stored in ViewState exist for the life of the current page. This includes postbacks (to the same page).

What does the "EnableViewState" property do? Why would I want it on or off?

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.

What are the different types of Session state management options available with ASP.NET?

ASP.NET provides In-Process and Out-of-Process state management. In-Process 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.

What’s a Windows process?

It’s an application that’s running and had been allocated memory.

What’s typical about a Windows process in regards to memory allocation?

Each process is allocated its own block of available RAM space, no process can access another process’ code or data. If the process crashes, it dies alone without taking the entire OS or a bunch of other applications down.

Explain what relationship is between a Process, Application Domain, and Application?

A process is an instance of a running application. An application is an executable on the hard drive or network. There can be numerous processes launched of the same application (5 copies of Word running), but 1 process can run just 1 application.

What are possible implementations of distributed applications in .NET?

.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.

What are the consideration in deciding to use .NET Remoting or ASP.NET Web Services?

Remoting is a more efficient communication exchange when you can control both ends of the application involved in the communication process. Web Services provide an open-protocol-based exchange of informaion. Web Services are best when you need to communicate with an external organization or another (non-.NET) technology.

What’s a proxy of the server object in .NET Remoting?

It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.

What are remotable objects in .NET Remoting?

Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.

What are channels in .NET Remoting?

Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.

What security measures exist for .NET Remoting in System.Runtime.Remoting?

None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.

What is a formatter?

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.

Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs?

Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.

What’s SingleCall activation mode used for?

If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.

What’s Singleton activation mode?

A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease.

How do you define the lease of the object?

By implementing ILease interface when writing the class code.

Can you configure a .NET Remoting object via XML file?

Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.

How can you automatically generate interface for the remotable object in .NET with Microsoft tools?

Use the Soapsuds tool.

Does C# support multiple-inheritance?

No.

Who is a protected class-level variable available to?

It is available to any sub-class (a class inheriting this class).

Are private class-level variables inherited?

Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.

Describe the accessibility modifier “protected internal”.

It is available to classes that are within the same assembly and derived from the specified base class.

What’s the top .NET class that everything is derived from?

System.Object.

What does the term immutable mean?

The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.

What’s the difference between System.String and System.Text.StringBuilder classes?

System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

What’s the advantage of using System.Text.StringBuilder over System.String?

StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.

Can you store multiple data types in System.Array?

No.

What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?

The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.

What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?

By calling Sort() and then Reverse() methods.

What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?

HashTable.

What class is underneath the SortedList class?

A sorted HashTable.

Will the finally block get executed if an exception has not occurred?

Yes.

What’s the C# syntax to catch any possible exception?

A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?

No. Once the proper catch block processed, control is transferred to the finally block (if there are any).

What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?

Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).

Class Questions

What is the syntax to inherit from a class in C#?

Place a colon and then the name of the base class.

Example: class MyNewClass : MyBaseClass

Can you prevent your class from being inherited by another class?

Yes. The keyword “sealed” will prevent the class from being inherited.

Can you allow a class to be inherited, but prevent the method from being over-ridden?

Yes. Just leave the class public and make the method sealed.

What’s an abstract class?

A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.

When do you absolutely have to declare a class as abstract?

1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.

2. When at least one of the methods in the class is abstract.

What is an interface class?

Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.

Why can’t you specify the accessibility modifier for methods inside the interface?

They all must be public, and are therefore public by default.

Can you inherit multiple interfaces?

Yes. .NET does support multiple interfaces.

What happens if you inherit multiple interfaces and they have conflicting method names?

It’s 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 you’re okay.

To Do: Investigate

What’s the difference between an interface and abstract class?

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.

What is the difference between a Struct and a Class?

Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.

Method and Property Questions

What’s the implicit name of the parameter that gets passed into the set method/property of a class?

Value. The data type of the value parameter is defined by whatever data type the property is declared as.

What does the keyword “virtual” declare for a method or property?

The method or property can be overridden.

How is method overriding different from method overloading?

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.

Can you declare an override method to be static if the original method is not static?

No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)

What are the different ways a method can be overloaded?

Different parameter data types, different number of parameters, different order of parameters.

If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?

Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

Events and Delegates

What’s a delegate?

A delegate object encapsulates a reference to a method.

What’s a multicast delegate?

A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.

XML Documentation Questions

Is XML case-sensitive?

Yes.

What’s the difference between // comments, /* */ comments and /// comments?

Single-line comments, multi-line comments, and XML documentation comments.

How do you generate documentation from the C# file commented properly with a command-line compiler?

Compile it with the /doc switch.

Debugging and Testing Questions

What debugging tools come with the .NET SDK?

1. CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch.

2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR.

What does assert() method do?

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.

What’s the difference between the Debug class and Trace class?

Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.

Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

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.

Where is the output of TextWriterTraceListener redirected?

To the Console or a text file depending on the parameter passed to the constructor.

How do you debug an ASP.NET Web application?

Attach the aspnet_wp.exe process to the DbgClr debugger.

What are three test cases you should go through in unit testing?

1. Positive test cases (correct data, correct output).

2. Negative test cases (broken or missing data, proper handling).

3. Exception test cases (exceptions are thrown and caught properly).

Can you change the value of a variable while debugging a C# application?

Yes. If you are debugging via Visual Studio.NET, just go to Immediate window.

ADO.NET and Database Questions

What is the role of the DataReader class in ADO.NET connections?

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.

What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?

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 it’s not as fastest and efficient as SqlServer.NET.

What is the wildcard character in SQL?

Let’s 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%’.

Explain ACID rule of thumb for transactions.

A transaction must be:

1. Atomic - it is one unit of work and does not dependent on previous and following transactions.

2. Consistent - data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t.

3. Isolated - no transaction sees the intermediate results of the current transaction).

4. Durable - the values persist if the data had been committed even if the system crashes right after.

What connections does Microsoft SQL Server support?

Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password).

Between Windows Authentication and SQL Server Authentication, 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 does the Initial Catalog parameter define in the connection string?

The database name to connect to.

What does the Dispose method do with the connection object?

Deletes it from the memory.

To Do: answer better. The current answer is not entirely correct.

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. The connection string must be identical.

Assembly Questions

How is the DLL Hell problem solved in .NET?

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.

What are the ways to deploy an assembly?

An MSI installer, a CAB archive, and XCOPY command.

What is a satellite assembly?

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.

What namespaces are necessary to create a localized application?

System.Globalization and System.Resources.

What is the smallest unit of execution in .NET?

an Assembly.

When should you call the garbage collector in .NET?

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.

How do you convert a value-type to a reference-type?

Use Boxing.

What happens in memory when you Box and Unbox a value-type?

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.

What are the differences between ASP and ASP .Net ?

ASP: Code is Interpreted
ASP.NET: Code is Compiled
ASP: Business Logic and Presentation Logic are in a single file
ASP.NET: Business Logic and Presentation Logic are in separate files (.cs or
.vb) and (.aspx) respectively.
ASP: No Web Server Controls
ASP.NET: Web Server Controls supported by strong .NET Framework
ASP: No RAD* in Classic ASP
ASP.NET: Supports RAD
_________________________
* RAD – Rapid Application Development
Or

1.Asp is interpreted
Asp.net is compiled which is faster than asp.
2 Asp.net maintains its own CLR and is managed as it runs by CLR
Where as asp is unmanaged
3 We can mainatin sessions in state server and sql server which is Outproc,
where in asp sessions will be last if we restart webserver or make changes.
4 In asp.net we can configure each application using web.config file which is availble in application itself and we have machine.config wherer we can configure all applications.
In asp we cannot configure single aplication
5 Asp.net we have autopostback event which is not in asp
6 In asp.net we have global.asax where can hadle some global things which is not in asp.
7 We have well built GUI to work in asp.net
8 We have ado.net and as well as disconnected architecture in asp.net
9 We have Xcopy deployment in asp.net
10. We can work with any language as code behind technique in asp.net that supports .net frame work

Differences between Datagrid, Datalist and Repeater?

1. Datagrid has paging while Datalist doesnt.
2. Datalist has a property called repeat. Direction = vertical/horizontal. (This is of great help in designing layouts). This is not there in Datagrid.
3. A repeater is used when more intimate control over html generation is required.
4. When only checkboxes/radiobuttons are repeatedly served then a checkboxlist or radiobuttonlist are used as they involve fewer overheads than a Datagrid.
The Repeater repeats a chunk of HTML you write, it has the least functionality of the three. DataList is the next step up from a Repeater; accept you have very little control over the HTML that the control renders. DataList is the first of the three controls that allow you Repeat-Columns horizontally or vertically. Finally, the DataGrid is
the motherload. However, instead of working on a row-by-row basis, you’re working on a column-by-column basis. DataGrid caters to sorting and has basic paging for your disposal. Again you have little contro, over the HTML. NOTE: DataList and DataGrid both render as HTML tables by default. Out of the 3 controls, I use the Repeater the most due to its flexibility w/ HTML. Creating a Pagination scheme isn't that hard, so I rarely if ever use a DataGrid.
Occasionally I like using a DataList because it allows me to easily list out my records in rows of three for instance.

Explain dotnet framework ?
The dot net Framework has two main components CLR and .NET Libraries. CLR (common language runtimes), that actually runs the code manages so many things for example code execution, garbage collection, memory allocation, thread management etc. Apart from CLR, the .NET framework contains .NET libraries, which are collection of namespaces and classes. The classes and namespaces are kept in a systematic way and can be used in making any application, code reuability etc. The root namespace of .NET framework is System, with this namespace many namespaces like web (system.web), data (system.data), windows (system.windows) are generated which can be further have their namespaces.

What is the difference between Metadata and Menifest ?
Menifest descriubes the assembely itself. Assembely name, version number, culture information. strong name, list of all files, type reference and reference assembely. While the Metadata describes the contents within the assembely. like classes, interfaces, namespaces, base class, scope, properties and their parameters etc.

What are public(Shared) and private assemblies ? differences and scope ?
Public assembly are the dll/exe file that can be used in different application.

The main advantage of public assemblies is code reusability. These can be used in different machine on different computers. These are also called as shared assemblies. Private assembly is the assembelyinfo.cs or assembelyinfo.vb file within an application. An application must have one private assembely, outside this application there is no scope of privaet assembely.

What is an Assembly ?
Assemblies are the fundamental buildung block of .NET framework. They contains the type and resources that are useful to make an application Assembly enables code reuse, version control, security and deployment. An assembely can have four parts :Menifest, Type metadata, MSIL and Resource file

What is GAC ?
GAC (global assembelu cache) Its an space (directory C:\winnt\assembely) on the server where all the shared assemblies are registrered and that can be used in the application for code reuse.

What do you know about Machine.Config file ?
Its a base configuration file for all .NET assemblies running on the server. It specifies

a settings that are global to a perticular machine.


Different types of authentication modes in .NET Framework ?
Windows, Forms, Passport and None.

What is Strong name ?

Strong name ensures the uniqueness of assembely on the server. A strong name incudes information about Assembely version, Public/Private Key token, Culture information and ASsembely name.

Where does the GAC exist ?
By defauit C:\\assembely e.g c:\winnt\assembely or c:\windows\assembely

What are different types that a variable can be defined and their scopes ?


Public- Can be accessed anywhere
Private- anywhere in the same class
Protected -winthin the class and the class that inherites this class
Friend- Members of the class within the assembely
Protected friend- member of assembely or inheriting class

What is DLL HELL ?
Previously (when using VB)we can have a situation that we have to put same name dll file in a single directory , but the dlls are of different versions. This is known as dll hell.


What is COM, COM+ and DCOM ?
COM (Component Object Model) A standard that is used to for communication between OS and the softwares. COM is used to create reusable software components


COM+ : COM+ is an extension of Component Object Model (COM). COM+ is both an OOP architecture and a set of operating system services.
DCOM an extension of the Component Object Model (COM) that allows COM components to communicate across network boundaries. Traditional COM components can only perform interprocess communication across process boundaries on the same machine. DCOM uses the RPC mechanism to transparently send and receive information between COM components (i.e., clients and servers) on the same network.

What is boxing and unboxing ?
Implicit (manual) conversion of value type to reference type of a variable is known as BOXING, for example integer to object type conversion Conversion of Boxed type variable back to value type is called as UnBoxing.

what is connected and diconnected database ?
Connected and Disconneted database basically the approach that how you handle the database connection, It may be connected that once the application starts you have to open the connection only for a single time and then performs many transactions and close the connection just before exit the application. This approch will be generally used in windows based application. On other hand disconnected architecter refere to open and close the connection for each time while performing a transaction.

What is garbage collection and how it works ?
Garbage Collection is Automatic Memory Manager for the dotnet framework. It manages the momery allocated to the .NET framework. CLR takes cares about .NET framework. When a variable is defined, Its gets a space in the memory and when the program control comes out of that function the scope of variable gets ended, so the garbage collection acts on and memory will releases.


What are the different types of caching ?
Output caching, Fragment Caching and Data caching.


What do you mean by authentication and authorization ?
Authentication is the process of validating a user on the credentials(username and password) and authorization performs after authentication. After Authentication a user will varified for performing the various tasks, It access is limited it is known as authorization.


What is Setellite Assemblies ?

Setellite assemblies holds the cultural information. Cultural refers the cultural information about the region in the the application is going to use.

What are different types of directives in .NET ?
Page, Outputcache, Register

How to use Dataview property ?
How to reflect updation of data in dataset to database ?
What is is advantage of Dataset over Datareader ?
What is advantage of Datareader over dataset ?
What are the different types a command can be execute ? (execute reader, executenonquery.. )
What is ViewState ? and how it is managed ?
How you will set the datarelation between two coloumns ?
What are advantage of viewstate and what are benifits ?
How doyou turn off cookies in one page of your asp.net application ?
Dataset is always disconnected ? True

What is the difference between user controls and custom controls?
CUSTOM CONTROLS are DLL'S.It can be placed in the toolbox.Drag and drop controls.
USER CONTROLS: are pages (.ascx).It can not be placed in the tool box.


What are the 3 types of session state modes?
a.Inproc- session kept as live object in the web server(aspnet_wp.exe)
b.Stateserver-Session serialized and stored in memory in a seperate process(aspnet_state.exe),we can use for webform architecture.

c.SQLServer-Session serialized and stored in sql server.

what are the 6 types of validation controls in ASP.NET?
1.Required Field validator.2.Range validator.3.Regular Expression validator.4.compare validator.5custom validator.
6.validation summary.


What are the 3 types of caching in ASP.NET?
1. Output Caching(Page Caching)- stores the responses from an asp.net page(aspx) or user control(.ascx).
2.Fragment Caching(Partial Caching)- Only stores the portion of a page.
3. Data Caching is the programmatic way to your objects to a managed cache.
//Add item
Cache["TopProducts"] = objTopProductsDataset;
//Retrieve item
objDataset = Cache["TopProducts"];

How to Manage state in ASP.NET?
we can manage the state in two ways
Clent based techniques are
Viewstate, Query strings and Cookies.
Server based techniques are
Application and Session


What is the difference between overloading and shadowing?
Overloading ----------- A Member has the name, but something else in the signature is different.
Shadowing --------- A member shadows another member if the derived member replaces the base member


what is the difference between overloading and overriding?
Overloading : Method name remains the same with different signatures.
Overriding : Method name and Signatures must be the same.


what is the difference between Manifest and Metadata?
Manifest:

Manifest describes assembly itself.
Assembly Name,version number,culture,strongname,listof all all files,Type references,and referenced assemblies.
MetaData:
Metadata describes contents in an assembly
classes, interfaces, enums, structs, etc., and their containing namespaces, the name of each type,
its visibility/scope, its base class, the interfaces it implemented, its methods and their scope
, and each method’s parameters, type’s properties, and so on.


What is Boxing and Unboxing?
Boxing is an implicit conversion of a value type to the type object
int i = 123; // A value type
Object box = i // Boxing
CASTING : casting is the process of converting a variable from one type to another (from a string to an integer )
Unboxing is an explicit conversion from the type object to a value type
int i = 123; // A value type
object box = i; // Boxing
int j = (int)box; // Unboxing

what are the method parameter in c#?
C# is having 4 parameter types which are
1.Value Parameter. default parameter type. Only Input
2.Reference(ref) Parameter. Input\Output
3.Output(out) Parameter.
4.Parameter(params) Arrays

what are value types and reference types?
Value type
bool, byte,chat, decimal,double,enum , float, int, long, sbyte, short, strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type
class, delegate, interface, object, string
Reference types are stored in the Heap

what are the two activation modes for .NET Remoting?
1. Singleton 2. Singlecall

what's singlecall Activation mode used for ?

The Server Object is instantiated for responding to just one single request


what's the singleton Activation mode used for?
The server object is instantiated for responding number of clients


what are the channels and Formatters?
Channels
HTTP and TCP
Binay Over TCP is most efficient
SOAP over HTTP is most interoperable
Formatters
Binary and SOAP


What are the two Authentication modes for SQL server connection?
1. Trusted Connection - Windows Authentication
2. Non trusted Connection - Sql Server Authentication(its preferable for webservices)

What is typed dataset?
Data Access is normally done using indexes on collections in object model.
In ADO.NET it is possible to create a variation on a Dataset that does support
such syntax.Such Dataset is called "Typed Dataset".
Errors in the syntax are detected during compile time rather than runtime.
Advantages of Typed Dataset:
1.The data designer tool generates typed Datasets.
2.When we type the name of a dataset while writing a code,
weget a list of all available tables in the dataset.No need to
remember the table names.
For (eg) instead of typing
myDataset.Tables("products")
we can type
myDataset.products.

what is DataReader?
DataReader is a read only stream of data returned from
the database as the query executes.
It contains one row of data in memory at a time and is
restricted to navigating forward only in the results one record at a time.
Datareader supports access to multiple result sets but only one at a time and in the order retrieved.
In ADO data is no longer available through the Datareaderoncethe connection to the datasource is closed
which means a Datareader requires a connection to the Database throughout its usage.
o/p parameters or return values are only available thrugh the Datareader once the connection is closed.

Difference between Dataset and Recordset?
The Recordset was not XML-based and could not be serialized to XML easily or flexibly.
Finally, a Recordset was not independent of a data store because it tracked a Connection object
and through its methods could send queries to the data source to populate, update,
and refresh its data.
To that end, the Recordset contained functionality found in the ADO.NET DataSet,
data reader, and data adapter objects.

Similar to the DataSet, a Recordset could be disconnected from its data store
and therefore act as an in-memory cache of data.
Of course, it could also be used in a connected model depending on the cursor options that were set.
Although the Recordset object stored multiple versions of each column for each of its rows,
it was not by nature able to represent multiple tables without the use of the Data Shape Provider.

what is an Delegate?
A strongly typed function pointer. A delegate object encapsulates a reference to a method.

what are webservices?

A Web Service is an application that delivers a service across the Internet using the standards and technologies defined in the Web Services architecture in a platform-independent and language-neutral fashion.
Web Services rely on several XML protocols based on open standards that are collectively known as the Web Services architecture

Define Automatic memory Management:
c# Provides Automatic memory Management.
Automatic memory Management increases code quality and enhances developer productivity without negatively impacting.
either expressivenessor perfromance.Developers are freed from this burdensome task.

Define Threading:
It's a process of creating applications that can perform multiple tasks independently.

Difference Between XML AND HTML?
XML:

User definable tags.
Content driven
End tags required for well formed documents
Quotes required around attributes values


Slash required in empty tags
HTML :
Defined set of tags designed for web display
Format driven
End tags not required
Quotes not required
Slash not required


What is XSLTand what is it's use?
XSL Transformations (XSLT) is yet another popular W3C specification that defines XML-based syntax, used to transform XML documents to any other text format, such as HTML, text, XML, etc. XSLT stylesheets can be applied on the source XML document to transform XML into some other XML, or text, HTML, or any other text format.

What is Diffgram?
It's an XML format.
It'sone of the two xml formats that uses to render Dataset object contents to XML.
For reading database data to an XML file to be sent to a webservice.


what is the Role of XSL?
Querying a database and then formatting the result set so that it can be validated as an XML document allows developers to translate the data into an HTML table using XSLT rules. Consequently, the format of the resulting HTML table can be modified without changing the database query or application code since the document rendering logic is isolated to the XSLT rules


What is SAX?
Simple API for XML Processing (SAX) is an alternative to DOM, and can be used to parse XML documents. SAX is based on streaming model. The SAX parser reads input XML stream and generates various parsing events that an application can handle. With each parsing event, the parser sends sufficient information about the node being parsed. Unlike DOM, SAX does not build an in-memory representation of the source XML document, and hence it is an excellent alternative when parsing large XML documents, as SAX does not require that much memory (and resources). Unlike DOM, SAX is not defined/controlled by W3C. See http://www.saxproject.org/ for details.

Give a few examples of types of applications that can benefit from using XML.
XML allows content management systems to store documents independently of their format, which thereby reduces data redundancy. Another answer relates to B2B exchanges or supply chain management systems. In these instances, XML provides a mechanism for multiple companies to exchange data according to an agreed upon set of rules. A third common response involves wireless applications that require WML to render data on hand held devices.

When constructing an XML DTD, how do you create an external entity reference in an attribute value?
when using SGML, XML DTDs don't support defining external entity references in attribute values.


Give some examples of XML DTDs or schemas that you have worked with.
Although XML does not require data to be validated against a DTD, many of the benefits of using the technology are derived from being able to validate XML documents against business or technical architecture rules. Polling for the list of DTDs that developers have worked with provides insight to their general exposure to the technology.commonly used DTDs such as FpML, DocBook, HRML, and RDF, as well as experience designing a custom DTD for a particular project


What is SOAP and how does it relate to XML?
The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML.


What is WSDL?
Another key standard in the Web Services architecture is the Web Services Description Language, or WSDL for short. Whereas SOAP is responsible for providing a platform-neutral protocol for transporting data types and interapplication messaging, WSDL is an XML grammar responsible for exposing the methods, arguments, and return parameters exposed by a particular Web Service.

What’s the difference between authentication and authorization? Authentication happens first. You verify user’s identity based on credentials. Authorization is making sure the user only gets access to the resources he has credentials for.


Explain loosely coupled events.? Loosely coupled events enable an object (publisher) to publish an event. Other objects (subscribers) can subscribe to an event. COM+ does not require publishers or subscribers to know about each other. Therefore, loosely coupled events greatly simplify the programming model for distributed applications.


Define scalability.
The application meets its requirement for efficiency even if the number of users increases.


Define reliability.
The application generates correct and consistent information all the time.


Define availability.
Users can depend on using the application when needed.


Define security.
The application is never disrupted or compromised by the efforts of malicious or ignorant users


Define manageability.
Deployment and maintenance of the application is as efficient and painless as possible


Explain durability.
Make sure that the system can return to its original state in case of a failure.


Explain integrity.
Ensure data integrity by protecting concurrent transactions from seeing or being adversely affected by each other’s partial and uncommitted results.


Explain consistency.
We must ensure that the system is always left at the correct state in case of the failure or success of a transaction.

Explain JIT activation.
The objective of JIT activation is to minimize the amount of time for which an object lives and consumes resources on the server. With JIT activation, the client can hold a reference to an object on the server for a long time, but the server creates the object only when the client calls a method on the object. After the method call is completed, the object is freed and its memory is reclaimed. JIT activation enables applications to scale up as the number of users increases

Define Constructors and destructors
The create and destroy methods - often called constructors and destructors - are usually implemented for any abstract data type. Occasionally, the data type's use or semantics are such that there is only ever one object of that type in a program. In that case, it is possible to hide even the object's `handle' from the user. However, even in these cases, constructor and destructor methods are often provided.
Of course, specific applications may call for additional methods, e.g. we may need to join two collections (form a union in set terminology) - or may not need all of these.

What is datagrid?

The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data.

What’s the difference between code-based security and role-based security? Which one is better? Code security is the approach of using permissions and permission sets for a given code to run. The admin, for example, can disable running executables off the Internet or restrict access to corporate database to only few applications. Role-based security most of the time involves the code running with the privileges of the current user. This way the code cannot supposedly do more harm than mess up a single user account. There’s no better, or 100% thumbs-up approach, depending on the nature of deployment, both code-based and role-based security could be implemented to an extent.

How can you work with permissions from your .NET application? You can request permission to do something and you can demand certain permissions from other apps. You can also refuse permissions so that your app is not inadvertently used to destroy some data.

How can C# app request minimum permissions?

using System.Security.Permissions;
[assembly:FileDialogPermissionAttribute(SecurityAction.RequestMinimum, Unrestricted=true)]

What’s a code group?

A code group is a set of assemblies that share a security context.

What’s the difference between authentication and authorization? Authentication happens first. You verify user’s identity based on credentials. Authorization is making sure the user only gets access to the resources he has credentials for.

What are the authentication modes in ASP.NET? None, Windows, Forms and Passport.

Are the actual permissions for the application defined at run-time or compile-time? The CLR computes actual permissions at runtime based on code group membership and the calling chain of the code

What’s the difference between private and shared assembly? Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.

What’s a strong name? A strong name includes the name of the assembly, version number, culture identity, and a public key token.

How can you tell the application to look for assemblies at the locations other than its own install? Use the
directive in the XML .config file for a given application.

should do the trick. Or you can add additional search paths in the Properties box of the deployed application.

How can you debug failed assembly binds? Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched.

Where are shared assemblies stored? Global assembly cache.

How can you create a strong name for a .NET assembly? With the help of Strong Name tool (sn.exe).

Where’s global assembly cache located on the system? Usually C:\winnt\assembly or C:\windows\assembly.

Can you have two files with the same file name in GAC? Yes, remember that GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so it’s possible for MyApp.dll and MyApp.dll to co-exist in GAC if the first one is version 1.0.0.0 and the second one is 1.1.0.0.

So let’s say I have an application that uses MyApp.dll assembly, version 1.0.0.0. There is a security bug in that assembly, and I publish the patch, issuing it under name MyApp.dll 1.1.0.0. How do I tell the client applications that are already installed to start using this new MyApp.dll? Use publisher policy. To configure a publisher policy, use the publisher policy configuration file, which uses a format similar app .config file. But unlike the app .config file, a publisher policy file needs to be compiled into an assembly and placed in the GAC.

What is delay signing? Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development.

In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events? Every Page object (which your .aspx page is) has nine events, most of which you will not have to worry about in your day to day dealings with ASP.NET. The three that you will deal with the most are: Page_Init, Page_Load, Page_PreRender.

What base class do all Web Forms inherit from? System.Web.UI.Page

What method do you use to explicitly kill a user’s session?
The Abandon method destroys all the objects stored in a Session object and releases their resources.
If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.

Syntax: Session.Abandon

How do you turn off cookies for one page in your site?
Use the Cookie.Discard Property which 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 user’s hard disk when a session ends.

Which two properties are on every validation control? ControlToValidate & ErrorMessage properties

What tags do you need to add within the asp:datagrid tags to bind columns manually?

How do you create a permanent cookie? Setting the Expires property to MinValue means that the Cookie never expires.

Which method do you use to redirect the user to another page without performing a round trip to the client?

Server.transfer()

What is the transport protocol you use to call a Web service? SOAP. Transport Protocols: It is essential for the acceptance of Web Services that they are based on established Internet infrastructure. This in fact imposes the usage of of the HTTP, SMTP and FTP protocols based on the TCP/IP family of transports. Messaging Protocol: The format of messages exchanged between Web Services clients and Web Services should be vendor neutral and should not carry details about the technology used to implement the service. Also, the message format should allow for extensions and different bindings to specific transport protocols. SOAP and ebXML Transport are specifications which fulfill these requirements. We expect that the W3C XML Protocol Working Group defines a successor standard.

True or False: A Web service can only be written in .NET. False.

What does WSDL stand for? Web Services Description Language

Describe the advantages of writing a managed code application instead of unmanaged one. What’s involved in certain piece of code being managed? The advantages include automatic garbage collection, memory management, support for versioning and security. These advantages are provided through .NET FCL and CLR, while with the unmanaged code similar capabilities had to be implemented through third-party libraries or as a part of the application itself.

Are COM objects managed or unmanaged? Since COM objects were written before .NET, apparently they are unmanaged.

So can a COM object talk to a .NET object? Yes, through Runtime Callable Wrapper (RCW) or PInvoke.

How do you generate an RCW from a COM object? Use the Type Library Import utility shipped with SDK. tlbimp COMobject.dll /out:.NETobject.dll or reference the COM library from Visual Studio in your project.

I can’t import the COM object that I have on my machine. Did you write that object? You can only import your own objects. If you need to use a COM component from another developer, you should obtain a Primary Interop Assembly (PIA) from whoever authored the original object.

How do you call unmanaged methods from your .NET code through PInvoke? Supply a DllImport attribute. Declare the methods in your .NET code as static extern. Do not implement the methods as they are implemented in your unmanaged code, you’re just providing declarations for method signatures.

Can you retrieve complex data types like structs from the PInvoke calls? Yes, just make sure you re-declare that struct, so that managed code knows what to do with it.

I want to expose my .NET objects to COM objects. Is that possible? Yes, but few things should be considered first. Classes should implement interfaces explicitly. Managed types must be public. Methods, properties, fields, and events that are exposed to COM must be public. Types must have a public default constructor with no arguments to be activated from COM. Types cannot be abstract.

Can you inherit a COM class in a .NET application? The .NET Framework extends the COM model for reusability by adding implementation inheritance. Managed types can derive directly or indirectly from a COM coclass; more specifically, they can derive from the runtime callable wrapper generated by the runtime. The derived type can expose all the method and properties of the COM object as well as methods and properties implemented in managed code. The resulting object is partly implemented in managed code and partly implemented in unmanaged code.

Suppose I call a COM object from a .NET applicaiton, but COM object throws an error. What happens on the .NET end? COM methods report errors by returning HRESULTs; .NET methods report them by throwing exceptions. The runtime handles the transition between the two. Each exception class in the .NET Framework maps to an HRESULT.

Explain role-based security. In the role-based security model, access to parts of an application are granted or denied based on the role to which the callers belong. A role defines which members of a Windows domain are allowed to work with what components, methods, or interfaces

What is portable executable (PE) The file format defining the structure that all executable files (EXE) and Dynamic Link Libraries (DLL) must use to allow them to be loaded and executed by Windows. PE is derived from the Microsoft Common Object File Format (COFF). The EXE and DLL files created using the .NET Framework obey the PE/COFF formats and also add additional header and data sections to the files that are only used by the CLR. The specification for the PE/COFF file formats is available at http://www.microsoft.com/whdc/hwdev/hardware/pecoffdown.mspx

Which is the base class for .net Class library? Ans: system.object

What is Event? Delegate, clear syntax for writing a event delegate// keyword_delegate.cs // delegate declaration delegate void MyDelegate(int i);

class Program
{
public static void Main()
{
TakesADelegate(new MyDelegate(DelegateFunction));
}
public static void TakesADelegate(MyDelegate SomeFunction)
{
SomeFunction(21);
}
public static void DelegateFunction(int i)
{
System.Console.WriteLine("Called by delegate withnumber: {0}.", i);
}
}

What is Application Domain? Application domains provide a unit of isolation for the common language runtime. They are created and run inside a process. Application domains are usually created by a runtime host, which is an application responsible for loading the runtime into a process and executing user code within an application domain. The runtime host creates a process and a default application domain, and runs managed code inside it. Runtime hosts include ASP.NET, Microsoft Internet Explorer, and the Windows shell.

What is serialization in .NET? What are the ways to control 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.

What are Satellite Assemblies? How you will create this? How will you get the different language strings? Satellite assemblies are often used to deploy language-specific resources for an application. These language-specific assemblies work in side-by-side execution because the application has a separate product ID for each language and installs satellite assemblies in a language-specific subdirectory for each language. When uninstalling, the application removes only the satellite assemblies associated witha given language and .NET Framework version. No core .NET Framework files are removed unless the last language for that .NET Framework version is being removed. For example, English and Japanese editions of the .NET Framework version 1.1 share the same core files. The Japanese .NET Framework version 1.1 adds satellite assemblies withlocalized resources in a \ja subdirectory. An application that supports the .NET Framework version 1.1, regardless of its language, always uses the same core runtime files.

What is Global Assembly Cache (GAC) and what is the purpose of it? (How to make an assembly to public? Steps) 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. You should share assemblies by installing them into the global assembly cache only when you need to.

Readonly vs. const?

A constfield can only be initialized at the declaration of the field. Areadonlyfield can be initialized either at the declaration or in a constructor. Therefore,readonlyfields can have different values depending on the constructor used. Also, while aconstfield is a compile-time constant, thereadonlyfield can be used for runtime constants, as in the following example: public static readonly uint l1 = (uint) DateTime.Now.Ticks;

What is RCW (Run time Callable Wrappers)? The common language runtime exposes COM objects through a proxy called the runtime callable wrapper (RCW). Although the RCW appears to be an ordinary object to .NET clients, its primary function is to marshal calls between a .NET client and a COM object.

What is CCW (COM Callable Wrapper) A proxy object generated by the common language runtime so that existing COM applications can use managed classes, including .NET Framework classes, transparently.

How does you handle this COM components developed in other programming languages in .NET?

How will you register com+ services?

What is use of ContextUtil class? ContextUtil is the preferred class to use for obtaining COM+ context information.

What is the new three features of COM+ services, which are not there in COM (MTS)

Is the COM architecture same as .Net architecture? What is the difference between them (if at all there is)?

What’s a Windows process? It’s an application that’s running and had been allocated memory.

What’s typical about a Windows process in regards to memory allocation? Each process is allocated its own block of available RAM space, no process can access another process’ code or data. If the process crashes, it dies alone without taking the entire OS or a bunch of other applications down.

Why do you call it a process? What’s different between process and application in .NET, not common computer usage, terminology? A process is an instance of a running application. An application is an executable on the hard drive or network. There can be numerous processes launched of the same application (5 copies of Word running), but 1 process can run just 1 application.

What distributed process frameworks outside .NET do you know? Distributed Computing Environment/Remote Procedure Calls (DEC/RPC), Microsoft Distributed Component Object Model (DCOM), Common Object Request Broker Architecture (CORBA), and Java Remote Method Invocation (RMI).

What are possible implementations of distributed applications in .NET? .NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.

When would you use .NET Remoting and when Web services? Use remoting for more efficient exchange of information when you control both ends of the application. Use Web services for open-protocol-based information exchange when you are just a client or a server with the other end belonging to someone else.

What’s a proxy of the server object in .NET Remoting? It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.

What are remotable objects in .NET Remoting? Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.

What are channels in .NET Remoting? Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.

What security measures exist for .NET Remoting in System.Runtime.Remoting? None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.

What is a formatter? 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.

Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs? Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.

What’s SingleCall activation mode used for? If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.

What’s Singleton activation mode? A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease.

How do you define the lease of the object? By implementing ILease interface when writing the class code.

Can you configure a .NET Remoting object via XML file? Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.

How can you automatically generate interface for the remotable object in .NET with Microsoft tools? Use the Soapsuds tool.

Questions mainly relate to drawing and graphics programming in Windows Forms, when programming C# under .NET.

I am constantly writing the drawing procedures with System.Drawing.Graphics, but having to use the try and dispose blocks is too time-consuming with Graphics objects. Can I automate this? Yes, the code

System.Drawing.Graphics canvas = new System.Drawing.Graphics();
try
{
            //some code
}
finally
            canvas.Dispose();

is functionally equivalent to

using (System.Drawing.Graphics canvas = new System.Drawing.Graphics())
{
//some code
}          //canvas.Dispose() gets called automatically

How do you trigger the Paint event in System.Drawing?Invalidate the current form, the OS will take care of repainting. The Update method forces the repaint.

With these events, why wouldn’t Microsoft combine Invalidate and Paint, so that you wouldn’t have to tell it to repaint, and then to force it to repaint? Painting is the slowest thing the OS does, so usually telling it to repaint, but not forcing it allows for the process to take place in the background.

How can you assign an RGB color to a System.Drawing.Color object? Call the static method FromArgb of this class and pass it the RGB values.

What class does Icon derive from? Isn’t it just a Bitmap with a wrapper name around it? No, Icon lives in System.Drawing namespace. It’s not a Bitmap by default, and is treated separately by .NET. However, you can use ToBitmap method to get a valid Bitmap object from a valid Icon object.

Before in my VB app I would just load the icons from DLL. How can I load the icons provided by .NET dynamically? By using System.Drawing.SystemIcons class, for example System.Drawing.SystemIcons.Warning produces an Icon with a warning sign in it.

When displaying fonts, what’s the difference between pixels, points and ems? A pixel is the lowest-resolution dot the computer monitor supports. Its size depends on user’s settings and monitor size. A point is always 1/72 of an inch. An em is the number of pixels that it takes to display the letter M.