Wednesday, May 27, 2009

ASP.NET Questions

1. Response.Redirect sends a response back to the browser and tells it to open the URL you pass it. Server.Transfer actually transfers the request from one page to another, never leaving the server. That is why you can not server.transfer to another domain. Each have their place, Response.Redirect is used more often than server.transfer, but I think that is because so many learned to do that in the old ASP days. With transfer you actually retain access to the objects of the page that initiated the post-back, where with Response.Redirect you would have to pass a set of querystring parameters.

2. response.Write add text to the buffer being sent to the browser
3. Web applications. These provide content from a server to client machines over the Internet. Users view the Web application through a Web browser, such as Microsoft Internet Explorer or Netscape Navigator.(System.web.namespace)
4. Web services. These components provide processing services from a server to other applications over the Internet. .(SystemWeb.Services.namespace)
5. Internet-enabled applications. These are stand-alone applications that incorporate aspects of the Internet to provide online registration, Help, updates, or other services to the user over the Internet. .(System.Net.namespace)
6. Peer-to-peer applications. These are stand-alone applications that use the Internet to communicate with other users running their own instances of the application. .(System.Net.Socket.namespace)
7. Web applications use a client/server architecture. The Web application resides on a server and responds to requests from multiple clients over the Internet
· On the client side, the Web application is hosted by a browser, such as Internet Explorer or Netscape Navigator
· On the server side, the Web application runs under Microsoft Internet Information Services (IIS). IIS manages the application, passes requests from clients to the application, and returns the application' s responses to the client. These requests and responses are passed across the Internet using Hypertext Transport Protocol (HTTP).
· protocol is a set of rules that describe how two or more items communicate over a medium
8. ASP.NET is the platform that you use to create Web applications and Web services that run under IIS. ASP.NET is part of the .NET Framework and is made up of several different components.
· Visual Studio .NET Web development tools. These include visual tools for designing Web pages and application templates, project management, and deployment tools for Web applications.
· The System.Web namespaces. These are part of the .NET Framework, and include the programming classes that deal with Web-specific items such as HTTP requests and responses, browsers, and e-mail.
· Server and HTML controls. These are the user-interface components that you use to gather information from and provide responses to users.
These items aren' t part of ASP.NET. However, they are key to ASP.NET programming.
· Microsoft Internet Information Services (IIS). As mentioned in the previous section, IIS hosts Web applications on the Windows server.
· The Microsoft Visual Basic .NET, Microsoft Visual C#, and JScript programming languages. These three languages have integrated support in Visual Studio .NET for creating Web applications.
· The .NET Framework. This is the complete set of Windows programming classes; they include the ASP.NET classes as well as classes for other programming tasks such as file access, data type conversion, array and string manipulation, and so on.
· ADO.NET database classes and tools. These components provide access to Microsoft SQL Server and ODBC databases. Data access is often a key component of Web applications.
· Microsoft Application Center Test (ACT). This Visual Studio .NET component provides an automated way to stress-test Web applications.
9. The most significant advantage is its integration with the Windows server and programming tools. Web applications created with ASP.NET are easier to create, debug, and deploy because those tasks can all be performed within a single development environment—Visual Studio .NET.
10. A Web form is a cross between a regular HTML page and a Windows form: but it also has controls that respond to events and run code, like a Windows form.
11. Components on a Web Form
· Server controls
TextBox, Label, Button, ListBox, DropDownList, DataGrid
These controls respond to user events by running event procedures on the server. Server controls have built-in features for saving data that the user enters between page displays. You use server controls to define the user interface of a Web form.
· HTML controls
Text area, Table, Image, Submit Button, Reset Button
These represent the standard visual elements provided in HTML. HTML controls are useful when the more complete feature set provided by server controls is not needed.
· . Data controls
SqlConnection, SqlCommand, OleDbConnection, OleDbCommand, DataSet
Data controls provide a way to connect to, perform commands on, and retrieve data from SQL and OLE databases and XML data files.
· System components
FileSystemWatcher, EventLog, MessageQueue
These components provide access to various system-level events that occur on the server


it possible to inline assembly or IL in C# code? - No.
2. Is it possible to have different access modifiers on the get/set methods of a property? - No. The access modifier on a property applies to both its get and set accessors. What you need to do if you want them to be different is make the property read-only (by only providing a get accessor) and create a private/internal set method that is separate from the property.
3. Is it possible to have a static indexer in C#? - No. Static indexers are not allowed in C#.
4. If I return out of a try/finally in C#, does the code in the finally-clause run? - Yes. The code in the finally always runs. If you return out of the try block, or even if you do a “goto” out of the try, the finally block always runs:
using System;


class main
{
public static void Main()
{
try
{
Console.WriteLine("In Try block");
return;
}
finally
{
Console.WriteLine("In Finally block");
}
}
}
Both “In Try block” and “In Finally block” will be displayed. Whether the return is in the try block or after the try-finally block, performance is not affected either way. The compiler treats it as if the return were outside the try block anyway. If it’s a return without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has an expression, there’s an extra store/load of the value of the expression (since it has to be computed within the try block).
5. I was trying to use an “out int” parameter in one of my functions. How should I declare the variable that I am passing to it? - You should declare the variable as an int, but when you pass it in you must specify it as ‘out’, like the following: int i; foo(out i); where foo is declared as follows: [return-type] foo(out int o) { }
6. How does one compare strings in C#? - In the past, you had to call .ToString() on the strings when using the == or != operators to compare the strings’ values. That will still work, but the C# compiler now automatically compares the values instead of the references when the == or != operators are used on string types. If you actually do want to compare references, it can be done as follows: if ((object) str1 == (object) str2) { … } Here’s an example showing how string compares work:
7. using System;
8. public class StringTest
9. {
10. public static void Main(string[] args)
11. {
12. Object nullObj = null; Object realObj = new StringTest();
13. int i = 10;
14. Console.WriteLine("Null Object is [" + nullObj + "]n"
15. + "Real Object is [" + realObj + "]n"
16. + "i is [" + i + "]n");
17. // Show string equality operators
18. string str1 = "foo";
19. string str2 = "bar";
20. string str3 = "bar";
21. Console.WriteLine("{0} == {1} ? {2}", str1, str2, str1 == str2 );
22. Console.WriteLine("{0} == {1} ? {2}", str2, str3, str2 == str3 );
23. }
24. }
Output:
Null Object is []
Real Object is [StringTest]
i is [10]
foo == bar ? False
bar == bar ? True
25. How do you specify a custom attribute for the entire assembly (rather than for a class)? - Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows:
26. using System;
27. [assembly : MyAttributeClass] class X {}
Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.
28. How do you mark a method obsolete? -
[Obsolete] public int Foo() {...}
or
[Obsolete("This is a message describing why this method is obsolete")] public int Foo() {...}
Note: The O in Obsolete is always capitalized.
29. How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#? - You want the lock statement, which is the same as Monitor Enter/Exit:
30. lock(obj) { // code }
translates to
try {
CriticalSection.Enter(obj);
// code
}
finally
{
CriticalSection.Exit(obj);
}
31. How do you directly call a native function exported from a DLL? - Here’s a quick example of the DllImport attribute in action:
32. using System.Runtime.InteropServices;
33. class C
34. {
35. [DllImport("user32.dll")]
36. public static extern int MessageBoxA(int h, string m, string c, int type);
37. public static int Main()
38. {
39. return MessageBoxA(0, "Hello World!", "Caption", 0);
40. }
41. }
This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA. For more information, look at the Platform Invoke tutorial in the documentation.
42. How do I simulate optional parameters to COM calls? - You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.


1. Why are Server control tags shown in the browser instead of the controls it represents?
This is because the server control tags were not converted into their respecting HTML element tags by ASP.Net. This happens when ASP.Net is not properly registered with IIS. .Net framework provides an Administration utility that manages the installation and uninstallation of multiple versions of ASP.NET on a single machine. You can find the file in C:\WINNT\Microsoft.NET\Framework\v**\aspnet_regiis.exe use the command: aspnet_regiis.exe -u ---> to uninstall current asp.net version. use the command: aspnet_regiis.exe -i ---> to install current asp.net version
2. What are the Best practices for side-by-side execution of Framework 1.1 and 2.0?
In ASP.NET, applications are said to be running side by side when they are installed on the same computer, but use different versions of the .NET Framework.
3. Can I have VS.NET and the Visual Studio 6.0 installed on the same machine?
Yes! VS.Net works with the .Net framework, while VS6.0 works with MFC or the Windows API directly, for the most part. They can be installed and run on the same machine without any considerations.
4. What is Assembly name and name space?
An assembly is a logical unit of code. Physically it may exist as dll or an exe. which can contain one or more files and they can be any file types like image files, text files etc. along with DLLs or EXEs.When you compile your source code by default the exe/dll which is generated is actually an assemblyand every assembly file contains information about itself which is called as Assembly Manifest.Namespace is an abstract container providing context for the items it holds and allows disambiguation of items having the same name (residing in different namespaces. It can also be said as a context for identifiers. So under a namespace you can have multiple assemblies.
5. what is capacity of dataset?
DataSet is logical represantation of database so it can store as much as database.
6. What is deployment? How do you deploy .Net and Java applications
Deployment - It is the procedure to deploy Web Application on the Server. You can deploy .Net application by simply Xcopy and create virtual directory for the application on server.
7. Where this DataSet is Stored?
Dataset is an in-memory representation of a database. Its stored no where but in memory. Goes off when GC stats after a littl sleep.
8. How different are interface and abstract class in .Net?
When a class is not provided with full functionalitythen it is declared as abstract.it doesn't support instance creation as well as it cannot be overridable to child class.interface is a colection of methods only without functionality.interface is 90% same as abstract class.
9. How does vs.net 2005 support biztalkserver?
if you install biztalk server it provides Biztalk Project in the project types like webproject, windows project, console project. We use rest of the products of the Biztalk like adapters and all those thing and use them in .net.
10. what is marshling?
Marshaling performs the necessary conversions in data formats between managed and unmanaged code.CLR allows managed code to interoperate with unmanaged code usining COM Marshaler(Component of CLR).
11. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
o A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
o A DataSet is designed to work without any continuing connection to the original data source.
o Data in a DataSet is bulk-loaded, rather than being loaded on demand.
o There's no concept of cursor types in a DataSet.
o DataSets have no current record pointer You can use For Each loops to move through the data.
o You can store many edits in a DataSet, and write them to the original data source in a single operation.
o Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.
12. In .NET Compact Framework, can I free memory explicitly without waiting for garbage collector to free the memory?
.NET Compact Framework come with CLR which perform automatic garbage collector to free the memory without using destector(perform garbage collector when is declear)
1. What is ASP.NET?
ASP.NET is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications
2. Why does my ASP.NET file have multiple form tag with runat=server?
This means that ASP.Net is not properly registered with IIS.
.Net framework provides an Administration utility that manages the installation and uninstallation of multiple versions of ASP.NET on a single machine. You can find the file in C:\WINNT\Microsoft.NET\Framework\v**\aspnet_regiis.exe
3. How to find out what version of ASP.NET I am using on my machine?
Response.Write(System.Environment.Version.ToString() )
4. Is it possible to pass a querystring from an .asp page to aspx page?
Yes you can pass querystring from .asp to ASP.NET page .asp
response.redirect "webform1.aspx?id=11
5. What is a ViewState?
View State Allows the state of objects to be Stored in Hidden Fields.In ASP .NET, when the form is submitted the form reappears in the browser with all form values.
6. Where can I get the details on Migration of existing projects using various technologies to ASP.NET?
Microsoft has designed Migration Assistants to help us convert existing pages and applications to ASP.NET. It does not make the conversion process completely automatic, but it will speed up project by automating some of the steps required for migration. Below are the Code Migration Assistants
ASP to ASP.NET Migration Assistant
PHP to ASP.NET Migration Assistant
JSP to ASP.NET Migration Assistant
7. What is the equivalent of date() and time() in ASP.NET?
System.DateTime.Now.ToShortDateString()
System.DateTime.Now.ToShortTimeString()
8. How to prevent a button from validating it's form?
Set the CauseValidation property of the button control to False
9. How to catch the 404 error in my web application and provide more useful information?
In the global.asax Application_error Event write the following code.
10. How can I change the action of a form through code?
You can't change it. The action attribute is owned by ASP.NET. Handle Events and Transfer.
11. 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.
12. What is the transport protocol you use to call a Web service?
SOAP (Simple Object Access Protocol) is the preferred protocol.
13. What does WSDL stand for?
Web Services Description Language
14. 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.
1. When was ASP.NET released?
ASP.NET is a part of the .NET framework which was released as a software platform in 2002.
2. What is CLR?
Common Language Runtime (CLR) is a run-time environment that manages the execution of .NET code and provides services like memory management, debugging, security, etc.
3. In Visual Studio .NET, how do I create a new ASP.NET application for an existing ASP.NET project?
First create an IIS application using the IIS MMC. Then in Visual Studio .NET, use the "New Project In Existing Folder" project template (at the end of the template list). It will first ask you for the project name (use the same one you created for the IIS application). Click OK button. Then enter in physical folder location.
4. What is the Difference between HTML controls and ASP.net Controls?
HTML controls are run on client side, where as ASP.net controls runs on server side and for execute on client side, they generate HTML controls.
5. Can a .NET web application consume Java web service ?
Yes.Actually Webservices are independent to language. it depends on WSDL and SOAP. so any one can develope the Webservices anddisclose the wsdl and users can cosume the webservices.wsdl and soap both are xml based.. and all languages having xml parsing capability and access to http protocol will be able to work with Webservices
6. how to click or select a row in gridview using c# code?
We should use the Currency CurrencyManager cmGrid = (CurrencyManager)this.BindingContext[gridview.DataSource, gridview.DataMember]; cmGrid.Position = iIndex;
7. What is IPostBack? How to use it?
Ispostback event is generated by the web controls to alert the server to take respected action of the event generated. When the button is clicked then click event is generated which further cause ispostback event & it alerts the server to take respected action during postback event.
8. ColumnMapping belongs to which namespaces?
ColumnMapping belongs to System.Data
9. Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component
when there is no .Net framework installed in one of the communicating applications
10. In order to get assembly info whcih namespace we should import?
system.reflection
11. Which method do you invoke on the DataAdapter control to load your generated dataset with data?
dataadapter.fill(dataset object)
12. Enumerate the types of Directives?
o @ Page directive
o @ Assembly directive
o @ Import directive
o @ Reference directive
o @ Implements directive
o @ OutputCache directive
o @ Register directive
13. What is a DataReader?
A DataReader is a read-only stream of data returned from the database as the query executes. It only 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. The DataReader does support access to multiple result sets, but only one at a time and in the order retrieved. Just as in the original version of ADO, the data is no longer available through the DataReader once the connection to the data source is closed, which means a DataReader requires a connection to the database throughout its usage. Output parameters or return values are only available through the DataReader once the connection is closed.
14. Why DataReader Useful?
Data Reader is Read only version Data Set,Each record is returned as a Data Reader Object,ExecuteReader method acts directly on the database connection. There are two versions of the data reader object: OleDbDataReader and SqlDataReader
15. Differnce B/w DataReader and DataSet
The Dataset is an core of disconnected architecture.Disconnected architecture means once you have retriveed the data from the database the connect of the datasource is dropped.The disconnected data become very commonlyThe dataset for the disconnected data from the Dataset object.The DataReader is an readonly ,forward only stream from the database.While using the datareader can improve the application performance reduce the system overhead because only one buffer row at a time in memory.
1. What is the smallest unit of execution in .NET?
An Assembly.
2. 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.
3. What’s 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.
4. What’s the difference between the Debug class and Trace class?
Use Debug class for debug builds, use Trace class for both debug and release builds.
5. 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.
6. What are the ways to deploy an assembly?
An MSI installer, a CAB archive, and XCOPY command.
7. 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.
8. How do you convert a value-type to a reference-type?
Use Boxing.
9. Whats an assembly?
Assemblies are the building blocks of the .NET framework;
10. 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.
11. Is .NET capable of supporting multi-thread?
yes, .net supports multithreading which is one of the feature supported by .net
12. What does assert() 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.
13. Can you store multiple data types in System.Array?
No
14. Where does the Web page belong in the .NET Framework class hierarchy?
System.Web.UI.Page
15. Where do you store the information about the user’s locale?
System.Web.UI.Page.Culture.
16. 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.
17. How many classes can a single .NET DLL contain?
It can contain many classes.
18. 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.
19. 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.
20. 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.
21. What is Serializatoin?
Serialization is the process of converting an object or a con-nected graph of objects into a contiguous stream of bytes. Deserialization is the process of converting a contiguous stream of bytes back into its graph of connected objects. The ability to convert objects to and from a byte stream is an incredibly useful mechanism. Here are some examples:
o An application's state (object graph) can easily be saved in a disk file or database and then restored the next time the application is run. ASP.NET saves and restores session state by way of serialization and deserialization.
o A set of objects can easily be copied to the system's clipboard and then pasted into the same or another application. In fact, Windows® Forms uses this procedure.
o A set of objects can be cloned and set aside as a backup while a user manipulates the main set of objects.
o A set of objects can easily be sent over the network to a process running on another machine. The Microsoft® .NET Framework remoting architecture serializes and deserializes objects that are marshaled by value.
1. What is ASP.NET?
ASP.NET is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications.
2. How To Repair ASP.Net IIS Mapping After You Remove and Reinstall IIS?
To reassociate aspx file extensions with ASP.Net runtime, you'll have to run the utlity aspnet_regiis.exe -i
3. What are the Best practices for side-by-side execution of Framework 1.0 and 1.1?
In ASP.NET, applications are said to be running side by side when they are installed on the same computer, but use different versions of the .NET Framework.
4. How should I check whether IIS is installed or not?
To verify if IIS is installed, go to your 'Add or Remove Programs' utility in the Control panel and click on the 'Add/Remove Windows Components' in the side menu. On XP Pro and below, you should see an item called "Internet Information Services (IIS)". If this is checked, IIS should be installed. On Win2K3, you'll see "Application Server". If this is checked, select it and then click 'Details'. Another form should open which will contain "Internet Information Services (IIS)". If it is checked, IIS should be installed.
5. In Visual Studio .NET, how do I create a new ASP.NET application for an existing ASP.NET project?
First create an IIS application using the IIS MMC. Then in Visual Studio .NET, use the "New Project In Existing Folder" project template (at the end of the template list). It will first ask you for the project name (use the same one you created for the IIS application). Click OK button. Then enter in physical folder location.
6. In Visual Studio .NET, how do I create a new ASP.NET application which does not have a physical path under wwwroot?
You must first create an IIS application using the IIS MMC. Then in Visual Studio .NET, create a new ASP.NET application and give it the same name you used for the IIS application
7. How to Configure the ASP.NET Version to use for Each Application(developed using 1.1)?
To configure WebApp2 to use ASP.NET 1.1, follow these steps:
1. Click Start, and then click Run.
2. In the Open text box, type cmd, and then click OK.
3. At the command prompt, locate the following directory: WindowsDirectory\Microsoft.NET\Framework\v1.1.4322\
4. At the command prompt, type one of the following commands:
§ To Install ASP.NET 1.1 recursively
aspnet_regiis -s W3SVC/1/ROOT/WebApp2
§ To Install ASP.NET 1.1 non-recursively
aspnet_regiis -sn W3SVC/1/ROOT/WebApp2
8. Can I have VS.NET and the Visual Studio 6.0 installed on the same machine?
Yes! VS.Net works with the .Net framework, while VS6.0 works with MFC or the Windows API directly, for the most part. They can be installed and run on the same machine without any considerations.
9. In Visual Studio .NET, how do I create a new ASP.NET application for an existing ASP.NET project?
First create an IIS application using the IIS MMC. Then in Visual Studio .NET, use the "New Project In Existing Folder" project template (at the end of the template list). It will first ask you for the project name (use the same one you created for the IIS application). Click OK button. Then enter in physical folder location.


1. What is .NET / .NET Framework?
It is a Framework in which Windows applications may be developed and run.
The Microsoft .NET Framework is a platform for building, deploying, and running Web Services and applications. It provides a highly productive, standards-based, multi-language environment for integrating existing investments with next-generation applications and services as well as the agility to solve the challenges of deployment and operation of Internet-scale applications. The .NET Framework consists of three main parts: the common language runtime, a hierarchical set of unified class libraries, and a componentized version of Active Server Pages called ASP.NET.
The .NET Framework provides a new programming model and rich set of classes designed to simplify application development for Windows, the Web, and mobile devices. It provides full support for XML Web services, contains robust security features, and delivers new levels of programming power. The .NET Framework is used by all Microsoft languages including Visual C#, Visual J#, and Visual C++

2. What is "Microsoft Intermediate Language
A .NET programming language (C#, VB.NET, J# etc.) does not compile into executable code; instead it compiles into an intermediate code called Microsoft Intermediate Language (MSIL). As a programmer one need not worry about the syntax of MSIL - since our source code in automatically converted to MSIL. The MSIL code is then send to the CLR (Common Language Runtime) that converts the code to machine language, which is, then run on the host machine. MSIL is similar to Java Byte code.
MSIL is the CPU-independent instruction set into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects.
Combined with metadata and the common type system, MSIL allows for true cross- language integration Prior to execution, MSIL is converted to machine code. It is not interpreted



What is "Common Language Runtime
CLR is .NET equivalent of Java Virtual Machine (JVM). It is the runtime that converts a MSIL code into the host machine language code, which is then executed appropriately.
The CLR is the execution engine for .NET Framework applications. It provides a number of services, including:
• Code management (loading and execution)
• Application memory isolation
• Verification of type safety
• Conversion of IL to native code.
• Access to metadata (enhanced type information)
• Managing memory for managed objects
• Enforcement of code access security
• Exception handling, including cross-language exceptions
• Interoperation between managed code, COM objects, and pre-existing DLL's (unmanaged code and data)
• Automation of object layout
• Support for developer services (profiling, debugging, and so on).

it is resource of .net work it functionality is 1.jit(msil to native code)2.garbage collector3.type safety4.multi thread management 5.croossslan exception

What is "Common Language Specification" ...
CLS is the collection of the rules and constraints that every language (that seeks to achieve .NET compatibility) must follow. It is a subsection of CTS and it specifies how it shares and extends one another libraries.


.NET FAQS
1. What is .NET Framework?
2. Is .NET a runtime service or a development platform? Answer It’s bothand actually a lot more. Microsoft .NET is a company-wide initiative. It includes a new way of delivering software and services to businesses and consumers. A part of Microsoft.NET is the .NET Frameworks. The frameworks is the first part of the MS.NET initiate to ship and it was given out to attendees at the PDC in July. The .NET frameworks consists of two parts: the .NET common language runtime and the .NET class library. These two components are packaged together into the .NET Frameworks SDK which will be available for free download from Microsoft’s MSDN web site later this month. In addition, the SDK also includes command-line compilers for C#, C++, JScript, and VB. You use these compilers to build applications and components. These components require the runtime to execute so this is a development platform. When Visual Studio.NET ships, it will include the .NET SDK and a GUI editor, wizards, tools, and a slew of other things. However, Visual Studio.NET is NOT required to build .NET applications.
3. New features of Framework 1.1 ?
4. What is CLR? How it will work?
5. What is MSIL, IL, CTS?
6. What is JIT and how is works
7. What is strong name? A name that consists of an assembly’s identity—its simple text name, version number, and culture information (if provided)—strengthened by a public key and a digital signature generated over the assembly.
8. 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
9. Which is the base class for .net Class library? Ans: system.object
10. What is Event? Delegate, clear syntax for writing a event delegate// keyword_delegate.cs // delegate declaration delegate void MyDelegate(int i);
11. class Program
12. {
13. public static void Main()
14. {
15. TakesADelegate(new MyDelegate(DelegateFunction));
16. }
17. public static void TakesADelegate(MyDelegate SomeFunction)
18. {
19. SomeFunction(21);
20. }
21. public static void DelegateFunction(int i)
22. {
23. System.Console.WriteLine("Called by delegate withnumber: {0}.", i);
24. }
}
25. ment DataGrid in .NET? How would you make a combo-box appear in one column of a DataGrid? What are the ways to show data grid inside a data grid for a master details type of tables?
26. If we write any code for DataGrid methods, what is the access specifier used for that methods in the code behind file and why?
27. 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.
28. 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. When the object is subsequently deserialized, an exact clone of the original object is created.
o Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application. For example, you can share an object between different applications by serializing it to the clipboard. You can serialize an object to a stream, disk, memory, over the network, and so forth. Remoting uses serialization to pass objects “by value” from one computer or application domain to another.
o XML serialization serializes only public properties and fields and does not preserve type fidelity. This is useful when you want to provide or consume data without restricting the application that uses the data. Because XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is an open standard, which makes it an attractive choice.

39. What is the use of trace utility
40. What is different between User Control and Web Control and Custom Control?
41. What is exception handling? When an exception occurs, the system searches for the nearest catch clause that can handle the exception, as determined by the run-time type of the exception. First, the current method is searched for a lexically enclosing try statement, and the associated catch clauses of the try statement are considered in order. If that fails, the method that called the current method is searched for a lexically enclosing try statement that encloses the point of the call to the current method. This search continues until a catch clause is found that can handle the current exception, by naming an exception class that is of the same class, or a base class, of the run-time type of the exception being thrown. A catch clause that doesn’t name an exception class can handle any exception. Once a matching catch clause is found, the system prepares to transfer control to the first statement of the catch clause. Before execution of the catch clause begins, the system first executes, in order, any finally clauses that were associated withtry statements more nested that than the one that caught the exception. Exceptions that occur during destructor execution are worthspecial mention. If an exception occurs during destructor execution, and that exception is not caught, then the execution of that destructor is terminated and the destructor of the base class (if any) is called. If there is no base class (as in the case of the object type) or if there is no base class destructor, then the exception is discarded.
42. What is Assembly? Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime withthe information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly. Assemblies are a fundamental part of programming withthe .NET Framework. An assembly performs the following functions:
o It contains code that the common language runtime executes. Microsoft intermediate language (MSIL) code in a portable executable (PE) file will not be executed if it does not have an associated assembly manifest. Note that each assembly can have only one entry point (that is,DllMain,WinMain, orMain).
o It forms asecurity boundary. An assembly is the unit at which permissions are requested and granted.
o It forms atype boundary. Every type’s identity includes the name of the assembly in which it resides. A type called MyType loaded in the scope of one assembly is not the same as a type called MyType loaded in the scope of another assembly.
o It forms areference scope boundary. The assembly’s manifest contains assembly metadata that is used for resolving types and satisfying resource requests. It specifies the types and resources that are exposed outside the assembly. The manifest also enumerates other assemblies on which it depends.
o It forms aversion boundary. The assembly is the smallest versionable unit in the common language runtime; all types and resources in the same assembly are versioned as a unit. The assembly’s manifest describes the version dependencies you specify for any dependent assemblies.
o It forms a deployment unit. When an application starts, only the assemblies that the application initially calls must be present. Other assemblies, such as localization resources or assemblies containing utility classes, can be retrieved on demand. This allows applications to be kept simple and thin when first downloaded.
o It is the unit at which side-by-side execution is supported. Assemblies can be static or dynamic. Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in PE files. You can also use the .NET Framework to create dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.
There are several ways to create assemblies. You can use development tools, such as Visual Studio .NET, that you have used in the past to create .dll or .exe files. You can use tools provided in the .NET Framework SDK to create assemblies withmodules created in other development environments. You can also use common language runtime APIs, such as Reflection.Emit, to create dynamic assemblies.
43. s of assemblies? Private, Public/Shared, Satellite
44. 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.
45. How will you load dynamic assembly? How will create assemblies at run time?
46. What is Assembly manifest? what all details the assembly manifest will contain. Every assembly, whether static or dynamic, contains a collection of data that describes how the elements in the assembly relate to each other. The assembly manifest contains this assembly metadata. 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 file (an .exe or .dll) withMicrosoft intermediate language (MSIL) code or in a standalone PE file that contains only assembly manifest information. It contains Assembly name, Version number, Culture, Strong name information, List of all files in the assembly, Type reference information, Information on referenced assemblies.
47. What are the contents of assembly? In general, a static assembly can consist of four elements:
o The assembly manifest, which contains assembly metadata.
o Type metadata.
o Microsoft intermediate language (MSIL) code that implements the types.
o A set of resources.
48. Difference between assembly manifest & metadata assembly manifest -An integral part of every assembly that renders the assembly self-describing. The assembly manifest contains the assembly’s metadata. The manifest establishes the assembly identity, specifies the files that make up the assembly implementation, specifies the types and resources that make up the assembly, itemizes the compile-time dependencies on other assemblies, and specifies the set of permissions required for the assembly to run properly. This information is used at run time to resolve references, enforce version binding policy, and validate the integrity of loaded assemblies. The self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment feasible. metadata -Information that describes every element managed by the common language runtime: an assembly, loadable file, type, method, and so on. This can include information required for debugging and garbage collection, as well as security attributes, marshaling data, extended class and member definitions, version binding, and other information required by the runtime.
49. 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.
50. If I have more than one version of one assemblies, then how’ll I use old version (how/where to specify version number?)in my application?
51. How to find methods of a assembly file (not using ILDASM) Reflection
52. Value type & data types difference. Example from .NET.
53. Integer & struct are value types or reference types in .NET?
54. What is Garbage Collection in .Net? Garbage collection process? The process of transitively tracing through all pointers to actively used objects in order to locate all objects that can be referenced, and then arranging to reuse any heap memory that was not found during this trace. The common language runtime garbage collector also compacts the memory that is in use to reduce the working space needed for the heap.
55. Readonly vs. const? Aconstfield 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;
56.
1.
2. < . { System.Attribute : MyAttribute public attribute.(>
3. < { public this.myvalue="myvalue;" myvalue) MyAttribute(bool constructors(>
4. //Declaring properties
5. public bool MyProperty
6. {
7. get {return this.myvalue;}
8. set {this.myvalue = value;}
9. }
10.
ion to get access to custom attributes.
class MainClass
{
public static void Main()
{
System.Reflection.MemberInfo info = typeof(MyClass);
object[] attributes = info.GetCustomAttributes();
for (int i = 0; i < attributes.Length; i ++)
{
System.Console.WriteLine(attributes[i]);
}
}
}
57. C++ & C# differences
58. What is the managed and unmanaged code in .net? The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime’s functionality and enable you to write code that benefits from this managed execution environment. Code that you develop witha language compiler that targets the runtime is calledmanaged code; itbenefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.
59. How do you create threading in .NET? What is the namespace for that?
60. using directive vs using statement You create an instance in ausingstatement to ensure thatDispose is called on the object when theusingstatement is exited. Ausing statement can be exited either when the end of theusingstatement is reached or if, for example, an exception is thrown and control leaves the statement block before the end of the statement. The using directive has two uses.
o Create an alias for a namespace (a using alias).
o Permit the use of types in a namespace, such that, you do not have to qualify the use of a type in that namespace (ausingdirective).
61. Describe the Managed Execution Process
62. What is Active Directory? What is the namespace used to access the Microsoft Active Directories?
63. Interop Services?
64. 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.
65. 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.
66. How does you handle this COM components developed in other programming languages in .NET?
67. How will you register com+ services?
68. What is use of ContextUtil class? ContextUtil is the preferred class to use for obtaining COM+ context information.
69. What is the new three features of COM+ services, which are not there in COM (MTS)
70. Is the COM architecture same as .Net architecture? What is the difference between them (if at all there is)?
For more questions and answers, visit Santhosh Thomas’ site, as he constantly updates these questions with answers.

No comments: