Interview Questions ASP
Interview Questions ASP
NET
ASP.NET Interview Questions This is a list of questions I have gathered and created over a period of time from my experience, many of which I felt where incomplete or simply wrong. I have finally taken the time to go through each question and correct them to the best of my ability. However, please feel free to post feedback to challenge, improve, or suggest new questions. I want to thank those of you that have contributed quality questions and corrections thus far. There are some questions in this list that I do not consider to be good questions for an interview. However, they do exist on other lists available on the Internet so I felt compelled to keep them here for easy access.
1.
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. Whats 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 users locale? System.Web.UI.Page.Culture Whats the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"? CodeBehind is relevant to Visual Studio.NET only. Whats 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();");
2.
3.
4. 5.
6. 7.
8.
9.
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. 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. 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.
15. 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.
17. 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.
18. 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.
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.
21. 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.
23. Which method do you invoke on the DataAdapter control to load your
generated dataset with data? The Fill() method.
25. Which template must you provide, in order to display data in a Repeater
control? ItemTemplate.
26. How can you provide an alternating color scheme in a Repeater control?
Use the AlternatingItemTemplate.
27. 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.
30. 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.
31. Which control would you use if you needed to make sure the values in two
different controls matched? CompareValidator control.
2.
3.
4.
Feedback
# re: Interview Questions: ASP.NET 6/1/2004 5:00 AM pinak
hey can anyone gimme some common basic questions on .net which can b expected in interview. Plz consider that i'm just beginer in .net. You can mail me at [email protected]. I'll b really thankfull to u ... bye
11. What type of code (server or client) is found in a Code-Behind class? Server-side code. we can write client side code in code-behind calss like button1.Attributes.Add("onMouseOver", "window.open('webform1.aspx')") pls help me
You are correct. You can write dynamically created client-side code in the code-behind class just as you have shown in your example. I understand your question and believe you have a good point. However, I would argue the code-behind class should still be considered "serverside" code since that is where it is executing. Client-side code does not execute in the codebehind, it is simply text or data, not really code and is treated as such in the code-behind. Your (excellent) example demonstrates the power of ASP in that a developer can dynamically create HTML, XML, or even Javascript in the code-behind. As you have pointed out, this dynamically generated code would execute on the client-side. In short, you are correct in your assessment and appear to be able to intelligently answer this question should you encounter it in an interview. Great question!
This is in response to Question 14 : What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? server.transfer simply transfer execution to another page. this doesn't require any information to be sent to the browser== it all occurs on the server without the user's knowledge. The response.redirect method sends http information to the browser instructing it to go to another page. [email protected]
hi all I,m working in NIC .it's a very good question for all freshers who really want about the .net
with the HTML, then he is doing a favor on himself. If he is messing, let him waste his own band width. To check whether all the validors on a page validate into *true*, before performing business, you better should do... Page.IsValid or if you want to perform validation for a particular validator, just do... FieldValidator.IsValid. Hope this helps :) mEEEEEEEEEEEEEEE!!!!!!!
Good for Interview point of view, but require more additional question in practicle.
Yeah nice questions u have it here. But still towards OOPS concept and their implementation will do better mail me @ [email protected] I do have some questions......... Ever Loving, R. Senthil Kumaran
Very useful article.Thanks for spending the time to come up with such an article.Would really appreciate more questions regding general asp.net & OOP concepts...
1. 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. 2. Whats the difference between Response.Write() andResponse.Output.Write()? The later one allows you to write formattedoutput. 3. What methods are fired during the page load? Init() - when the pageis instantiated Load() - when the page is loaded into server memory PreRender() - the brief moment before the page is displayed to the user asHTML, Unload() - when page finishes loading. 4. Where does the Web page belong in the .NET Framework class hierarchy? System.Web.UI.Page 5. Where do you store the information about the users locale? System.Web.UI.Page.Culture 6. Whats the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"? CodeBehind is relevant to Visual Studio.NET only. 7. Whats a bubbled event? When you have a complex control, like DataGrid, writing an event processing
hi iam fresher, addemding interviews.any one can send me faqs,maninly on oops concept,web services/remoting,security and windows services
11. What type of code (server or client) is found in a Code-Behind class? Server-side code. 12. Should validation (did the user enter a real date) occur server-side or client-side? Why? Client-side. This reduces an additional request to the server to validate the users input.
13. What does the "EnableViewState" property do? Why would I want it on or off? It enables the viewstate on the page. It allows the page to save the users input on a form.
14. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? Server.Transfer is used to post a form to another page. Response.Redirect is used to redirect the user to another page or site.
15. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset? 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. 16. Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines? This is where you can set the specific variables for the Application and Session objects. 17. If Im developing an application that must accommodate multiple security levels though secure login and my ASP.NET web application is spanned across three web-servers (using round-robin load balancing) what would be the best approach to maintain login-in state for the users? Maintain the login state security through a database. 18. 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. Base Class Employee. A Manager class could be derived from the Employee base class.
19. Whats an assembly? Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN
20. 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.
21. 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. For reading database data
22. 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.
23. Which method do you invoke on the DataAdapter control to load your generated dataset with data? The .Fill() method 24. Can you edit data in the Repeater control? No, it just reads the information from its data source 25. Which template must you provide, in order to display data in a Repeater control? ItemTemplate 26. How can you provide an alternating color scheme in a Repeater control? Use the AlternatingItemTemplate 27. What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control? You must set the DataSource property and call the DataBind method. 28. What base class do all Web Forms inherit from? The Page class. 29. Name two properties common in every validation control? ControlToValidate property and Text property. 30. What tags do you need to add within the asp:datagrid tags to bind columns manually? Set AutoGenerateColumns Property to false on the datagrid tag 31. What tag do you use to add a hyperlink column to the DataGrid? 32. What is the transport protocol you use to call a Web service? SOAP is the preferred protocol. 33. True or False: A Web service can only be written in .NET? False 34. What does WSDL stand for? (Web Services Description Language) 35. Where on the Internet would you look for Web services? (http://www.uddi.org) 36. 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 37. Which control would you use if you needed to make sure the values in two different controls matched? CompareValidator Control 38. True or False: To test a Web service you must create a windows application or Web application to consume this service? False, the webservice comes with a test page and it provides HTTP-GET method to test. 39. How many classes can a single .NET DLL contain? It can contain many classes.
6) Is String is Value Type or Reference Type in C#? String is an object (Reference Type). More to come.... Thanks & Regards, Senthilkumar.Thirukkami [email protected]
Someone posts a great article, and the feedback thread is littered with requests for more help. Are you guys idiots? Why should anyone take time out of their day to send you anything?
these question r not enough for interview plz add more question and mail me [email protected]
Dear friends, U can send Interview model papers on this, If u have any. If u do so, i am very thankfull to u. If it is possible to u u can mail me: [email protected]
Hello sir, Can u send me some more asp.net and vb.net interview questions with answers my emailid is [email protected] Thank you, B.sharu
Please give sites or links containing MCAD questions and answers.Please mail it to [email protected] or [email protected]
Excellent ! Really these questions will be very HELPFUL for freshers. pl.send these type important question on my E-mail. E-mail :- [email protected]
these questions are extremely fantastic.as a fresher like me, these are very helpful.I like these very much and hope you will send these type important question on my E-mail.
I like these very much and hope you will send these type important question on my E-mail.
Excellent ! Really these questions will be very beneficial for freshers. I like these very much and hope you will send these type important question on my E-mail. E-mail :- [email protected]
Hi all, Can anyone provide me some common questions on ASp.net which can be expected in interview. consider me as a beginner. pls do mail me with Ans. It will be very helpfull for my preparations My email id is [email protected]
Excellent ! Really these questions will be very beneficial for all. I like these very much and hope you will send these type important question on my E-mail. E-mail :- [email protected]
I really appreciate this piece of work. At the same time i support comments from "Developer in Seattle". Instead of asking your personal copies of the documents why dont you come and
visit this link again and copy the entire contents into a document. I'm not able to understand why are they demanding for spoonfeeding?? btw i'd like to share some more links which might help people who are in search of .NET questions. http://www.hanselman.com/blog/PermaLink.aspx?guid=2d2fae59-a589-4c43-b6a5-b6 ebc1a9eafd http://www.techinterviews.com/?p=193
I really appreciate this answers. You are doing so great job here. Thank you so much.
i am new to ASP.NET please guide me how to approch to learn asp.net send me more questions also. i will be very thankful of you. Regards Ravi Goyal
Vivek Harne
Siva R
Hi, I am new at .net and planning to take some interview. The questions on the top help me alot. If you have some more interview questions and useful links, please send me at [email protected]. Thanks in advance. Sohel.
hello friends , I said thanks to every body in this group for their helping nature and spend their valuable time please send me the interview related material and URLs in .net @[email protected] thank you
I am fresher n these interview question with answers really helping me.Good Show.....keep it up!! Keep flooding with more :)
inteview
qustions r very good can u send me some more qustions to my mail [email protected]
1. What is the purpose of XSLT other than displaying XML contents in HTML?
6. How to initialize COM in ASP? 7. What are the deferences of DataSet and ??? 8. What are the cursers in ADO? 9. What are the in-build components in ASP? 10. What are the Objects in ASP? Can any body send more ASP.net questions to [email protected]
This is not at all impressive site, I mean, To become a good and usable site, please upload 10000 questions and answer ( That may be even hypothetical question) to this site. Happy programming....
the article is excellent.can u pls send me more questions in ASP.net to my mail id.
thanx.
Pls. any one have some collection of question in .Net and SQL Server please mail me at this ID [email protected]
and get a satisfactory answer in about 10 seconds. When I interview, I want to know that the candidate understands deeper concepts than what can be Googled in 30 seconds. Explain to me some particular OOP concepts. When would you use a Singleton? Why? Why use an Interface? How would you implement exception handling in this case? I want to know that they can THINK. Sure, I'll ask some basic questions that are trivial during a phone screening, but asking what namespace some class out of the BCL belongs to is just...well, stupid. It might make you feel superior if you know the answer, but it does nothing to help you find talented programmers who can think intelligently.
I hav just jumped to .net technologies its quite a good site for learners coz i can brush up wht i hav studied through the books. Thanks Mr.Mark Wagner
1. Explain the differences between Server-side and Client-side code? Server side code basically gets executed on the server (for example on a webserver) per request/call basis, while client side code gets executed and rendered on the client side (for example web browser as a platform) per response basis. 2. What type of code (server or client) is found in a Code-Behind class?
In the Code-behind class the server side code resides, and it generates the responses to the client appropriately while it gets called or requested. 3. Should validation (did the user enter a real date) occur server-side or client-side? Why? That depends. In the up browsers (like IE 5.0 and up and Netscape 6.0) this would help if it gets validated on the client side, because it reduces number of round trips between client and server. But for the down level browsers (IE 4.0 and below and Netscape 5.0 and below) it has to be on server side. Reason being the validation code requires some scripting on client side. 4. What does the "EnableViewState" property do? Why would I want it on or off? EnableViewState stores the current state of the page and the objects in it like text boxes, buttons, tables etc. So this helps not losing the state between the round trips between client and server. But this is a very expensive on browser. It delays rendering on the browser, so you should enable it only for the important fields/objects 5. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? Server.Transfer transfers the currnet context of the page to the next page and also avoids double roundtrips. Where as Response.Redirect could only pass querystring and also requires roundtrip. 6. Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component Webservice is one of main component in Service Oriented Architecture. You could use webservices when your clients and servers are running on different networks and also different platforms. This provides a loosely coupled system. And also if the client is behind the firewall it would be easy to use webserivce since it runs on port 80 (by default) instead of having some thing else in SOA apps . 7. Let's say I have an existing application written using Visual Studio 6 (VB 6, InterDev 6) and this application utilizes Windows 2000 COM+ transaction services. How would you approach migrating this application to .NET You have to use System.EnterpriseServices namespace and also COMInterop the existing application 8. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset? ADO.NET DataSet is a mini RDBMS based on XML, where as RecordSet is collection of rows. DataSet is independent of connection and communicates to the database through DataAdapter, so it could be attached to any well defined collections like hashtable, dictionary, tables, arraylists etc. practically. And also it can be bound to DataGrid etc. controls straightaway. RecordSet on the otherhand is tightly coupled to Database System. 9. Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines? In the Application_Start event you could store the data, which is used throughout the life time of an application for example application name, where as Session_Start could be used to store the information, which is required for that session of the application say for example user id or user name. 10. If I'm developing an application that must accomodate multiple security levels though secure login and my ASP.NET web appplication is spanned across three web-servers (using round-robbin load balancing) what would be the best approach to maintain login-in state for the users? Use the state server or store the state in the database. This can be easily done through simple setting change in the web.config.
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;user id=sa;password=" cookieless="false" timeout="30" /> in the above one instead of mode="InProc", you specifiy stateserver or sqlserver. 11. What are ASP.NET Web Forms? How is this technology different than what is available though ASP (1.0-3.0)? ASP.NET webforms are analogous to Windows Forms which are available to most VB developers. A webform is essentially a core container in a Page. An empty webform is nothing but a HTML Form tag(control) running at server and posting form to itself by default, but you could change it to post it to something else. This is a container, and you could place the web controls, user controls and HTML Controls in that one and interact with user on a postback basis. 12. How does VB.NET/C# achieve polymorphism? Polymorphism is achieved through virtual, overloaded, overridden methods in C# and VB.NET 11. Can you explain what inheritance is and an example of when you might use it? . 13. How would you implement inheYou missed the number sequence here). Inheritance is extending the properites, behaviour, methods to child classes from super classes. VB.NET and C# provide single inheritance, means the subclasses can be derived from only one parent unlike C++, where true multiple inheritance is possible. As an alternate to implement multiple inheritance, we could do the same to implement interfaces to the parent classes and implement the same interfaces to derive the child classesritance using VB.NET/C#? 14. Whats an assembly An assembly is the primary building block of .NET. It's a reusable, self-describing, versionable deployment unit for types and resources. They are self-describing so to allow the .NET runtime to fully understand the application and enforce dependency and versioning rules 15. Describe the difference between inline and code behind - which is best in a 16. loosely coupled solution 5 and 16. (You missed the sequence again). Inline style is mixing the server side code and client side code (HTML and javascript) on the same page and run it. Where as codebehind is seperating the server side in a different page (enabling developers/coders to work) and leaving the client side code to do the presentation only (so designers would work on it). Inline code would be simplest way of approach because it doesn't require any pre-compilation. But it is not good in many ways, i. You mix the presentation and server side code together so whenever there is a change it would be tough to maintain. ii. The event processing would be a night mare in inline code. iii. Since the codebehind needs to be compile in advance, it would be faster unline inline, which is interpreted per call basis. In a loosely couple situation, codebehind would be the best way to approach. Because it provides better performance. 17. Explain what a diffgram is, and a good use for one http://msdn.microsoft.com/library/default.asp?url=/library/enus/sqlxml3/htm/dotnet_11pr.asp 18. Where would you use an iHTTPModule, and what are the limitations of any 19. approach you might take in implementing one 20. What are the disadvantages of viewstate/what are the benefits 21 Describe session handling in a webfarm, how does it work and what
are the > limits 22. How would you get ASP.NET running in Apache web servers - why would you even do this? 23. Whats MSIL, and why should my developers need an appreciation of it if at all? 24. In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events? 25. Which method do you invoke on the DataAdapter control to load your generated dataset with data? 26. Can you edit data in the Repeater control? 27. Which template must you provide, in order to display data in a Repeater control? 28. How can you provide an alternating color scheme in a Repeater control? 29. What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control? 30. What base class do all Web Forms inherit from? 31. What method do you use to explicitly kill a user s session? 32 How do you turn off cookies for one page in your site? 33. Which two properties are on every validation control? 34. What tags do you need to add within the asp:datagrid tags to bind columns manually? 35. How do you create a permanent cookie? Supply never to the expiration date/time 36. What tag do you use to add a hyperlink column to the DataGrid? 37. What is the standard you use to wrap up a call to a Web service 38. Which method do you use to redirect the user to another page without performing a round trip to the client? 39. What is the transport protocol you use to call a Web service SOAP 40. True or False: A Web service can only be written in .NET 41. What does WSDL stand for? 42. What property do you have to set to tell the grid which page to go to when using the Pager object? 43. Where on the Internet would you look for Web services? 44. What tags do you need to add within the asp:datagrid tags to bind columns manually. 45. 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? 46. How is a property designated as read-only? 47. Which control would you use if you needed to make sure the values in two different controls matched? 48. True or False: To test a Web service you must create a windows application or Web application to consume this service? 49. How many classes can a single .NET DLL contain? 1 Describe session handling in a webform, how does it work and what are the its limits Sometimes it is necessary to carry a particular session data across pages. And HTTP is a stateless protocol. In order to maintain state between page calls, we could use cookies, hidden form fields etc. One of them is using sessions. each sessions are maintain a unique key on the server and serialize the data on it. Actually it is a hashtable and stores data on key/value pair of combination. You could set a session using Session Object and retrieve the same data/state by passing the key. //Set Session["abc"] = "Session Value"; // Get string abc = Session["abc"].ToString();
The downside of sessions is scalability. Say your application gets more and more hits and you though instead of one webserver handling it, have it in a webfarm (multiple web servers working under one domain). You cannot transfer the session so easily across multiple webservers. Reason is like I said, it physically serializes the state data to webserver hard disk. .NET proposes a new way to handle this using a stateserver (actually a trimmed down sql server) storing the web session data in a factory configured database schema or using Database with your own schema defined to handle the sessions. 2. How would you get ASP.NET running in Apache web servers - why would you even do this? You need to create a CLRHost, which hosts the CLR (ASP.NET) on top of Apache. Since Apache is #1 webserver used by many companies, this would allow more number of web site owners to take advantage of ASP.NET and its richness. 3. Whats MSIL, and why should my developers need an appreciation of it if at all? MSIL is Microsoft Intermediate (Intermediary) Language. It is Microsoft's implementation of CIL (standard recognized by ECMA and ISO) as part of CLI and C# Standardization. .NET supports more than 21 language (I think 24 now). They compile to IL first and then this IL would get JITted to Native code at runtime. Learning IL is advantageous in many terms. The important one is sometimes you need to optimize your code, so you could disassemble your compile assembly using ILDASM and tweak your code and re assemble it using ILASM. 4. In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events? This is the order of Page events i. Page_Init ii.Page_LoadViewState iii. Page_LoadPostData iv. Page_Load v. Page_RaisePostDataChanged vi. Page_RaisePostBackEvent vii. Page_PreRender viii. Page_SaveViewState ix. Page_Render x. Page_Dispose xii. Page_Error (this is caused whenever there is an exception at the page level). Out of all the Page_Load is the one where your code gets loaded and your magic should be written. page_init occurs only once, i.e. when the page is initially created. As a developer you need to know these, becuase your development activity is coding for these only. 5. Which method do you invoke on the DataAdapter control to load your
generated dataset with data? Fill() 6. Can you edit data in the Repeater control? No. Only DataList and DataGrid provide you editing capabilities. 7. Which template must you provide, in order to display data in a Repeater control? ItemTemplate 8. How can you provide an alternating color scheme in a Repeater control? Use AlternatingItemTemplate 9. What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control? The text property and the DataBind Method. 10. What base class do all Web Forms inherit from? System.Web.UI.Page 11. What method do you use to explicitly kill a user s session? Session.Abandon 12 How do you turn off cookies for one page in your site? Actually I never did this. But there should be a way to do this. May be need to write your own code to do this using Response.Cookies collection and HTTPCookie class and also SessionStateMode. Or there may be some simple way to do it. Need to do further research on this. 13. Which two properties are on every validation control? The common properties are: i. IsValid (bool) ii. ControlToValidate (string) iii. ErrorMessage (string) iv. ValidationDisplay (Display) v. Text (string) The common method is: Validate() 14. What tags do you need to add within the asp:datagrid tags to bind columns manually? You need to set AutoGenerateColumns Property to false. 15. How do you create a permanent cookie? If you are developing web services and the cookies need to be travelled across multiple requests, then you need to have permanent or persistant cookie. In order to do this, you have to set the your webserivce CookieContainer to a newly created
CookieContainer, and the its cookie to a session value and then store the cookie(s) into the Service CookieCollection from that cookie container if something is there othere wise add cookie to the container. 16. What tag do you use to add a hyperlink column to the DataGrid? HyperLinkColumn 17. What is the standard you use to wrap up a call to a Web service SOAP. 18. Which method do you use to redirect the user to another page without performing a round trip to the client? Server.Transfer Response.Redirect also does that but it requires round trip between client and server. 19. What is the transport protocol you use to call a Web service SOAP SOAP 20. True or False: A Web service can only be written in .NET False. 21. What does WSDL stand for? Web Services Description Language. 22. What property do you have to set to tell the grid which page to go to when using the Pager object? CurrentPageIndex. You need to set this one with the DataGridPageChangedEventArgs' NewPageIndex. 23. Where on the Internet would you look for Web services? UDDI.org, UDDI.Org (even microsoft maintains a uddi server-- http://uddi.microsoft.com) UDDI is Universal Description, Discovery and Integration of Web Services. The UDDI servers serves as yellow pages to WebServices (visit http://www.uddi.org) 24. What tags do you need to add within the asp:datagrid tags to bind columns manually. Set AutoGenerateColumns Property to false on the datagrid tag 25. 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? ListItem. 26. How is a property designated as read-only? If it has only get accessor. ex: public class abc { private string stringIt="This is the string"; public string StringIt { get { return stringIt; } } } But you could set an attribute prior to the property name with [ReadOnly="true"],
if that property defined an attribute 27. Which control would you use if you needed to make sure the values in two different controls matched? Use CompareValidator 28. True or False: To test a Web service you must create a windows application or Web application to consume this service? False. The webservice comes with a test page and it provides HTTP-GET method to test. And if the web service turned off HTTP-GET for security purposes then you need to create a web application or windows app as a client to this to test. 29. How many classes can a single .NET DLL contain? many is correct. Yes an assembly can contain one or more classes and an assembly can be contained in one dll or could spread across multiple dlls. too. Take System.dll, it is collections of so many classes. 2. What is CLR ? 2.1. Diff between CLR & CTS 3. Trace and Debug belongs to which namespaces? 4. ColumnMapping belongs to which namespaces? 5. In order to get assembly info whcih namespace we should import? 6. DIff. between Friend and Protected Friend. 7. What is an abstract class? 8. What is diff. between abstract class and an interface? what is shadowing ? Overloading allows a subclass to add a new variation of a method. As long as the new variation has a different method signature, it can have the same name as an existing method on the base class. Shadowing, on the other hand, entirely replaces all variations of the method from the base class, leaving the subclass with only a single version of the methodthe one we created through shadowing. Shadowing does not extend an interface, but rather replaces existing methods. Overriding allows a subclass to alter or replace an existing method with the permission of the base class designer. Shadowing can be done without the permission of the base class designer, which is a risky proposition and one that requires extensive testing because the base class was never designed with such a thing in mind. Also, as we discussed earlier, overriding uses virtual methods so the implementation of the method that is invoked is based on the data type of the underlying object, not the data type of the variable we're using. When a method is shadowed it is not virtual, and it is the data type of the variable that dictates the implementation of the method that will be used. The data type of the underlying object is ignored. http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnadvnet/html/vbnet12252001.asp * diff between Overriding and overloading 9. How do u declare static variable and how it is declared and what is its lifetime? 10. Diff between Dataset and Datareader? 11. How do u get record no from 5 to 15 from a dataset of 100 records. 12. diff. betn Dataset and Recordset. 13. why Datareader is useful? 14. How do u call and execute a SP in .NET? 15. What is DLL hell? 16. what is versioning in .NET? 17. What r the ASP.NET list controls and diff. between them? 18. What is diff. betn ASP State Management and ASP.NET State Management?(Imp) 19. How can we pass info. between 2 asp.net pages?
20. Diff betn Web User Control and Web Custom Control 21. What is an indexed property? 22. i've 2 buttons on an asp.net page(.aspx). i wanna execute same routine clicking on 2 buttons.how? 23. How do we Sort the data from a Dataset? 24. how do we get only edited/deleted/inserted records from a Dataset? 25. how Dataadapter.fill works? 26. how can we implement a Identity (SQL Server) call in an asp.net page? 27. What is Viewstate? 28. What is the life cycle of an asp.net page? 1. What does the keyword static mean when applied to a class member? 1. It means the method can be called through the class without instantiating the class. 2. Declare a method called calculate that takes one integer, adds one and returns the result. Allow this method to be overridden by an inheriting class. 2. Public virtual int calculate(int value) { newValue = value + 1; return newValue; } value++; return value; 3. What is the difference between a class and a struct? 3. The class object is stored in the heap and struct object is stored in the stack. Therefore accessing and removing data from the struct is faster than for a class. 4. What is the difference between a class and an interface? 4. You can instantiate a class but you cannot instantiate an interace you can only offer the functionality of that interface. 5. What are the .Net web authentication options and which one would generally be used for a secured/public site? 5. None Windows Authentication Secured side IIS Authentication Forms Authentication Public Side 6. What are some .Net options for maintaining session state? 6. In process and out of process. (wasn't sure about this one?) I believe the 6th one could be Querystring, Cookies, Session objects (variables) I wasn't sure, but I knew they could either be handled in the memory on the local machine (in process) or through the ASP.NET state service running either locally or remotely (out of process). 7. What is a Singleton? 7. This ensures that a class can only be instantiated once. Using the EMPLOYEE and JOBS tables, fill in the following stored procedure template so that it removes a job by job_id and all associated employees ensuring that both updates succeed or fail together. CREATE PROCEDURE deleteJob @jobid smallint AS
Database Answer: CREATE PROCEDURE deleteJob @jobid smallint AS BEGIN BEGIN TRAN IF EXISTS (SELECT * FROM JOBS WHERE job_id = @jobid) DELETE FROM JOBS WHERE job_id = @jobid IF @@ERROR <> 0 BEGIN RAISERROR(Could not delete row from Jobs Abort, 16,1) GOTO Errorhandler END IF EXISTS(SELECT * FROM EMPLOYEES WHERE job_id = @jobid) DELETE FROM EMPLOYEES WHERE job_id = @jobid IF @@ ERROR <> 0 BEGIN RAISERROR(Could not delete row from Employees Abort, 16,1) GOTO Errorhandler END COMMIT RETURN Errorhandler: ROLLBACK TRAN RETURN END You could also ask him what situations to use a datareader in, when to use a dataset etc... for ado.net In general they will be questions bascially on the SQL Server management, what kind of different services it provides. what the replication methods used. They will give you a situation where you have to choose which type of SQL sever edition you have to use. (there are 7). About ADO.NET, they will give some senario and ask you to use the appropriate methods like sort,filter, row state enumeration and all
1. What is other name for shared assembly? 2. How do you create and use shared assemblies? 3. How do you use thread in your .NET application? 4. what are the main differences between Web Server controls and HTML Server controls? 5. Differences between ref and out parameters? 6. How will you consume web services in ASP.NET? 7. To test web service you must create a windows application or web application to consume this service (True or False). 8. When on the internet would you look for web services? 9. Does .NET supports Pessimistic record locking or Optimistic record locking or both? 10. What is Catch API? 11. How do you handle concurrency errors? 12. where on the internet would you look for web services? 13. In .NET Exception handling model, what are the benefits of over return code? Shared assemblies. By including a strong name, the assembly can be shared by multiple
applications running on the same machine when installed in the Global Assembly Cache (GAC). This code-sharing model is the inverse of the model used in the unmanaged world, where COM components are automatically shared when compiled and registered in the system registry. Serviced Components. For a .NET class to take advantage of Enterprise Services (COM+ Services), such as distributed transactions and object pooling, the assembly that contains the classcalled a Serviced Component because it inherits from the class EnterpriseServices.ServicedComponentmust have a strong name. Having a strong name allows Enterprise Services to be sure it loads the correct assembly. Serviced Components that run in the process hosted by Enterprise Services (DLLHost.exe) should be placed in the GAC, while those running as library applications in the caller's process need not ADO.NET and Visual Studio .NET use optimistic concurrency, because the data architecture is based on disconnected data. Therefore, you need to add business logic to resolve issues with optimistic concurrency. If you choose to use optimistic concurrency, there are two general ways to determine if changes have occurred: the version approach (true version numbers or date-time stamps) and the saving all values approach. be. sion Number ApproachIn the version number approach, the record to be updated must have a column that contains a date-time stamp or version number. The date-time stamp or a version number is saved on the client when the record is read. This value is then made part of the update.One way to handle concurrency is to update only if value in the WHERE clause matches the value on the record. The SQL representation of this approach is: UPDATE Table1 SET Column1 = @newvalue1, Column2 = @newvalue2 WHERE DateTimeStamp = @origDateTimeStamp Alternatively, the comparison can be made using the version number: UPDATE Table1 SET Column1 = @newvalue1, Column2 = @newvalue2 WHERE RowVersion = @origRowVersionValue If the date-time stamps or version numbers match, the record in the data store has not changed and can be safely updated with the new values from the dataset. An error is returned if they don't match. You can write code to implement this form of concurrency checking in Visual Studio .NET. You will also have to write code to respond to any update conflicts. To keep the date-time stamp or version number accurate, you need to set up a trigger on the table to update it when a change to a row occurs A finally block can not have with break; continue; return or goto statements Hi Friends, I know some of the answers.... but i want to recheck it... Please give me the correct answers... or any links where i can study abt these... 1. what is the root namespace for all types? 2. What is CLR ? 2.1. Diff between CLR & CTS 3. Trace and Debug belongs to which namespaces? 4. ColumnMapping belongs to which namespaces? 5. In order to get assembly info whcih namespace we should import? 6. DIff. between Friend and Protected Friend. 7. What is an abstract class? 8. What is diff. between abstract class and an interface? * what is shadowing ? * diff between
Overriding and overloading 9. How do u declare static variable and how it is declared and what is its lifetime? 10. Diff between Dataset and Datareader? 11. How do u get record no from 5 to 15 from a dataset of 100 records. 12. diff. betn Dataset and Recordset. 13. why Datareader is useful? 14. How do u call and execute a SP in .NET? 15. What is DLL hell? 16. what is versioning in .NET? 17. What r the ASP.NET list controls and diff. between them? 18. What is diff. betn ASP State Management and ASP.NET State Management?(Imp) 19. How can we pass info. between 2 asp.net pages? 20. Diff betn Web User Control and Web Custom Control. 21. What is an indexed property? 22. i've 2 buttons on an asp.net page(.aspx). i wanna execute same routine clicking on 2 buttons.how? 23. How do we Sort the data from a Dataset? 24. how do we get only edited/deleted/inserted records from a Dataset? 25. how Dataadapter.fill works? 26. how can we implement a Identity (SQL Server) call in an asp.net page? 27. What is Viewstate? 28. What is the life cycle of an asp.net page? Thanks 1. System 2. Common Language Runtime 2.1. CLR - The common language runtime is the execution engine for .NET Framework applications. It provides a number of services, including the following: Code management (loading and execution) Application memory isolation Verification of type safety Conversion of IL to native code Access to metadata (enhanced type information) Managing memory for managed objects Enforcement of code access security Exception handling, including cross-language exceptions Interoperation between managed code, COM objects, and pre-existing DLLs (unmanaged code
and data) Automation of object layout Support for developer services (profiling, debugging, and so on) CTS - The common type system is a rich type system, built into the common language runtime, that supports the types and operations found in most programming languages. The common type system supports the complete implementation of a wide range of programming languages. 3. System.Diagnostics 4. System.Data.Common 5. System.Reflection 6. Protected - Available only to classes that inherit from our class. Friend - Available only to code within the project/component. Protected Friend - Available only to classes that inherit from our class (in any project) or to code within our project/component. This is a combination of Protected and Friend. 7. Abstract classes cannot be instantiated they can only be extended. You call the functionality of the abstract class without having to create an instance of it. 8. a) Interfaces don't have implementation and abstract classes can be partially implemented. From a practical point of view, interfaces can be implemented in any class and more than one interface can be implemented in a class, but abstract classes can only be implemented in the same class hierarchy (subclassing) and only one abstract class can be implemented in a class. b) Basically it's an mixture of non-virtual methods and method hiding. That is, in VB.NET overriding methods never hide while non-overriding methods always do. c) Overloading a method means that you are providing another version of an existing method that takes different input arguments/parameters. The method will have the same name as an existing method and may or may not have a different return type. It must have a different number and/or type of input parameters. Methods are identified by their name, and number and type of arguments. This is known as the method's signature. The return value of a method is not regarded as part of the signature. Overloading can be done within the same class i.e. you can have several methods defined in one class that have the same name, but different arguments, or it can be done in a class related to another by inheritance i.e. the superclass contains one method, and a subclass provides another version of the method with the same name and different arguments. Overriding a method means that you are replacing the method with your own version. The overriding method must be defined identically to the method being replaced. Overriding can only be done in inherited classes i.e. the superclass provides a method and the subclass redefines the method with one that has exactly the same name and arguments as the superclass version. This will cause the method to behave differently when it is called by an object of the subclass, to when it is called by an object of the superclass. 9. Has application scope...variable only goes out of scope when the application ends. code: public static int Size = 0;
10. The datareader is a forward only, readonly object. It will keep a connection open as long as it is open. It is a fast way to loop through records. The dataset can be used like an in memory representation of the database. You can use DataViews to filter and sort records for presentation. You can also establish relationships with the dataRelation object. You can use the dataset with a data adapter to update the database. These objects can keep track of changes and original values. When updating the database these objects can help to resolve conflicts or concurrency issues. 11. Working with ADO.NET Now, I'm tired...You can find the answers to all of these questions...If you really want to. __________________ "When that first bullet goes past your head, politics goes right out the window." Eric Bana Black Hawk Down
Good God. So many threads going on. I think there are a lot of desperate job searchers are out there (especially freshers). Every body is asking for questions to be sent to their email id. You already have got tons and tons of question in this page. Have you all done learning those. The basic thing is nobody knows what to study [what are the important topics to focus, how to study for the interview....[ we never know what Q would come from the interviewer] . Me too..Thats the reason i am here. By just going through the questions and answerers you can not win. All you need to do is once you done reading the particular topic for eg. ADO.Net, then search for questions and see if you could answer. Or just don't read the answer and try to remember that. Read that topic fully and try to understand. I got some basic questions, may seem very easy but try to answer [try to tell out loud in 3 or 4 lines] with out googling 1. 2. 3. 4. What What What What is is is is HTML ? XML ? the difference between a class and struct ? the difference between a Get and a Post ?
5. What is a managed code ? 6. int n *=2; int x = n & 1; What is the value of x ? 7. What is a friend in C++ ? Knowledge is Power. All the best for the hunters.
The inheritance question that you have is incomplete; you fail to mention both types of inheritance:implementation and interface inheritance. Also, the answer to your web service testing question is just plain wrong. 99 percent of .NET web services out there use complex types in method signatures to push data across the wire; the test page does not support this. Looks like you are trying to do a good thing here; but most of your answers are very incomplete. If you were an interviewee for a senior developer position with my company and gave some of the answers that you have listed they would definitely warrant follow up questions, or I would consider them wrong; and that is just at first glance. Dave
Dear All, Please send me all the FAQs on vb.net , asp.net & c#.net which might help me out in my inteview [email protected] Yogesh Choudhary 9890254775
you. We used SOAP, but I never coded for that part of it; I've coded to use other peoples' web services but never coded my own; never used a diffgram; etc. And as far as what the methods are, type a dang dot and see what pops up!
The answer for #24 is wrong. The data in repeater can be edited if Itemtemplates are added.
Hi Guru, Thankyou for such a wonderful site. I need sqlserver 2005 Questions and answer. Regards prakjiii
hi i am begineer in the asp.net i read wrox for beginners .now i am prepraing for the intervies so please send me the asp.net with c #question as soon as possible
I am keen to look more questions and answers on advanced features of .NET like Remoting, Reflection, Web Services, Assembly etc. Mail me if ne1 have : [email protected] Thanks, Intekhab
This page has got extensive list of Questions and Answers, even if you go through it once you should get good idea about what to expect in ASP.Net and .Net interviews I went through the answers of many of questions, for some of those answers you can expect sub-questions which one should be prepared for. So best way to tackle this is to learn about these .Net topics in little more details by going through online articles Or msdn. I think you have to know following topics to be confidently attend the interview: - CLR functions, CTS, MSIL, Metadata - OOP's in C# & VB.Net - .Net Remoting Basics & Web Services - XML & Serialization - Enterprise Services - ADO.Net, DataSets, Typed DataSets - Multi-threading and Syncronization - State Management in ASP.Net - Data binding in ASP.Net (specifically with Grid & List controls) - Security in ASP.Net - Application Configuration - Whats New in .Net Framework 2.0 (to be upto date with tecnology changes)
I just have the list, please look around for answers. Even I need it. Best of Luck!!
I am not impressed by your list of questions. If you really want to impress me get your MCSD. With the MCSD, they ask in depth questions. Not lame repeats of stuff you can google out on google.
hi myself atul kumar i have done MCA in 2005 and after that i continuesly search the job in dot net so u lease u send me some more questions on c# and asp.net so that i can prepare myself for the interviews in MNC thanks & regards atul kumar
Dear Friends , If You have any more question related to .net please send to me.I am very very thankful to you... Ajay Kumar
Hai Sir, you have given that Range Validator supports only int, str, and date but it also supports double and currency data types. please check it out and correct it!.
i need some more Question. If somebody have some fundoo questions in asp.net or c#.net pls send me at [email protected]
This site is ver helpfull for me and i need more information about this. Thanks
1.I wanna access controls of one form into another webform. (I dont want to use Session/Querystring etc) Is their any other Method please help. I tried using property by returing refernce of that control. 2.I want to destroy previous form when user moves from one form to another. The previous page should not be accessable again i.e it should be Expired. 3.How to navigate through all textbox in a form. Like i wanna clear the contents of all textboxes on my from using a for loop. 4.I want a list of availabe webservices.( I tried to find it on www.UDDI.org but couldn't find usefull one.
can we add/insert new items in drop-downlist during execution(running)? for tht seperate code is required in asp.net??? send me on:[email protected]
Plz answer my questions 1.what are ADO objects int .net? 2.What is differance between ASP.NET & ASP? 3.Is .net a platform independent? 4 What is default datatype in .net?
question 3: i would answer like this "the view state is available when Load event is fired" I was little confused with answer before and after... because this is main difference between this two events. During Init we can not see view state. question 10: full answer is integer, string, double, date and currency. greetings from Serbia:)
I had interview yesterday 13 out of 15 question was from your question. I wished I had seen your web site before the interview. Guys if you have interview it real help. Thank you for your time.
1.1 What is .NET? .NET is a general-purpose software development platform, similar to Java. At its core is a virtual machine that turns intermediate language (IL) into machine code. High-level language compilers for C#, VB.NET and C++ are provided to turn source code into IL. C# is a new programming language, very similar to Java. An extensive class library is included, featuring all the functionality one might expect from a contempory development platform - windows GUI development (Windows Forms), database access (ADO.NET), web development (ASP.NET), web services, XML etc. See also Microsoft's definition. 1.2 When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET. 1.3 What versions of .NET are there? The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on 15-Jan-2002. At the same time, the final version of Visual Studio.NET was made available to MSDN subscribers. .NET 1.1 was released in April 2003 - it's mostly bug fixes for 1.0. .NET 2.0 is expected in 2005. 1.4 What operating systems does the .NET Framework run on? The runtime supports Windows Server 2003, Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on XP and Windows 2000/2003. Windows 98/ME cannot be used for development. IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the ASP.NET Web Matrix web server does run on XP Home. The .NET Compact Framework is a version of the .NET Framework for mobile devices, running Windows CE or Windows Mobile.
The Mono project has a version of the .NET Framework that runs on Linux. 1.5 What tools can I use to develop .NET applications? There are a number of tools, described here in ascending order of cost: The .NET Framework SDK is free and includes command-line compilers for C++, C#, and VB.NET and various other utilities to aid development. ASP.NET Web Matrix is a free ASP.NET development environment from Microsoft. As well as a GUI development environment, the download includes a simple web server that can be used instead of IIS to host ASP.NET apps. This opens up ASP.NET development to users of Windows XP Home Edition, which cannot run IIS. Microsoft Visual C# .NET Standard 2003 is a cheap (around $100) version of Visual Studio limited to one language and also with limited wizard support. For example, there's no wizard support for class libraries or custom UI controls. Useful for beginners to learn with, or for savvy developers who can work around the deficiencies in the supplied wizards. As well as C#, there are VB.NET and C++ versions. Microsoft Visual Studio.NET Professional 2003. If you have a license for Visual Studio 6.0, you can get the upgrade. You can also upgrade from VS.NET 2002 for a token $30. Visual Studio.NET includes support for all the MS languages (C#, C++, VB.NET) and has extensive wizard support. At the top end of the price spectrum are the Visual Studio.NET 2003 Enterprise and Enterprise Architect editions. These offer extra features such as Visual Sourcesafe (version control), and performance and analysis tools. Check out the Visual Studio.NET Feature Comparison at http://msdn.microsoft.com/vstudio/howtobuy/choosing.asp 1.6 Why did they call it .NET? I don't know what they were thinking. They certainly weren't thinking of people using search tools. It's meaningless marketing nonsense - best not to think about it. 2. Terminology 2.1 What is the CLI? Is it the same as the CLR? The CLI (Common Language Infrastructure) is the definiton of the fundamentals of the .NET framework - the Common Type System (CTS), metadata, the Virtual Execution Environment (VES) and its use of intermediate language (IL), and the support of multiple programming languages via the Common Language Specification (CLS). The CLI is documented through ECMA - see http://msdn.microsoft.com/net/ecma/ for more details. The CLR (Common Language Runtime) is Microsoft's primary implementation of the CLI. Microsoft also have a shared source implementation known as ROTOR, for educational purposes, as well as the .NET Compact Framework for mobile devices. Non-Microsoft CLI implementations include Mono and DotGNU Portable.NET. 2.2 What is the CTS, and how does it relate to the CLS? CTS = Common Type System. This is the full range of types that the .NET runtime understands. Not all .NET languages support all the types in the CTS. CLS = Common Language Specification. This is a subset of the CTS which all .NET languages are expected to support. The idea is that any program which uses CLS-compliant types can interoperate with any .NET program written in any language. This interop is very fine-grained - for example a VB.NET class can inherit from a C# class. 2.3 What is IL? IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL during development. The IL is then converted to machine code at the point where the software is installed, or (more commonly) at run-time by a Just-In-Time (JIT) compiler. 2.4 What is C#? C# is a new language designed by Microsoft to work with the .NET framework. In their "Introduction to C#" whitepaper, Microsoft describe C# as follows: "C# is a simple, modern, object oriented, and type-safe programming language derived from C and C++. C# (pronounced C sharp) is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++." Substitute 'Java' for 'C#' in the quote above, and you'll see that the statement still works pretty well :-). If you are a C++ programmer, you might like to check out my C# FAQ. 2.5 What does 'managed' mean in the .NET context?
The term 'managed' is the cause of much confusion. It is used in various places within .NET, meaning slightly different things. Managed code: The .NET framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. Such code is called managed code. Managed data: This is data that is allocated and freed by the .NET runtime's garbage collector. Managed classes: This is usually referred to in the context of Managed Extensions (ME) for C+ +. When using ME C++, a class can be marked with the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector, but it also means more than that. The class becomes a fully paid-up member of the .NET community with the benefits and restrictions that brings. An example of a benefit is proper interop with classes written in other languages - for example, a managed C++ class can inherit from a VB class. An example of a restriction is that a managed class can only inherit from one base class. 2.6 What is reflection? All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly. Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries. Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember), or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder). 3. Assemblies 3.1 What is an assembly? An assembly is sometimes described as a logical .EXE or .DLL, and can be an application (with a main entry point) or a library. An assembly consists of one or more files (dlls, exes, html files etc), and represents a group of resources, type definitions, and implementations of those types. An assembly may also contain references to other assemblies. These resources, types and references are described in a block of data called a manifest. The manifest is part of the assembly, thus making the assembly self-describing. An important aspect of assemblies is that they are part of the identity of a type. The identity of a type is the assembly that houses it combined with the type name. This means, for example, that if assembly A exports a type called T, and assembly B exports a type called T, the .NET runtime sees these as two completely different types. Furthermore, don't get confused between assemblies and namespaces - namespaces are merely a hierarchical way of organising type names. To the runtime, type names are type names, regardless of whether namespaces are used to organise the names. It's the assembly plus the typename (regardless of whether the type name belongs to a namespace) that uniquely indentifies a type to the runtime. Assemblies are also important in .NET with respect to security - many of the security restrictions are enforced at the assembly boundary. Finally, assemblies are the unit of versioning in .NET - more on this below. 3.2 How can I produce an assembly? The simplest way to produce an assembly is directly from a .NET compiler. For example, the following C# program: public class CTest { public CTest() { System.Console.WriteLine( "Hello from CTest" ); } } can be compiled into a library assembly (dll) like this: csc /t:library ctest.cs You can then view the contents of the assembly by running the "IL Disassembler" tool that comes with the .NET SDK. Alternatively you can compile your source into modules, and then combine the modules into an assembly using the assembly linker (al.exe). For the C# compiler, the /target:module
switch is used to generate a module instead of an assembly. 3.3 What is the difference between a private assembly and a shared assembly? Location and visibility: A private assembly is normally used by a single application, and is stored in the application's directory, or a sub-directory beneath. A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, e.g. the .NET framework classes. Versioning: The runtime enforces versioning constraints only on shared assemblies, not on private assemblies. 3.4 How do assemblies find each other? By searching directory paths. There are several factors which can affect the path (such as the AppDomain host, and application configuration files), but for private assemblies the search path is normally the application's directory and its sub-directories. For shared assemblies, the search path is normally same as the private assembly path plus the shared assembly cache. 3.5 How does assembly versioning work? Each assembly has a version number called the compatibility version. Also each reference to an assembly (from another assembly) includes both the name and version of the referenced assembly. The version number has four numeric parts (e.g. 5.5.2.33). Assemblies with either of the first two parts different are normally viewed as incompatible. If the first two parts are the same, but the third is different, the assemblies are deemed as 'maybe compatible'. If only the fourth part is different, the assemblies are deemed compatible. However, this is just the default guideline - it is the version policy that decides to what extent these rules are enforced. The version policy can be specified via the application configuration file. Remember: versioning is only applied to shared assemblies, not private assemblies. 3.6 How can I develop an application that automatically updates itself from the web? For .NET 1.x, use the Updater Application Block. For .NET 2.x, use ClickOnce. 4. Application Domains 4.1 What is an application domain? An AppDomain can be thought of as a lightweight process. Multiple AppDomains can exist inside a Win32 process. The primary purpose of the AppDomain is to isolate applications from each other, and so it is particularly useful in hosting scenarios such as ASP.NET. An AppDomain can be destroyed by the host without affecting other AppDomains in the process. Win32 processes provide isolation by having distinct memory address spaces. This is effective, but expensive. The .NET runtime enforces AppDomain isolation by keeping control over the use of memory - all memory in the AppDomain is managed by the .NET runtime, so the runtime can ensure that AppDomains do not access each other's memory. One non-obvious use of AppDomains is for unloading types. Currently the only way to unload a .NET type is to destroy the AppDomain it is loaded into. This is particularly useful if you create and destroy types on-the-fly via reflection. Microsoft have an AppDomain FAQ. 4.2 How does an AppDomain get created? AppDomains are usually created by hosts. Examples of hosts are the Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new AppDomain for every application. AppDomains can also be explicitly created by .NET applications. Here is a C# sample which creates an AppDomain, creates an instance of an object inside it, and then executes one of the object's methods: using System; using System.Runtime.Remoting; using System.Reflection; public class CAppDomainInfo : MarshalByRefObject { public string GetName() { return AppDomain.CurrentDomain.FriendlyName; } } public class App {
public static int Main() { AppDomain ad = AppDomain.CreateDomain( "Andy's new domain" ); CAppDomainInfo adInfo = (CAppDomainInfo)ad.CreateInstanceAndUnwrap( Assembly.GetCallingAssembly().GetName().Name, "CAppDomainInfo" ); Console.WriteLine( "Created AppDomain name = " + adInfo.GetName() ); return 0; } } 4.3 Can I write my own .NET host? Yes. For an example of how to do this, take a look at the source for the dm.net moniker developed by Jason Whittington and Don Box. There is also a code sample in the .NET SDK called CorHost. 5. Garbage Collection 5.1 What is garbage collection? Garbage collection is a heap-management strategy where a run-time component takes responsibility for managing the lifetime of the memory used by objects. This concept is not new to .NET - Java and many other languages/runtimes have used garbage collection for some time. 5.2 Is it true that objects don't always get destroyed immediately when the last reference goes away? Yes. The garbage collector offers no guarantees about the time when an object will be destroyed and its memory reclaimed. There was an interesting thread on the DOTNET list, started by Chris Sells, about the implications of non-deterministic destruction of objects in C#. In October 2000, Microsoft's Brian Harry posted a lengthy analysis of the problem. Chris Sells' response to Brian's posting is here. 5.3 Why doesn't the .NET runtime offer deterministic destruction? Because of the garbage collection algorithm. The .NET garbage collector works by periodically running through a list of all the objects that are currently being referenced by an application. All the objects that it doesn't find during this search are ready to be destroyed and the memory reclaimed. The implication of this algorithm is that the runtime doesn't get notified immediately when the final reference on an object goes away - it only finds out during the next 'sweep' of the heap. Futhermore, this type of algorithm works best by performing the garbage collection sweep as rarely as possible. Normally heap exhaustion is the trigger for a collection sweep. 5.4 Is the lack of deterministic destruction in .NET a problem? It's certainly an issue that affects component design. If you have objects that maintain expensive or scarce resources (e.g. database locks), you need to provide some way to tell the object to release the resource when it is done. Microsoft recommend that you provide a method called Dispose() for this purpose. However, this causes problems for distributed objects - in a distributed system who calls the Dispose() method? Some form of referencecounting or ownership-management mechanism is needed to handle distributed objects unfortunately the runtime offers no help with this. 5.5 Should I implement Finalize on my class? Should I implement IDisposable? This issue is a little more complex than it first appears. There are really two categories of class that require deterministic destruction - the first category manipulate unmanaged types directly, whereas the second category manipulate managed types that require deterministic destruction. An example of the first category is a class with an IntPtr member representing an OS file handle. An example of the second category is a class with a System.IO.FileStream member. For the first category, it makes sense to implement IDisposable and override Finalize. This allows the object user to 'do the right thing' by calling Dispose, but also provides a fallback of freeing the unmanaged resource in the Finalizer, should the calling code fail in its duty. However this logic does not apply to the second category of class, with only managed resources. In this case implementing Finalize is pointless, as managed member objects cannot be accessed in the Finalizer. This is because there is no guarantee about the ordering of Finalizer execution. So only the Dispose method should be implemented. (If you think about it,
it doesn't really make sense to call Dispose on member objects from a Finalizer anyway, as the member object's Finalizer will do the required cleanup.) For classes that need to implement IDisposable and override Finalize, see Microsoft's documented pattern. Note that some developers argue that implementing a Finalizer is always a bad idea, as it hides a bug in your code (i.e. the lack of a Dispose call). A less radical approach is to implement Finalize but include a Debug.Assert at the start, thus signalling the problem in developer builds but allowing the cleanup to occur in release builds. 5.6 Do I have any control over the garbage collection algorithm? A little. For example the System.GC class exposes a Collect method, which forces the garbage collector to collect all unreferenced objects immediately. Also there is a gcConcurrent setting that can be specified via the application configuration file. This specifies whether or not the garbage collector performs some of its collection activities on a separate thread. The setting only applies on multi-processor machines, and defaults to true. 5.7 How can I find out what the garbage collector is doing? Lots of interesting statistics are exported from the .NET runtime via the '.NET CLR xxx' performance counters. Use Performance Monitor to view them. 5.8 What is the lapsed listener problem? The lapsed listener problem is one of the primary causes of leaks in .NET applications. It occurs when a subscriber (or 'listener') signs up for a publisher's event, but fails to unsubscribe. The failure to unsubscribe means that the publisher maintains a reference to the subscriber as long as the publisher is alive. For some publishers, this may be the duration of the application. This situation causes two problems. The obvious problem is the leakage of the subscriber object. The other problem is the performance degredation due to the publisher sending redundant notifications to 'zombie' subscribers. There are at least a couple of solutions to the problem. The simplest is to make sure the subscriber is unsubscribed from the publisher, typically by adding an Unsubscribe() method to the subscriber. Another solution, documented here by Shawn Van Ness, is to change the publisher to use weak references in its subscriber list. 5.9 When do I need to use GC.KeepAlive? It's very unintuitive, but the runtime can decide that an object is garbage much sooner than you expect. More specifically, an object can become garbage while a method is executing on the object, which is contrary to most developers' expectations. Chris Brumme explains the issue on his blog. I've taken Chris's code and expanded it into a full app that you can play with if you want to prove to yourself that this is a real problem: using System; using System.Runtime.InteropServices; class Win32 { [DllImport("kernel32.dll")] public static extern IntPtr CreateEvent( IntPtr lpEventAttributes, bool bManualReset,bool bInitialState, string lpName); [DllImport("kernel32.dll", SetLastError=true)] public static extern bool CloseHandle(IntPtr hObject); [DllImport("kernel32.dll")] public static extern bool SetEvent(IntPtr hEvent); } class EventUser { public EventUser() { hEvent = Win32.CreateEvent( IntPtr.Zero, false, false, null ); }
~EventUser() { Win32.CloseHandle( hEvent ); Console.WriteLine("EventUser finalized"); } public void UseEvent() { UseEventInStatic( this.hEvent ); } static void UseEventInStatic( IntPtr hEvent ) { //GC.Collect(); bool bSuccess = Win32.SetEvent( hEvent ); Console.WriteLine( "SetEvent " + (bSuccess ? "succeeded" : "FAILED!") ); } IntPtr hEvent; } class App { static void Main(string[] args) { EventUser eventUser = new EventUser(); eventUser.UseEvent(); } } If you run this code, it'll probably work fine, and you'll get the following output: SetEvent succeeded EventDemo finalized However, if you uncomment the GC.Collect() call in the UseEventInStatic() method, you'll get this output: EventDemo finalized SetEvent FAILED! (Note that you need to use a release build to reproduce this problem.) So what's happening here? Well, at the point where UseEvent() calls UseEventInStatic(), a copy is taken of the hEvent field, and there are no further references to the EventUser object anywhere in the code. So as far as the runtime is concerned, the EventUser object is garbage and can be collected. Normally of course the collection won't happen immediately, so you'll get away with it, but sooner or later a collection will occur at the wrong time, and your app will fail. A solution to this problem is to add a call to GC.KeepAlive(this) to the end of the UseEvent method, as Chris explains. 6. Serialization 6.1 What is serialization? Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process, i.e. creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database). 6.2 Does the .NET Framework have in-built support for serialization? There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code. 6.3 I want to serialize instances of my class. Should I use XmlSerializer, SoapFormatter or BinaryFormatter? It depends. XmlSerializer has severe limitations such as the requirement that the target class has a parameterless constructor, and only public read/write properties and fields can be
serialized. However, on the plus side, XmlSerializer has good support for customising the XML document that is produced or consumed. XmlSerializer's features mean that it is most suitable for cross-platform work, or for constructing objects from existing XML documents. SoapFormatter and BinaryFormatter have fewer limitations than XmlSerializer. They can serialize private fields, for example. However they both require that the target class be marked with the [Serializable] attribute, so like XmlSerializer the class needs to be written with serialization in mind. Also there are some quirks to watch out for - for example on deserialization the constructor of the new object is not invoked. The choice between SoapFormatter and BinaryFormatter depends on the application. BinaryFormatter makes sense where both serialization and deserialization will be performed on the .NET platform and where performance is important. SoapFormatter generally makes more sense in all other cases, for ease of debugging if nothing else. 6.4 Can I customise the serialization process? Yes. XmlSerializer supports a range of attributes that can be used to configure serialization for a particular class. For example, a field or property can be marked with the [XmlIgnore] attribute to exclude it from serialization. Another example is the [XmlElement] attribute, which can be used to specify the XML element name to be used for a particular property or field. Serialization via SoapFormatter/BinaryFormatter can also be controlled to some extent by attributes. For example, the [NonSerialized] attribute is the equivalent of XmlSerializer's [XmlIgnore] attribute. Ultimate control of the serialization process can be acheived by implementing the the ISerializable interface on the class whose instances are to be serialized. 6.5 Why is XmlSerializer so slow? There is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize or deserialize an object of a given type in an application, there is a significant delay. This normally doesn't matter, but it may mean, for example, that XmlSerializer is a poor choice for loading configuration settings during startup of a GUI application. 6.6 Why do I get errors when I try to serialize a Hashtable? XmlSerializer will refuse to serialize instances of any class that implements IDictionary, e.g. Hashtable. SoapFormatter and BinaryFormatter do not have this restriction. 6.7 XmlSerializer is throwing a generic "There was an error reflecting MyClass" error. How do I find out what the problem is? Look at the InnerException property of the exception that is thrown to get a more specific error message. 6.8 Why am I getting an InvalidOperationException when I serialize an ArrayList? XmlSerializer needs to know in advance what type of objects it will find in an ArrayList. To specify the type, use the XmlArrayItem attibute like this: public class Person { public string Name; public int Age; } public class Population { [XmlArrayItem(typeof(Person))] public ArrayList People; } 7. Attributes 7.1 What are attributes? There are at least two types of .NET attribute. The first type I will refer to as a metadata attribute - it allows some data to be attached to a class or method. This data becomes part of the metadata for the class, and (like other class metadata) can be accessed via reflection. An example of a metadata attribute is [serializable], which can be attached to a class and means that instances of the class can be serialized. [serializable] public class CTest {} The other type of attribute is a context attribute. Context attributes use a similar syntax to metadata attributes but they are fundamentally different. Context attributes provide an interception mechanism whereby instance activation and method calls can be pre- and/or post-processed. If you have encountered Keith Brown's universal delegator you'll be familiar with this idea.
7.2 Can I create my own metadata attributes? Yes. Simply derive a class from System.Attribute and mark it with the AttributeUsage attribute. For example: [AttributeUsage(AttributeTargets.Class)] public class InspiredByAttribute : System.Attribute { public string InspiredBy; public InspiredByAttribute( string inspiredBy ) { InspiredBy = inspiredBy; } } [InspiredBy("Andy Mc's brilliant .NET FAQ")] class CTest { } class CApp { public static void Main() { object[] atts = typeof(CTest).GetCustomAttributes(true); foreach( object att in atts ) if( att is InspiredByAttribute ) Console.WriteLine( "Class CTest was inspired by {0}", ((InspiredByAttribute)att).InspiredBy ); } } 7.3 Can I create my own context attibutes? Yes. Take a look at Peter Drayton's Tracehook.NET. 8. Code Access Security 8.1 What is Code Access Security (CAS)? CAS is the part of the .NET security model that determines whether or not code is allowed to run, and what resources it can use when it is running. For example, it is CAS that will prevent a .NET web applet from formatting your hard disk. 8.2 How does CAS work? The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set. For example, using the default security policy, a control downloaded from a web site belongs to the 'Zone - Internet' code group, which adheres to the permissions defined by the 'Internet' named permission set. (Naturally the 'Internet' named permission set represents a very restrictive range of permissions.) 8.3 Who defines the CAS code groups? Microsoft defines some default ones, but you can modify these and even create your own. To see the code groups defined on your system, run 'caspol -lg' from the command-line. On my system it looks like this: Level = Machine Code Groups: 1. All code: Nothing 1.1. Zone - MyComputer: FullTrust 1.1.1. Honor SkipVerification requests: SkipVerification
1.2. Zone - Intranet: LocalIntranet 1.3. Zone - Internet: Internet 1.4. Zone - Untrusted: Nothing 1.5. Zone - Trusted: Internet 1.6. StrongName 0024000004800000940000000602000000240000525341310004000003 000000CFCB3291AA715FE99D40D49040336F9056D7886FED46775BC7BB5430BA4444FEF834 8EBD06 F962F39776AE4DC3B7B04A7FE6F49F25F740423EBF2C0B89698D8D08AC48D69CED0FC8F83B 465E08 07AC11EC1DCC7D054E807A43336DDE408A5393A48556123272CEEEE72F1660B71927D3856 1AABF5C AC1DF1734633C602F8F2D5: Everything Note the hierarchy of code groups - the top of the hierarchy is the most general ('All code'), which is then sub-divided into several groups, each of which in turn can be sub-divided. Also note that (somewhat counter-intuitively) a sub-group can be associated with a more permissive permission set than its parent. 8.4 How do I define my own code group? Use caspol. For example, suppose you trust code from www.mydomain.com and you want it have full access to your system, but you want to keep the default restrictions for all other internet sites. To achieve this, you would add a new code group as a sub-group of the 'Zone Internet' group, like this: caspol -ag 1.3 -site www.mydomain.com FullTrust Now if you run caspol -lg you will see that the new group has been added as group 1.3.1: ... 1.3. Zone - Internet: Internet 1.3.1. Site - www.mydomain.com: FullTrust ... Note that the numeric label (1.3.1) is just a caspol invention to make the code groups easy to manipulate from the command-line. The underlying runtime never sees it. 8.5 How do I change the permission set for a code group? Use caspol. If you are the machine administrator, you can operate at the 'machine' level which means not only that the changes you make become the default for the machine, but also that users cannot change the permissions to be more permissive. If you are a normal (non-admin) user you can still modify the permissions, but only to make them more restrictive. For example, to allow intranet code to do what it likes you might do this: caspol -cg 1.2 FullTrust Note that because this is more permissive than the default policy (on a standard system), you should only do this at the machine level - doing it at the user level will have no effect. 8.6 Can I create my own permission set? Yes. Use caspol -ap, specifying an XML file containing the permissions in the permission set. To save you some time, here is a sample file corresponding to the 'Everything' permission set - just edit to suit your needs. When you have edited the sample, add it to the range of available permission sets like this: caspol -ap samplepermset.xml Then, to apply the permission set to a code group, do something like this: caspol -cg 1.3 SamplePermSet (By default, 1.3 is the 'Internet' code group) 8.7 I'm having some trouble with CAS. How can I troubleshoot the problem? Caspol has a couple of options that might help. First, you can ask caspol to tell you what code group an assembly belongs to, using caspol -rsg. Similarly, you can ask what permissions are being applied to a particular assembly using caspol -rsp. 8.8 I can't be bothered with CAS. Can I turn it off? Yes, as long as you are an administrator. Just run: caspol -s off 9. Intermediate Language (IL) 9.1 Can I look at the IL for an assembly? Yes. MS supply a tool called Ildasm that can be used to view the metadata and IL for an assembly.
9.2 Can source code be reverse-engineered from IL? Yes, it is often relatively straightforward to regenerate high-level source from IL. Lutz Roeder's Reflector does a very good job of turning IL into C# or VB.NET. 9.3 How can I stop my code being reverse-engineered from IL? You can buy an IL obfuscation tool. These tools work by 'optimising' the IL in such a way that reverse-engineering becomes much more difficult. Of course if you are writing web services then reverse-engineering is not a problem as clients do not have access to your IL. 9.4 Can I write IL programs directly? Yes. Peter Drayton posted this simple example to the DOTNET mailing list: .assembly MyAssembly {} .class MyApp { .method static void Main() { .entrypoint ldstr "Hello, IL!" call void System.Console::WriteLine(class System.Object) ret } } Just put this into a file called hello.il, and then run ilasm hello.il. An exe assembly will be generated. 9.5 Can I do things in IL that I can't do in C#? Yes. A couple of simple examples are that you can throw exceptions that are not derived from System.Exception, and you can have non-zero-based arrays. 10. Implications for COM 10.1 Does .NET replace COM? This subject causes a lot of controversy, as you'll see if you read the mailing list archives. Take a look at the following two threads: http://discuss.develop.com/archives/wa.exe?A2=ind0007&L=DOTNET&D=0&P=68241 http://discuss.develop.com/archives/wa.exe?A2=ind0007&L=DOTNET&P=R60761 The bottom line is that .NET has its own mechanisms for type interaction, and they don't use COM. No IUnknown, no IDL, no typelibs, no registry-based activation. This is mostly good, as a lot of COM was ugly. Generally speaking, .NET allows you to package and use components in a similar way to COM, but makes the whole thing a bit easier. 10.2 Is DCOM dead? Pretty much, for .NET developers. The .NET Framework has a new remoting model which is not based on DCOM. DCOM was pretty much dead anyway, once firewalls became widespread and Microsoft got SOAP fever. Of course DCOM will still be used in interop scenarios. 10.3 Is COM+ dead? Not immediately. The approach for .NET 1.0 was to provide access to the existing COM+ services (through an interop layer) rather than replace the services with native .NET ones. Various tools and attributes were provided to make this as painless as possible. Over time it is expected that interop will become more seamless - this may mean that some services become a core part of the CLR, and/or it may mean that some services will be rewritten as managed code which runs on top of the CLR. For more on this topic, search for postings by Joe Long in the archives - Joe is the MS group manager for COM+. Start with this message: http://discuss.develop.com/archives/wa.exe?A2=ind0007&L=DOTNET&P=R68370 10.4 Can I use COM components from .NET programs? Yes. COM components are accessed from the .NET runtime via a Runtime Callable Wrapper (RCW). This wrapper turns the COM interfaces exposed by the COM component into .NETcompatible interfaces. For oleautomation interfaces, the RCW can be generated automatically from a type library. For non-oleautomation interfaces, it may be necessary to develop a custom RCW which manually maps the types exposed by the COM interface to .NETcompatible types. Here's a simple example for those familiar with ATL. First, create an ATL component which implements the following IDL: import "oaidl.idl"; import "ocidl.idl";
[ object, uuid(EA013F93-487A-4403-86EC-FD9FEE5E6206), helpstring("ICppName Interface"), pointer_default(unique), oleautomation ] interface ICppName : IUnknown { [helpstring("method SetName")] HRESULT SetName([in] BSTR name); [helpstring("method GetName")] HRESULT GetName([out,retval] BSTR *pName ); }; [ uuid(F5E4C61D-D93A-4295-A4B4-2453D4A4484D), version(1.0), helpstring("cppcomserver 1.0 Type Library") ] library CPPCOMSERVERLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); [ uuid(600CE6D9-5ED7-4B4D-BB49-E8D5D5096F70), helpstring("CppName Class") ] coclass CppName { [default] interface ICppName; }; }; When you've built the component, you should get a typelibrary. Run the TLBIMP utility on the typelibary, like this: tlbimp cppcomserver.tlb If successful, you will get a message like this: Typelib imported successfully to CPPCOMSERVERLib.dll You now need a .NET client - let's use C#. Create a .cs file containing the following code: using System; using CPPCOMSERVERLib; public class MainApp { static public void Main() { CppName cppname = new CppName(); cppname.SetName( "bob" ); Console.WriteLine( "Name is " + cppname.GetName() ); } } Compile the C# code like this: csc /r:cppcomserverlib.dll csharpcomclient.cs Note that the compiler is being told to reference the DLL we previously generated from the typelibrary using TLBIMP. You should now be able to run csharpcomclient.exe, and get the following output on the console: Name is bob 10.5 Can I use .NET components from COM programs? Yes. .NET components are accessed from COM via a COM Callable Wrapper (CCW). This is
similar to a RCW (see previous question), but works in the opposite direction. Again, if the wrapper cannot be automatically generated by the .NET development tools, or if the automatic behaviour is not desirable, a custom CCW can be developed. Also, for COM to 'see' the .NET component, the .NET component must be registered in the registry. Here's a simple example. Create a C# file called testcomserver.cs and put the following in it: using System; using System.Runtime.InteropServices; namespace AndyMc { [ClassInterface(ClassInterfaceType.AutoDual)] public class CSharpCOMServer { public CSharpCOMServer() {} public void SetName( string name ) { m_name = name; } public string GetName() { return m_name; } private string m_name; } } Then compile the .cs file as follows: csc /target:library testcomserver.cs You should get a dll, which you register like this: regasm testcomserver.dll /tlb:testcomserver.tlb /codebase Now you need to create a client to test your .NET COM component. VBScript will do - put the following in a file called comclient.vbs: Dim dotNetObj Set dotNetObj = CreateObject("AndyMc.CSharpCOMServer") dotNetObj.SetName ("bob") MsgBox "Name is " & dotNetObj.GetName() and run the script like this: wscript comclient.vbs And hey presto you should get a message box displayed with the text "Name is bob". An alternative to the approach above it to use the dm.net moniker developed by Jason Whittington and Don Box. 10.6 Is ATL redundant in the .NET world? Yes. ATL will continue to be valuable for writing COM components for some time, but it has no place in the .NET world. 11. Miscellaneous 11.1 How does .NET remoting work? .NET remoting involves sending messages along channels. Two of the standard channels are HTTP and TCP. TCP is intended for LANs only - HTTP can be used for LANs or WANs (internet). Support is provided for multiple message serializarion formats. Examples are SOAP (XMLbased) and binary. By default, the HTTP channel uses SOAP (via the .NET runtime Serialization SOAP Formatter), and the TCP channel uses binary (via the .NET runtime Serialization Binary Formatter). But either channel can use either serialization format. There are a number of styles of remote access: SingleCall. Each incoming request from a client is serviced by a new object. The object is thrown away when the request has finished. Singleton. All incoming requests from clients are processed by a single server object. Client-activated object. This is the old stateful (D)COM model whereby the client receives a reference to the remote object and holds that reference (thus keeping the remote object alive) until it is finished with it. Distributed garbage collection of objects is managed by a system called 'leased based lifetime'. Each object has a lease time, and when that time expires the object is disconnected from the .NET runtime remoting infrastructure. Objects have a default renew time - the lease is renewed when a successful call is made from the client to the object. The client can also explicitly renew the lease. If you're interested in using XML-RPC as an alternative to SOAP, take a look at Charles Cook's XML-RPC.Net.
11.2 How can I get at the Win32 API from a .NET program? Use P/Invoke. This uses similar technology to COM Interop, but is used to access static DLL entry points instead of COM objects. Here is an example of C# calling the Win32 MessageBox function: using System; using System.Runtime.InteropServices; class MainApp { [DllImport("user32.dll", EntryPoint="MessageBox", SetLastError=true, CharSet=CharSet.Auto)] public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType); public static void Main() { MessageBox( 0, "Hello, this is PInvoke in operation!", ".NET", 0 ); } } Pinvoke.net is a great resource for off-the-shelf P/Invoke signatures. 11.3 How do I write to the application configuration file at runtime? You don't. See http://www.interact-sw.co.uk/iangblog/2004/11/25/savingconfig. 11.4 What is the difference between an event and a delegate? An event is just a wrapper for a multicast delegate. Adding a public event to a class is almost the same as adding a public multicast delegate field. In both cases, subscriber objects can register for notifications, and in both cases the publisher object can send notifications to the subscribers. However, a public multicast delegate has the undesirable property that external objects can invoke the delegate, something we'd normally want to restrict to the publisher. Hence events - an event adds public methods to the containing class to add and remove receivers, but does not make the invocation mechanism public. See this post by Julien Couvreur for more discussion. 11.5 What size is a .NET object? Each instance of a reference type has two fields maintained by the runtime - a method table pointer and a sync block. These are 4 bytes each on a 32-bit system, making a total of 8 bytes per object overhead. Obviously the instance data for the type must be added to this to get the overall size of the object. So, for example, instances of the following class are 12 bytes each: class MyInt { ... private int x; } However, note that with the current implementation of the CLR there seems to be a minimum object size of 12 bytes, even for classes with no data (e.g. System.Object). Values types have no equivalent overhead. 12. .NET 2.0 12.1 What are the new features of .NET 2.0? Generics, anonymous methods, partial classes, iterators, property visibility (separate visibility for get and set) and static classes. See http://msdn.microsoft.com/msdnmag/issues/04/05/C20/default.aspx for more information about these features. 12.2 What are the new 2.0 features useful for? Generics are useful for writing efficient type-independent code, particularly where the types might include value types. The obvious application is container classes, and the .NET 2.0 class library includes a suite of generic container classes in the System.Collections.Generic namespace. Here's a simple example of a generic container class being used: List<int> myList = new List<int>(); myList.Add( 10 ); Anonymous methods reduce the amount of code you have to write when using delegates, and are therefore especially useful for GUI programming. Here's an example
AppDomain.CurrentDomain.ProcessExit += delegate { Console.WriteLine("Process ending ..."); }; Partial classes is a useful feature for separating machine-generated code from hand-written code in the same class, and will therefore be heavily used by development tools such as Visual Studio. Iterators reduce the amount of code you need to write to implement IEnumerable/IEnumerator. Here's some sample code: static void Main() { RandomEnumerator re = new RandomEnumerator( 5 ); foreach( double r in re ) Console.WriteLine( r ); Console.Read(); } class RandomEnumerator : IEnumerable<double> { public RandomEnumerator(int size) { m_size = size; } public IEnumerator<double> GetEnumerator() { Random rand = new Random(); for( int i=0; i < m_size; i++ ) yield return rand.NextDouble(); } int m_size = 0; } The use of 'yield return' is rather strange at first sight. It effectively synthethises an implementation of IEnumerator, something we had to do manually in .NET 1.x. 12.3 What's the problem with .NET generics? .NET generics work great for container classes. But what about other uses? Well, it turns out that .NET generics have a major limitation - they require the type parameter to be constrained. For example, you cannot do this: static class Disposer<T> { public static void Dispose(T obj) { obj.Dispose(); } } The C# compiler will refuse to compile this code, as the type T has not been constrained, and therefore only supports the methods of System.Object. Dispose is not a method on System.Object, so the compilation fails. To fix this code, we need to add a where clause, to reassure the compiler that our type T does indeed have a Dispose method static class Disposer<T> where T : IDisposable { public static void Dispose(T obj) { obj.Dispose(); } } The problem is that the requirement for explicit contraints is very limiting. We can use constraints to say that T implements a particular interface, but we can't dilute that to simply say that T implements a particular method. Contrast this with C++ templates (for example), where no constraint at all is required - it is assumed (and verified at compile time) that if the code invokes the Dispose() method on a type, then the type will support the method. In fact, after writing generic code with interface constraints, we quickly see that we haven't gained much over non-generic interface-based programming. For example, we can easily rewrite the Disposer class without generics: static class Disposer { public static void Dispose( IDisposable obj ) { obj.Dispose(); } } For more on this topic, start by reading the following articles:
Bruce Eckel: http://www.mindview.net/WebLog/log-0050 Ian Griffiths: http://www.interact-sw.co.uk/iangblog/2004/03/14/generics Charles Cook: http://www.cookcomputing.com/blog/archives/000425.html Brad Wilson: http://dotnetguy.techieswithcats.com/archives/004273.shtml 12.4 What's new in the .NET 2.0 class library? Here is a selection of new features in the .NET 2.0 class library (beta 1): Generic collections in the System.Collections.Generic namespace. The System.Nullable<T> type. (Note that C# has special syntax for this type, e.g. int? is equivalent to Nullable<int>) The GZipStream and DeflateStream classes in the System.IO.Compression namespace. The Semaphore class in the System.Threading namespace. Wrappers for DPAPI in the form of the ProtectedData and ProtectedMemory classes in the System.Security.Cryptography namespace. The IPC remoting channel in the System.Runtime.Remoting.Channels.Ipc namespace, for optimised intra-machine communication. 13. Class Library 13.1 Threads 13.1.1 How do I spawn a thread? Create an instance of a System.Threading.Thread object, passing it an instance of a ThreadStart delegate that will be executed on the new thread. For example: class MyThread { public MyThread( string initData ) { m_data = initData; m_thread = new Thread( new ThreadStart(ThreadMain) ); m_thread.Start(); } // ThreadMain() is executed on the new thread. private void ThreadMain() { Console.WriteLine( m_data ); } public void WaitUntilFinished() { m_thread.Join(); } private Thread m_thread; private string m_data; } In this case creating an instance of the MyThread class is sufficient to spawn the thread and execute the MyThread.ThreadMain() method: MyThread t = new MyThread( "Hello, world." ); t.WaitUntilFinished(); 13.1.2 How do I stop a thread? There are several options. First, you can use your own communication mechanism to tell the ThreadStart method to finish. Alternatively the Thread class has in-built support for instructing the thread to stop. The two principle methods are Thread.Interrupt() and Thread.Abort(). The former will cause a ThreadInterruptedException to be thrown on the thread when it next goes into a WaitJoinSleep state. In other words, Thread.Interrupt is a polite way of asking the thread to stop when it is no longer doing any useful work. In contrast, Thread.Abort() throws a ThreadAbortException regardless of what the thread is doing. Furthermore, the ThreadAbortException cannot normally be caught (though the ThreadStart's finally method will be executed). Thread.Abort() is a heavy-handed mechanism which should not normally be required. 13.1.3 How do I use the thread pool?
By passing an instance of a WaitCallback delegate to the ThreadPool.QueueUserWorkItem() method class CApp { static void Main() { string s = "Hello, World"; ThreadPool.QueueUserWorkItem( new WaitCallback( DoWork ), s ); Thread.Sleep( 1000 ); // Give time for work item to be executed } // DoWork is executed on a thread from the thread pool. static void DoWork( object state ) { Console.WriteLine( state ); } } 13.1.4 How do I know when my thread pool work item has completed? There is no way to query the thread pool for this information. You must put code into the WaitCallback method to signal that it has completed. Events are useful for this. 13.1.5 How do I prevent concurrent access to my data? Each object has a concurrency lock (critical section) associated with it. The System.Threading.Monitor.Enter/Exit methods are used to acquire and release this lock. For example, instances of the following class only allow one thread at a time to enter method f(): class C { public void f() { try { Monitor.Enter(this); ... } finally { Monitor.Exit(this); } } } C# has a 'lock' keyword which provides a convenient shorthand for the code above: class C { public void f() { lock(this) { ... } } } Note that calling Monitor.Enter(myObject) does NOT mean that all access to myObject is serialized. It means that the synchronisation lock associated with myObject has been acquired, and no other thread can acquire that lock until Monitor.Exit(o) is called. In other words, this class is functionally equivalent to the classes above: class C { public void f() {
lock( m_object ) { ... } } private m_object = new object(); } Actually, it could be argued that this version of the code is superior, as the lock is totally encapsulated within the class, and not accessible to the user of the object. 13.1.6 Should I use ReaderWriterLock instead of Monitor.Enter/Exit? Maybe, but be careful. ReaderWriterLock is used to allow multiple threads to read from a data source, while still granting exclusive access to a single writer thread. This makes sense for data access that is mostly read-only, but there are some caveats. First, ReaderWriterLock is relatively poor performing compared to Monitor.Enter/Exit, which offsets some of the benefits. Second, you need to be very sure that the data structures you are accessing fully support multithreaded read access. Finally, there is apparently a bug in the v1.1 ReaderWriterLock that can cause starvation for writers when there are a large number of readers. Ian Griffiths has some interesting discussion on ReaderWriterLock here and here. 13.2 Tracing 13.2.1 Is there built-in support for tracing/logging? Yes, in the System.Diagnostics namespace. There are two main classes that deal with tracing Debug and Trace. They both work in a similar way - the difference is that tracing from the Debug class only works in builds that have the DEBUG symbol defined, whereas tracing from the Trace class only works in builds that have the TRACE symbol defined. Typically this means that you should use System.Diagnostics.Trace.WriteLine for tracing that you want to work in debug and release builds, and System.Diagnostics.Debug.WriteLine for tracing that you want to work only in debug builds. 13.2.2 Can I redirect tracing to a file? Yes. The Debug and Trace classes both have a Listeners property, which is a collection of sinks that receive the tracing that you send via Debug.WriteLine and Trace.WriteLine respectively. By default the Listeners collection contains a single sink, which is an instance of the DefaultTraceListener class. This sends output to the Win32 OutputDebugString() function and also the System.Diagnostics.Debugger.Log() method. This is useful when debugging, but if you're trying to trace a problem at a customer site, redirecting the output to a file is more appropriate. Fortunately, the TextWriterTraceListener class is provided for this purpose. Here's how to use the TextWriterTraceListener class to redirect Trace output to a file: Trace.Listeners.Clear(); FileStream fs = new FileStream( @"c:\log.txt", FileMode.Create, FileAccess.Write ); Trace.Listeners.Add( new TextWriterTraceListener( fs ) ); Trace.WriteLine( @"This will be writen to c:\log.txt!" ); Trace.Flush(); Note the use of Trace.Listeners.Clear() to remove the default listener. If you don't do this, the output will go to the file and OutputDebugString(). Typically this is not what you want, because OutputDebugString() imposes a big performance hit. 13.2.3 Can I customise the trace output? Yes. You can write your own TraceListener-derived class, and direct all output through it. Here's a simple example, which derives from TextWriterTraceListener (and therefore has inbuilt support for writing to files, as shown above) and adds timing information and the thread ID for each trace line: class MyListener : TextWriterTraceListener { public MyListener( Stream s ) : base(s) { } public override void WriteLine( string s ) {
Writer.WriteLine( "{0:D8} [{1:D4}] {2}", Environment.TickCount - m_startTickCount, AppDomain.GetCurrentThreadId(), s ); } protected int m_startTickCount = Environment.TickCount; } (Note that this implementation is not complete - the TraceListener.Write method is not overridden for example.) The beauty of this approach is that when an instance of MyListener is added to the Trace.Listeners collection, all calls to Trace.WriteLine() go through MyListener, including calls made by referenced assemblies that know nothing about the MyListener class. 13.2.4 Are there any third party logging components available? Log4net is a port of the established log4j Java logging component. These are very basic question. If find any problem u can contact me at [email protected] or [email protected] Thanx & Regards Abhishek Saxena, India
Session Never Expired --------------------------On Code Project, I found something very useful in which the author was discussing a very beautiful idea for preventing session timeouts Idea was to call the following function in the Page Load() event. private void ReconnectSession() { int int_MilliSecondsTimeOut = (this.Session.Timeout * 60000) - 30000; string str_Script = @" <script type='text/javascript'> function Reconnect()
{ window.open('reconnect.aspx','reconnect','width=5,height=5,top=180 0,left=1800,scrollbars=no,showintaskbar=no'); } window.setInterval('Reconnect()',"+int_MilliSecondsTimeOut.ToString()+ @"); </script> "; this.Page.RegisterClientScriptBlock("Reconnect", str_Script); } Using the above code the page will restore the session variables 30 seconds prior to session timeout specified in the web.config file. What it does is, calling a javascript function that opens a page in a new window. This javascript function call is "scheduled" so that the it will happen when the session is going to expire in 30 seconds. window.setInterval() is used for that purpose. In my application, some details were to be retrieved from the database at the time of session renewal. Reconnect.aspx is the page in which these things are done. You can put your own code in that page. In the actual article on Code Project, the author was trying to embed the page within a java script Image() tag. This was not suitable for my application. So 30 seconds prior to session expiry, I am opening a window with the above properties and after refreshing the session variables, it will close automatically. Since that idea is pretty straight forward, we are not discussing it here. The trickiest part of the game is yet to come. If the application consists of more than 50 or 100 pages, in order to avoid pasting the code in every page, we can make use of the inheritance feature of web forms. As we know, all the web forms are inherited from the System.Web.UI.Page class. We can add a class file to the project that inherits from System.Web.UI.Page class. public class YourNewPageClass : System.Web.UI.Page Then add the following code to the class. override protected void OnInit(EventArgs e) { base.OnInit(e); if (Context.Session != null) { int int_MilliSecondsTimeOut = (this.Session.Timeout * 60000) - 30000; string str_Script = @" <script type='text/javascript'> function Reconnect() { window.open('reconnect.aspx','reconnect','width=5,height=5,top=1800,left=1800,scrollbars= no,showintaskbar=no'); } window.setInterval('Reconnect()',"+int_MilliSecondsTimeOut.ToString()+ @"); </script>"; this.Page.RegisterClientScriptBlock("Reconnect", str_Script); } } Solution 2 I recently came across some code which attempted to fix this problem but that was unsuccessful because the author had forgotten the issue of client side caching. Add to your page the following code: private void Page_Load(object sender, System.EventArgs e) { this.AddKeepAlive(); }
private void AddKeepAlive() { int int_MilliSecondsTimeOut = (this.Session.Timeout * 60000) - 30000; string str_Script = @" <script type='text/javascript'> //Number of Reconnects var count=0; //Maximum reconnects setting var max = 5; function Reconnect() { count++; if (count < max) { window.status = 'Link to Server Refreshed ' + count.toString()+' time(s)' ; var img = new Image(1,1); img.src = 'Reconnect.aspx'; } } window.setInterval('Reconnect()',"+ _ int_MilliSecondsTimeOut.ToString()+ @"); //Set to length required </script> "; this.Page.RegisterClientScriptBlock("Reconnect", str_Script); } This code will cause the client to request within 30 seconds of the session timeout the page Reconnect.aspx. The Important Part Now this works the first time but if the page is cached locally then the request is not made to the server and the session times out again, so what we have to do is specify that the page Reconnect.aspx cannot be cached at the server or client. This is done by creating the Reconnect.aspx page with this content: <%@ OutputCache Location="None" VaryByParam="None" %> <html> </html> The OutputCache directive prevents this from being cached and so the request is made each time. No code behind file will be needed for this page so no @Page directive is needed either.
Questions and solutions given are very very helpful for the job seekers
hi i am begineer in the asp.net i read wrox for beginners .now i am prepraing for the intervies so please send me the asp.net with vb.net & c #question. my id is [email protected] Thanks & regards, anil
qustions r very usefull for any one . send me more qustions n ans. related to asp.net, remoting,socket programming, c#.
sir, i want to know how to add yahoo,gmail & rediffmail and access them from one page.if u have any information then pls send me on [email protected]
The questions and answers in this article are quite useful in an interview. I am very thankful to this site. From shailesh e-mail id: [email protected] `
# re: Interview Questions: ASP.NET 6/6/2006 9:45 PM Rupesh sharma (S/W Devlpr. NIIT Ltd. Gurgaon)
how does the .net framework support explicit standardized version management?
HI I m vishal, completed BE computer (2005), Pune university and seeking for job. i m interested in .NET technologies so plz send me more & more questions and ans .....and material regarding .net interview...waiting for ur help.
I done two project in ASP.Net and I am final year student. I am searching good job in ASP.Net
I agree with Mr. Mark Haffman... but ..... still.... this info is useful for most ......... and ...... any peice of information on .Net is highly useful ... no matter .... how small the info is..... but it is ... greatly useful........ Friends.... if u hav any usful info on .Net plz forward them to my mail id...... here it [email protected] or [email protected]. My advance thanks for those who are willing to help me........ hav a great time....
methods do the same, Move and Resize are the names adopted from VB to ease migration to C#. 14. How would you create a non-rectangular window, lets say an ellipse? Create a rectangular form, set the TransparencyKey property to the same value as BackColor, which will effectively make the background of the form transparent. Then set the FormBorderStyle to FormBorderStyle.None, which will remove the contour and contents of the form. 15. How do you create a separator in the Menu Designer? A hyphen - would do it. Also, an ampersand &\ would underline the next letter. 16. Hows anchoring different from docking? Anchoring treats the component as having the absolute size and adjusts its location relative to the parent form. Docking treats the component location as absolute and disregards the component size. So if a status bar must always be at the bottom no matter what, use docking. If a button should be on the top right, but change its position with the form being resized, use anchoring. AND FEEEW MORE>>>> 1. Write a simple Windows Forms MessageBox statement. 2. System.Windows.Forms.MessageBox.Show 3. ("Hello, Windows Forms"); 4. Can you write a class without specifying namespace? Which namespace does it belong to by default?? Yes, you can, then the class belongs to global namespace which has no name. For commercial products, naturally, you wouldnt want global namespace. 5. You are designing a GUI application with a window and several widgets on it. The user then resizes the app window and sees a lot of grey space, while the widgets stay in place. Whats the problem? One should use anchoring for correct resizing. Otherwise the default property of a widget on a form is top-left, so it stays at the same location when resized. 6. How can you save the desired properties of Windows Forms application? .config files in .NET are supported through the API to allow storing and retrieving information. They are nothing more than simple XML files, sort of like what .ini files were before for Win32 apps. 7. So how do you retrieve the customized properties of a .NET application from XML .config file? Initialize an instance of AppSettingsReader class. Call the GetValue method of AppSettingsReader class, passing in the name of the property and the type expected. Assign the result to the appropriate variable. 8. Can you automate this process? In Visual Studio yes, use Dynamic Properties for automatic .config creation, storage and retrieval. 9. My progress bar freezes up and dialog window shows blank, when an intensive background process takes over. Yes, you shouldve multi-threaded your GUI, with taskbar and main form being one thread, and the background process being the other. 10. Whats the safest way to deploy a Windows Forms app? Web deployment: the user always downloads the latest version of the code; the program runs within security sandbox, properly written app will not require additional security privileges. 11. Why is it not a good idea to insert code into InitializeComponent method when working with Visual Studio? The designer will likely throw it away; most of the code inside InitializeComponent is auto-generated. 12. Whats the difference between WindowsDefaultLocation and WindowsDefaultBounds? WindowsDefaultLocation tells the form to start up at a location selected by OS, but with internally specified size. WindowsDefaultBounds delegates both size and starting position choices to the OS. 13. Whats the difference between Move and LocationChanged? Resize and SizeChanged? Both methods do the same, Move and Resize are the names adopted from VB to ease migration to C#. 14. How would you create a non-rectangular window, lets say an ellipse? Create a rectangular form, set the TransparencyKey property to the same value as BackColor, which will effectively make the background of the form transparent. Then set the FormBorderStyle to FormBorderStyle.None, which will remove the contour and contents of the form. 15. How do you create a separator in the Menu Designer? A hyphen - would do it. Also, an ampersand &\ would underline the next letter. 16. Hows anchoring different from docking? Anchoring treats the component as having the
absolute size and adjusts its location relative to the parent form. Docking treats the component location as absolute and disregards the component size. So if a status bar must always be at the bottom no matter what, use docking. If a button should be on the top right, but change its position with the form being resized, use anchoring. Alll The Best Frndz
Also frnd... try to find answers.... to some unanswered questions in the above questions..... it is worth... if u can work out those questins. If u hav any questions.... plz forward them to my id..... [email protected] or [email protected]
NET Portable Executable File: A Windows executable, EXE or DLL, must conform to a file format called the PE file format, which is a derivative of the Microsoft Common Object File Format (COFF). Both of these formats are fully specified and publicly available. The Windows OS knows how to load and execute DLLs and EXEs because it understands the format of a PE file. Given this, any compiler that wants to generate Windows executables must obey the PE/COFF specification. Standard Windows PE files are divided into two major sections. The first section includes the PE/COFF headers that reference the contents within the PE file. In addition to the header section, the PE file holds a number of native image sections, including the .data, .rdata, .rsrc , and .Text sections. These are the standard sections of a typical Windows executable, but Microsoft's C/C++ compiler allows you to add your own custom sections into the PE file using a compiler pragma statement. For example, you can create your own data section to hold encrypted data that only you can read. Taking advantage of this ability, Microsoft has added a few new sections to the normal PE file specifically to support the CLR's functionality. The CLR understands and manages the new sections. For example, the CLR will read these sections and determine how to load classes and execute your code at runtime. The sections that Microsoft has added to the normal PE format are the CLR header and the CLR data sections. While the CLR header stores information to indicate that the PE file is a .NET executable, the CLR data section contains metadata and IL code, both of which determine how the program will be executed. Metadata
Metadata is machine -readable information about a resource, or "data about data." Such information might include details on content, format, size, or other characteristics of a data source. In .NET, metadata includes type definitions, version information, external assembly references, and other standardized information. In order for two components, systems, or objects to interoperate with one another, at least one must know something about the other. In COM, this "something" is an interface specification, which is implemented by a component provider and used by its consumers. In .NET, metadata is a common mechanism or dialect that the .NET runtime, compilers, and tools can all use. Microsoft .NET uses metadata to describe all types that are used and exposed by a particular .NET assembly. Metadata includes descriptions of an assembly and modules, classes, interfaces, methods, properties, fields, events, global methods, and so forth. .NET assemblies are deployable units and manifests are the metadata that describes the assemblies. IL Code: An assembly contains the IL code that the CLR executes at runtime. The IL code typically uses types defined within the same assembly, but it also may use or refer to types in other assemblies. There is one caveat: each assembly can have at most one entry point, such as DllMain( ), WinMain( ), or Main( ). You must follow this rule because when the CLR loads an assembly, it searches for one of these entry points to start assembly execution. There are four types of assemblies in .NET: Static assemblies: These are the .NET PE files that you create at compile time. You can create static assemblies using your favorite compiler: csc, cl, or vbc. Dynamic assemblies: These are PE-formatted, in-memory assemblies that you dynamically create at runtime using the classes in the System.Reflection.Emit namespace. Private assemblies: These are static assemblies used by a specific application. Public or shared assemblies: These are static assemblies that must have a unique shared name and can be used by any application. Side-by-Side Execution: The CLR allows any versions of the same-shared DLL (shared assembly) to execute at the same time, on the same system, and even in the same process. This concept is known as side-by-side execution. Manifests: Assembly Metadata An assembly manifest is metadata that describes everything about the assembly, including its identity, a list of files belonging to the assembly, references to external assemblies, exported types, exported resources, and permission requests. In short, it describes all the details that are required for component plug-and-play. Since an assembly contains all these details, there's no need for storing this type of information in the registry, as in the COM world. An assembly can be a single-module assembly or a multi-module assembly. In a singlemodule assembly, everything in a build is clumped into one EXE or DLL, an example of which is the hello.exe application that we developed earlier. This is easy to create because a compiler takes care of creating the single -module assembly for you. A multi-module assembly is one that contains many modules and resource files. To create it you have to use the Assembly Linker (al.exe) that is provided by the .NET SDK. This tool takes one or more IL or resource files and spits out a file with an assembly manifest.
Any .NET language may be converted into IL, so .NET supports multiple languages and perhaps multiple platforms in the future (as long as the target platforms have a CLR). The Common Type System (CTS): Because .NET treats all languages as equal, a class written in C# should be equivalent to a class written in VB.NET, and an interface defined in Managed C++ should be exactly the same as one that is specified in managed COBOL. Languages must agree on the meanings of these concepts before they can integrate with one another. In order to make language integration a reality, Microsoft has specified a common type system to which every .NET language must abide. Interfaces: Interfaces support exactly the same concept as a C++ abstract base class (ABC) with only pure virtual functions. An ABC is a class that declares one or more pure virtual functions and thus cannot be instantiated. If you know COM or Java, interfaces in .NET are conceptually equivalent to a COM or Java interface. You specify them, but you don't implement them. A class that derives from your interface must implement your interface. An interface may contain methods, properties, indexers, and events. In .NET, a class can derive from multiple interfaces. The Common Language Specification (CLS): Microsoft has published the Common Language Specification (CLS). The CLS specifies a series of basic rules that are required for language integration. Since Microsoft provides the CLS that spells out the minimum requirements for being a .NET language, compiler vendors can build their compilers to the specification and provide languages that target .NET. Besides compiler writers, application developers should read the CLS and use its rules to guarantee language interoperation. CLR Execution: .Net PE Files(Metadata And IL) >> Class Loader >> Verifier >> JIT >> Managed Native Code Once the class loader has found and loaded the target class, it caches the type information for the class so that it doesn't have to load the class again for the duration of this process. The verifier is responsible for verifying that: 1. The metadata is well formed, meaning the metadata must be valid. 2. The IL code is type safe, meaning type signatures are used correctly. The JIT compilers convert IL to native code so that it can execute on the target operating system. For optimization reasons, JIT compilation occurs only the first time a method is invoked. Recall that the class loader adds a stub to each method during class loading. At the first method invocation, the VEE reads the information in this stub, which tells it that the code for the method has not been JIT compiled. At this indication, the JIT compiler compiles the method and injects the address of the managed native method into this stub. During subsequent invocations to the same method, no JIT compilation is needed because each time the VEE goes to read information in the stub, it sees the address of the native method. Because the JIT compiler only performs its magic the first time a method is invoked, the methods you don't need at runtime will never be JIT compiled. The compiled, native code lies in memory until the process shuts down and until the garbage collector clears off all references and memory associated with the process. This means that the next time you execute the process or component, the JIT compiler will again perform its magic. If you want to avoid the cost of JIT compilation at runtime, you can use a special tool called ngen, which compiles your IL during installation and setup time. Using ngen, you can JITcompile the code once and cache it on the machine so that you can avoid JIT compilation at runtime (this process is referred to as Pre-JITting). In the event that the PE file has been updated, you must PreJIT the PE file again. Otherwise, the CLR can detect the update and dynamically command the appropriate JIT compiler to compile the assembly.
All .NET assemblies are essentially binary components. You can treat each .NET assembly as a component that you can plug into another component or application, without the need for source code, since all the metadata for the component is stored inside the .NET assembly. While you have to perform a ton of plumbing to build a component in COM, you need to perform zero extra work to get a component in .NET, as all .NET assemblies are components by nature. Remember, we're using the term "component" as a binary, deployable unit, not as a COM class. Shared Components: Unlike application-private assemblies, shared assemblies - ones that can be used by any client application - must be published or registered in the system Global Assembly Cache (GAC). When you register your assemblies against the GAC, they act as system components, such as a system DLL that every process in the system can use. A prerequisite for GAC registration is that the component must possess originator and version information. In addition to other metadata, these two items allow multiple versions of the same component to be registered and executed on the same machine. Again, unlike COM, we don't have to store any information in the system registry for clients to use these shared assemblies. Object Pooling: A pool is technical term that refers to a group of resources, such as connections, threads, and objects. Putting a few objects into a pool allows hundreds of clients to share these few objects (you can make the same assertion for threads, connections, and other objects). Pooling is therefore a technique that minimizes the use of system resources, improves performance, and helps system scalability. ADO.NET Architecture: Microsoft ADO.NET's object model encompasses two distinct groups of classes: content components and managed-provider components. The content components include the DataSet class and other supporting classes such as DataTable, DataRow, DataColumn, and DataRelation. These classes contain the actual content of a data exchange. The managedprovider components assist in data retrievals and updates. Microsoft provides two managed providers in its current release of ADO.NET: OLE DB and SQL. The OLE DB managed provider comes with OleDbConnection, OleDbCommand, OleDbParameter, and OleDbDataReader. The SQL Server managed provider comes with a similar set of objects, whose names start with SqlClient instead of OleDb. Developers can use the connection, command, and data reader objects to directly manipulate data. We might think that setting up and tearing down connections is not a good idea since the cost of establishing a connection is usually high. This is a concern only in the absence of connection pooling. ADO.NET automatically keeps connections to a data source in a pool, so when an application thinks it is tearing down a connection, it's actually returning it to the resource pool. This allows connections to be reused, avoiding the cost of reconstructing new connections from scratch. Because ADO.NET framework classes are managed code, developers can inherit and extend these classes to their custom needs. A data reader is a new object providing fast, forward-only, and read-only access to data. This is similar to an ADO Recordset with server-side, forward - only, and read-only cursor types. Since this is a server side cursor, the connection to the server is open throughout the reading of data. Even though each DataAdapter maps only one DataTable in the DataSet, you can have multiple adapters to fill the DataSet object with multiple DataTables. Managed Code: The .Net framework provides several core run-time services to the programs that run within it. For example exception handling and security. For these services to work the code must provide a minimum level of information to runtime. Such code is called Managed Code. Managed Data:
This is data for which memory management is done by .Net runtimes garbage collector this includes tasks for allocation de-allocation. We can call garbage collector to collect unreferenced data by executing System.GC.Collect(). What is an Assembly? Assemblies are fundamental building blocks of .Net Framework. They contain the type and resources that are useful to make an application. Assemblies enables code reuse, version control, security and deployment. An assembly consist of: Manifest , Type Metadata, MSIL and resource file. Assemblies are Private and Shared. Private are used for a single application and installed in applications install directory or its sub-directory. Shared assembly is one that can be referenced by multiple application and resides in GAC(local cache for assemblies managed by .Net Framework). gacutil /i myDll.dll can see and %windir%\assembly
Metadata and Manifest: Manifest describes the assembly itself. Assembly name, version, culture, strong name, list of files, type reference and reference assembly. While Metadata describes contents within the assembly like classes, namespaces, interfaces, scope, properties, methods and their parameters etc. Application Domain: It is a virtual process that serves to isolate an application. All object created within the same application scope are created within same application domain. Garbage Collection: It is Automatic Memory Manager for .Net Framework. It manages the memory allocated to .Net Framework. When a variable is defined it gets a space in memory (stack) and when an object is created memory for the object is allocated in heap. When an object is assigned to a variable it increments the reference counts for the object and when program control comes out of the function the scope of variable gets ended Or NULL is assigned to variable it decrements the reference count of object by 1. When reference count of one object becomes zero GC acts call destructor of object and then releases the memory acquired by the object. Can .Net Components can be used from a COM? Yes, can be used. But There are few restrictions such as COM needs an object to be created. So static methods, parameterized constructor can not be used from COM. These are used by COM using a COM Callable Wrapper (CCW). TlbImp.exe and TlbExp.exe How does .NET Remoting work? It involves sending messages along channels. Two of the standard channels are HTTP and TCP. TCP is for LANs only and HTTP can be used on LANs or WANs (internet). TCP uses binary serialization and HTTP uses SOAP (.Net Runtime Serialization SOAP Formatter). There are 3 styles of remote access: SingleCall: Each incoming request is handled by new instance. Singleton: All requests are served by single server object. Client-Activated Object: This is old state-full DCOM model. Where client receives reference to the remote object and keep until it finished with it. DLL-HELL: Situations where we have to put same name Dlls in single directory where are Dlls are of different versions.
Versioning: MajorVersion.MinorVersion.BuildNumber.Revision Boxing and Un-Boxing: Implicit(automatic) conversion of value type to reference type is known as Boxing And Explicit (manual) conversion of Reference type to value type is said to be Un-boxing. (conversion of Integer variable to object type) .Net Object Oriented Programming Concepts Class: Class is concrete representation of an entity. It represents a group of objects, which posses similar attributes and behavior. Provides Abstraction and Encapsulations. A category name that can be given to group of objects of similar kind. Object: Object represents/resembles a Physical/real entity. An object is simply something you can give a name. Object Oriented Programming: It is a Style of programming that represents a program as a system of objects and enables code-reuse. Encapsulation: Binding of attributes and behaviors. Hiding the implementation and exposing the functionality. Abstraction: Hiding the complexity. Defining communication interface for the functionality and hiding rest of the things. In .Net destructor can not be abstract. Can define Either Finalize / Destructor. For Destructor access specifiers can not be assigned. It is Private. Overloading: Adding a new method with the same name in same/derived class but with different number/types of parameters. Implements Polymorphism. Overriding: When we need to provide different implementation than the provide by base class, We define the same method with same signatures in the derived class. Method must be Protected/Protected-Friend/Public for this purpose. (Base class routine can be called by Mybase.Method, base.Method). Shadowing: When the method is defined as Final/sealed in base class and not overridable and we need to provide different implementation for the same. We define method with Shadows/new. Inheritance: Gives you ability to provide is-a relationship. Acquires attributes and behaviors from another. When a class acquires attributes and behaviors from another class. (must not be Final or sealed class in .Net) Abstract Class: Instance can not be created. Optionally can have one or more abstract methods but not necessary. Can provide body to Classes. Interface: What a Class must do, But not how-to. Bridge for the communication when the caller does not know to whom he is calling.
Describes externally visible behavior of element. Only Public members which defines the means of the communication with the outer world. Can-be-Used-As Relationship. Can not contain data but can declare property. There can be no implementation. Interface can be derived from another interface. Polymorphism: Mean by more than one form. Ability to provide different implementation based on different no./type of parameters. A method behaves differently based on the different input parameters. Does not depend on the Return-Type. Pure-Polymorphism: Make an method abstract/virtual in base class. Override it in Derived Class. Declare a variable of type base class and assign an object of derived class to it. Now call the virtual/abstract method. The actual method to be called is decided at runtime. Early-Binding: Calling an non-virtual method decides the method to call at compile time is known as EarlyBinding. Late-Binding: Same as pure-polymorphism. Identifiers/Access Specifies and scope: VB.NET: Private, Protected, Friend, Protected Friend, Public. C#: private, protected, internal, protected internal, public. What is a Delegate? A strongly typed function pointer. A delegate object encapsulates a reference to a method. When actual function needs to be called will be decided at run-time. Static Variable and Its Life-Time: VB.NET: Public Shared VAR As Type. C#: public static Type VAR; Life time is till the class is in memory. Constructor: Special Method Always called whenever an instance of the class is created. Destructor/Finalize: Called by GC just before object is being reclaimed by GC. ASP.Net Different Types of Caching? Output Caching: stores the responses from an asp.net page. Fragment Caching: Only caches/stores the portion of page (User Control) Data Caching: is Programmatic way to Cache objects for performance. Authentication and Authorization: Authentication is identifying/validating the user against the credentials (username and password) and Authorization performs after authentication. Authorization allowing access of specific resource to user. Different Types of Directives: Page, Register, Control, OutputCache, Import, Implements, Assembly, Reference Difference between Server-Side and Client-Side: Server-Side code is executed on web-server and does not transmitted to client, while clientside code executed on client(browser) and is rendered to client along with the content.
Difference Server.Transfer and Response.Redirect: Both ends the processing for the current request immediately. Server.Transfer start executing the another resource specified as parameter without acknowledgement to client(browser) while Response.Redirect intimate client that your requested resource is available at this location and then client request for that resource. Different Types of Validators and Validation Controls: RequiredFieldValidator, RangeValidator, RegularExpressionValidator, CompareValidator, CustomValidator, ValidationSummary How to Manage State in ASP.Net? Client based: ViewState, QueryString and Cookies Server based: Session, Application. Difference between User Control and Custom Control: CUSTOM Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls. Attributes can be set visually at design time. Can be used by Multiple Applications (If Shared Dlls), Even if Private can copy to bin directory of webApp add reference and use. Normally designed to provide common functionality independent of consuming Application. 3 Types of Session State Modes? InProc(cookieless, timeout), StateServer (Server, Port stateConnectionString="tcpip=server:port"), SQLServer (sqlconnectionstring) and Off. What is ViewState and How it is managed, Its Advantages/Benefits? ViewState is a special object that ASP.NET uses to maintain the state of page and all webcontrols/ServerControls within it. It is in this object preserves the states of various FORM elements during post-backs. It is rendered to client(browser) as a Hidden variable __VIEWSTATE under <form>tag. We can also add custom values to it. What is web.config and machine.config: machine.config is default configuration for all applications running under this version, located in %WinDir%\Microsfot.Net\Framework\Version. Settings can be overridden by Web.Config for an specific application Web.Config resides in applications root/virtual root and exists in subsequent folders. Role of Global.asax: Optional file contains the code to handle Application level events raised by ASP.Net or By HttpModule. This file resides in application root directory. Application_Start, _End, _AuthenticateRequest, _Error, Session_Start, _End, BeginRequest, EndRequest. This file is parsed and compiled into dynamically generated class derived from HttpApplication. Page Life Cycle: Init, LoadViewState, LoadPostBackData, Load, RaisePostBackDataChangedEvent, RaisePostBackEvents, Pre-Render, SaveViewState, Render, Unload, (IpostBackDataChangedEventHandler and IpostBackEventHandler) Error, CommitTransaction, AbortTransaction, Abort inetinfo.exe, aspnet_isapi.dll aspnet_wp.exe, HttpModules (OutputCache, Session, Authentication, Authorization, Custom Modules Specified) and Then HttpHandlers PageHandlerFactory for *.aspx Can the action attribute of a server-side <form>tag be set to a value and if not how can you possibly pass data from a form to a subsequent Page? No assigning value will not work because will be overwritten at the time of rendering. We can assign value to it by register a startup script which will set the action value of form on clientside. Rest are Server.Transfer and Response.Redirect.
ASP.Net List Controls and differentiate between them? RadioButtonList, CheckBoxList, DropDownList, Repeater, DataGrid, DataList Type Of Code in Code-Behind class: Server-Side Code. What might be best suited to place in the Application_Start and Session_Start: Application level variables and settings initialization in App_Start User specific variables and settings in Session_Start Difference between inline and code-behind. Which is best? Inline is mixed with html and code-behind is separated. Use code-behind, Because Inline pages are loaded, parsed, compiled and processed at each first request to page and remains in compiled code remains in cache until it expires, If expires it again load, parse and compile While code-behind allows to be pre-compiled and provide better performance. Which Template must provide to display data in Repeater? ItemTemplate. How to Provide Alternating Color Scheme in Repeater? AlternatingItemTemplate What base class all Web Forms inherit from? System.Web.UI.Page What method do you use to explicitly kill a users Session? HttpContext.Current.Session.Abandon() How do you turn off cookies in one page of your asp.net application? We will not use it. But can not turn off cookies from server. To allow or not is a client side functionality. Which two properties are on every validation control? ControlToValidate and Text, ErrorMessage How do you create a permanent cookie? Set expires property to Date.MaxValue (HttpCookie.Expires = Date.MaxValue) What is the standard you use to wrap up a call to a Web Service? SOAP Which method do you use to redirect to user to another page without performing a round trip to Client? Server.Transfer(AnotherPage.aspx) What is transport protocol you use to call a Web-Service SOAP? HTTP-POST A Web Service can only be written in .NET? FALSE Where on internet would you look for Web services? www.uddi.org How many classes can a single .NET DLL contain? Unlimited How many namespaces are in .NET version 1.1? 124
What is a bubbled event? When you have a complex control like DataGrid. Writing an event processing routine for each object (cell, button, row etc.). DataGrid handles the events of its constituents and will raise its own defined custom events. Difference between ASP Session State and ASP.Net Session State? ASP: relies on cookies, Serialize all requests from a client, Does not survive process shutdown, Can not maintained across machines in a Web farm/garden. Layouts of ASP.NET Pages: GridLayout and FlowLayout Web User Control: Combines existing Server and HTML controls by using VS.Net. to create functional units that encapsulate some aspects of UI. Resides in Content Files, which must be included in project in which the controls are used. Composite Custom Control: combination of existing HTML and Server Controls. Rendered custom control: create entirely new control by rendering HTML directly rather than using composition. Where do you store the information about users Locale? Page.Culture should Validation occur on Client/Server Side for Date Input? Both. Client-side reduces extra round-trip. Server-Side ensures prevention against hacking and failure against automated requests. HTTP GET and HTTP POST: As their names imply, both HTTP GET and HTTP POST use HTTP as their underlying protocol. Both of these methods encode request parameters as name/value pairs in the HTTP request. The GET method creates a query string and appends it to the script's URL on the server that handles the request. For the POST method, the name/value pairs are passed in the body of the HTTP request message. Web Services Discovery: Even though advertising of a web service is important, it is optional. Web services can be private as well as public. Depending on the business model, some business-to -business (B2B) services would not normally be advertised publicly. Instead, the web service owners would provide specific instructions on accessing and using their service only to the business partner. To advertise web services publicly, authors post discovery files on the Internet. Potential web services clients can browse to these files for information about how to use the web services the WSDL (Web Service Description Language). Think of it as the yellow pages for the web service. All it does is point you to where the actual web services reside and to the description of those web services. The process of looking up a service and checking out the service description is called Web Service discovery. There are two ways of advertising the service: static and dynamic. In both of these, XML conveys the locations of web services. Static discovery is easier to understand because it is explicit in nature. If you want to advertise your web service, you must explicitly create the .disco discovery file and point it to the WSDL. As opposed to explicitly specifying the URL for all web services your site supports, you can enable dynamic discovery, which enables all web services underneath a specific URL on your web site to be listed automatically. For your web site, you might want to group related web services under many different directories and then provide a single dynamic discovery file in
each of the directory. Web Services and Security: We incorporate security into web service in two ways: system security and application security. System -level security allows for restricting access to the web services from unauthorized clients. It is done in a declarative fashion, whereas application - level security is more flexible. With system-level security, you will most likely have the list of authorized clients' IP addresses that you will let access your web service through the use of some configuration - management tools. With application-level security, you will incorporate the authentication into your web service, thus providing a more flexible configuration. In system level security client send a user name and password to web server. This pair can be in plain text format or in some encrypted format. Once server authenticates the user it can access the services available to server. In application level security mode your web services involves taking security into your own hands. You can program your web services so that all of their methods require an access token, which can be obtained from the web service after sending in the client's username and password. The client credentials can be sent to the server through SSL (Secure Sockets Layer), which eliminates the risk of sending clear-text passwords across the wire. Through this SSL channel, the server returns an access token to the caller, who can use it to invoke all other web service methods. Web Form Events The first event that happens in the life of a Web Form is the Init event. This is raised so that we can have initialization code for the page. The controls on the page are not yet created at this point. This event is raised once for each user of the page. The Load event follows the Init event. Subsequently, it is raised each time the page is requested. When this event is raised, all child controls of the Web Form are loaded and accessible. You should be able to retrieve data and populate the controls so that they can render themselves on the page when sent back to the client. The PreRender event happens just before the page is rendered and sent back to the client. We don't often handle this event; however, it depends on the situation. The last event in the life of a Web Form is the Unload event. This happens when the page is unloaded from memory. Final cleanup should be done here. Lifecycle Of A Web Form: In ASP .NET, the web page starts its life when a client requests a particular page. IIS parses and runs the scripts on the ASP page to render HTML content. As soon as the page rendering is complete, the page's life ceases; only the view states of the page persist between requests to the page. These view states allow the controls on the server to appear as if they are still present to handle server events. Using Web Services: In Visual Studio.NET IDE, you can choose Project >> Add Web Reference and then type in the URL where the web service resides. For example, we'll point to the web service we created on local server, than is PubsWS (suppose). The URL to this web service on our server is http://localhost/PubsWS/PubsWS.asmx. After adding the web reference, you can access the proxy object to the web service you are calling via the type servername.proxyObjectName. For your case, it is localhost.PubsWS. The following code excerpt demonstrates how to use the web service through the proxy. We create an instance of the proxy object and then ask it to relay the message to the real web service to get the list of authors. The result will be streamed back in XML format, which is reconstructed into a DataSet object.
[C#] localhost.PubsWS ws = new localhost.PubsWS( ); DataSet ds = ws.GetAuthors( ); ASP.NET Session-State Management: ASP.NET improves upon ASP session-state management by moving to an out-of-process model. By having all web servers in the farm pointing to a common server that hosts the outof-process state manager, the web client can be redirected around the farm without losing the session states. By using an out-of-process model, we no longer have the problem of losing session states when the IIS process is cycled. This means that if the web server application crashed for whatever reason and restarted within the session time-out duration, the web clients could still have all their session states intact. Of course, if the out-of-process state manager crashed, that is a whole different issue. This leads to the next improvement of ASP.NETthe ability to persist session state to a database. There are two levels of configuration: machine and application. Machine-level configuration associates with the machine.config file stored in WinNT\Microsoft.NET\ Framework\\CONFIG\machine.config, while the application-level configuration uses the web.config file in the application root directory. The application-level configuration overrides the machine -level configuration. Acronyms
CCW COM Callable Wrapper CLI Common Language Infrastructure. This is a subset of the CLR and base class libraries that Microsoft has submitted to ECMA so that a third-party vendor can build a .NET runtime on another platform. CLR Common Language Runtime CLS Common Language Specification COFF Common Object File Format COM Component Object Model CTS Common Type System DISCO Discovery of Web Services. A Web Service has one or more. DISCO files that contain information on how to access its WSDL. DNA Distributed interNet Applications Architecture. DOM Document Object Model
GDI Graphical Device Interface GAC Global Assembly Cache GUID Globally Unique Identifier HTTP Hyper Text Transfer Protocol IDL Interface Definition Language IL Intermediate Language MSIL Microsoft Intermediate Language MS-DTC Microsoft Distributed Transaction Coordinator N-Tier Multi-Tier OLTP Online Transaction Processing OLAP Online Analytical Processing PE Portable Executable RAD Rapid Application Development RCW Runtime Callable Wrapper SMTP Simple Mail Transfer Protocol SOAP Simple Object Access Protocol TCP Transport Control Protocol TLB Type Library UDF Uniform Data Format UI User Interface
URL Uniform Resource Locator UDDI Universal Description, Discovery and Integration WAP Wireless Access Protocol WSDL Web Services Definition Language WML Wireless Markup Language XML Extensible Markup Language
Standard Windows PE files are divided into two major sections. The first section includes the PE/COFF headers that reference the contents within the PE file. In addition to the header section, the PE file holds a number of native image sections, including the .data, .rdata, .rsrc , and .Text sections. These are the standard sections of a typical Windows executable, but Microsoft's C/C++ compiler allows you to add your own custom sections into the PE file using a compiler pragma statement. For example, you can create your own data section to hold encrypted data that only you can read. Taking advantage of this ability, Microsoft has added a few new sections to the normal PE file specifically to support the CLR's functionality. The CLR understands and manages the new sections. For example, the CLR will read these sections and determine how to load classes and execute your code at runtime. The sections that Microsoft has added to the normal PE format are the CLR header and the CLR data sections. While the CLR header stores information to indicate that the PE file is a .NET executable, the CLR data section contains metadata and IL code, both of which determine how the program will be executed. Metadata Metadata is machine -readable information about a resource, or "data about data." Such information might include details on content, format, size, or other characteristics of a data source. In .NET, metadata includes type definitions, version information, external assembly references, and other standardized information. In order for two components, systems, or objects to interoperate with one another, at least one must know something about the other. In COM, this "something" is an interface specification, which is implemented by a component provider and used by its consumers.
In .NET, metadata is a common mechanism or dialect that the .NET runtime, compilers, and tools can all use. Microsoft .NET uses metadata to describe all types that are used and exposed by a particular .NET assembly. Metadata includes descriptions of an assembly and modules, classes, interfaces, methods, properties, fields, events, global methods, and so forth. .NET assemblies are deployable units and manifests are the metadata that describes the assemblies. IL Code: An assembly contains the IL code that the CLR executes at runtime. The IL code typically uses types defined within the same assembly, but it also may use or refer to types in other assemblies. There is one caveat: each assembly can have at most one entry point, such as DllMain( ), WinMain( ), or Main( ). You must follow this rule because when the CLR loads an assembly, it searches for one of these entry points to start assembly execution. There are four types of assemblies in .NET: Static assemblies: These are the .NET PE files that you create at compile time. You can create static assemblies using your favorite compiler: csc, cl, or vbc. Dynamic assemblies: These are PE-formatted, in-memory assemblies that you dynamically create at runtime using the classes in the System.Reflection.Emit namespace. Private assemblies: These are static assemblies used by a specific application. Public or shared assemblies: These are static assemblies that must have a unique shared name and can be used by any application. Side-by-Side Execution: The CLR allows any versions of the same-shared DLL (shared assembly) to execute at the same time, on the same system, and even in the same process. This concept is known as side-by-side execution. Manifests: Assembly Metadata An assembly manifest is metadata that describes everything about the assembly, including its identity, a list of files belonging to the assembly, references to external assemblies, exported types, exported resources, and permission requests. In short, it describes all the details that are required for component plug-and-play. Since an assembly contains all these details, there's no need for storing this type of information in the registry, as in the COM world. An assembly can be a single-module assembly or a multi-module assembly. In a singlemodule assembly, everything in a build is clumped into one EXE or DLL, an example of which is the hello.exe application that we developed earlier. This is easy to create because a compiler takes care of creating the single -module assembly for you. A multi-module assembly is one that contains many modules and resource files. To create it you have to use the Assembly Linker (al.exe) that is provided by the .NET SDK. This tool takes one or more IL or resource files and spits out a file with an assembly manifest. Any .NET language may be converted into IL, so .NET supports multiple languages and perhaps multiple platforms in the future (as long as the target platforms have a CLR). The Common Type System (CTS): Because .NET treats all languages as equal, a class written in C# should be equivalent to a class written in VB.NET, and an interface defined in Managed C++ should be exactly the same as one that is specified in managed COBOL. Languages must agree on the meanings of these concepts before they can integrate with one another. In order to make language integration a reality, Microsoft has specified a common type system to which every .NET language must abide.
Interfaces: Interfaces support exactly the same concept as a C++ abstract base class (ABC) with only pure virtual functions. An ABC is a class that declares one or more pure virtual functions and thus cannot be instantiated. If you know COM or Java, interfaces in .NET are conceptually equivalent to a COM or Java interface. You specify them, but you don't implement them. A class that derives from your interface must implement your interface. An interface may contain methods, properties, indexers, and events. In .NET, a class can derive from multiple interfaces. The Common Language Specification (CLS): Microsoft has published the Common Language Specification (CLS). The CLS specifies a series of basic rules that are required for language integration. Since Microsoft provides the CLS that spells out the minimum requirements for being a .NET language, compiler vendors can build their compilers to the specification and provide languages that target .NET. Besides compiler writers, application developers should read the CLS and use its rules to guarantee language interoperation. CLR Execution: .Net PE Files(Metadata And IL) >> Class Loader >> Verifier >> JIT >> Managed Native Code Once the class loader has found and loaded the target class, it caches the type information for the class so that it doesn't have to load the class again for the duration of this process. The verifier is responsible for verifying that: 1. The metadata is well formed, meaning the metadata must be valid. 2. The IL code is type safe, meaning type signatures are used correctly. The JIT compilers convert IL to native code so that it can execute on the target operating system. For optimization reasons, JIT compilation occurs only the first time a method is invoked. Recall that the class loader adds a stub to each method during class loading. At the first method invocation, the VEE reads the information in this stub, which tells it that the code for the method has not been JIT compiled. At this indication, the JIT compiler compiles the method and injects the address of the managed native method into this stub. During subsequent invocations to the same method, no JIT compilation is needed because each time the VEE goes to read information in the stub, it sees the address of the native method. Because the JIT compiler only performs its magic the first time a method is invoked, the methods you don't need at runtime will never be JIT compiled. The compiled, native code lies in memory until the process shuts down and until the garbage collector clears off all references and memory associated with the process. This means that the next time you execute the process or component, the JIT compiler will again perform its magic. If you want to avoid the cost of JIT compilation at runtime, you can use a special tool called ngen, which compiles your IL during installation and setup time. Using ngen, you can JITcompile the code once and cache it on the machine so that you can avoid JIT compilation at runtime (this process is referred to as Pre-JITting). In the event that the PE file has been updated, you must PreJIT the PE file again. Otherwise, the CLR can detect the update and dynamically command the appropriate JIT compiler to compile the assembly. All .NET assemblies are essentially binary components. You can treat each .NET assembly as a component that you can plug into another component or application, without the need for source code, since all the metadata for the component is stored inside the .NET assembly. While you have to perform a ton of plumbing to build a component in COM, you need to perform zero extra work to get a component in .NET, as all .NET assemblies are components by nature. Remember, we're using the term "component" as a binary, deployable unit, not as a COM class. Shared Components: Unlike application-private assemblies, shared assemblies - ones that can be used by any client
application - must be published or registered in the system Global Assembly Cache (GAC). When you register your assemblies against the GAC, they act as system components, such as a system DLL that every process in the system can use. A prerequisite for GAC registration is that the component must possess originator and version information. In addition to other metadata, these two items allow multiple versions of the same component to be registered and executed on the same machine. Again, unlike COM, we don't have to store any information in the system registry for clients to use these shared assemblies. Object Pooling: A pool is technical term that refers to a group of resources, such as connections, threads, and objects. Putting a few objects into a pool allows hundreds of clients to share these few objects (you can make the same assertion for threads, connections, and other objects). Pooling is therefore a technique that minimizes the use of system resources, improves performance, and helps system scalability. ADO.NET Architecture: Microsoft ADO.NET's object model encompasses two distinct groups of classes: content components and managed-provider components. The content components include the DataSet class and other supporting classes such as DataTable, DataRow, DataColumn, and DataRelation. These classes contain the actual content of a data exchange. The managedprovider components assist in data retrievals and updates. Microsoft provides two managed providers in its current release of ADO.NET: OLE DB and SQL. The OLE DB managed provider comes with OleDbConnection, OleDbCommand, OleDbParameter, and OleDbDataReader. The SQL Server managed provider comes with a similar set of objects, whose names start with SqlClient instead of OleDb. Developers can use the connection, command, and data reader objects to directly manipulate data. We might think that setting up and tearing down connections is not a good idea since the cost of establishing a connection is usually high. This is a concern only in the absence of connection pooling. ADO.NET automatically keeps connections to a data source in a pool, so when an application thinks it is tearing down a connection, it's actually returning it to the resource pool. This allows connections to be reused, avoiding the cost of reconstructing new connections from scratch. Because ADO.NET framework classes are managed code, developers can inherit and extend these classes to their custom needs. A data reader is a new object providing fast, forward-only, and read-only access to data. This is similar to an ADO Recordset with server-side, forward - only, and read-only cursor types. Since this is a server side cursor, the connection to the server is open throughout the reading of data. Even though each DataAdapter maps only one DataTable in the DataSet, you can have multiple adapters to fill the DataSet object with multiple DataTables. Managed Code: The .Net framework provides several core run-time services to the programs that run within it. For example exception handling and security. For these services to work the code must provide a minimum level of information to runtime. Such code is called Managed Code. Managed Data: This is data for which memory management is done by .Net runtimes garbage collector this includes tasks for allocation de-allocation. We can call garbage collector to collect unreferenced data by executing System.GC.Collect(). What is an Assembly? Assemblies are fundamental building blocks of .Net Framework. They contain the type and resources that are useful to make an application. Assemblies enables code reuse, version control, security and deployment. An assembly consist of: Manifest , Type Metadata, MSIL and resource file.
Assemblies are Private and Shared. Private are used for a single application and installed in applications install directory or its sub-directory. Shared assembly is one that can be referenced by multiple application and resides in GAC(local cache for assemblies managed by .Net Framework). gacutil /i myDll.dll can see and %windir%\assembly
Metadata and Manifest: Manifest describes the assembly itself. Assembly name, version, culture, strong name, list of files, type reference and reference assembly. While Metadata describes contents within the assembly like classes, namespaces, interfaces, scope, properties, methods and their parameters etc. Application Domain: It is a virtual process that serves to isolate an application. All object created within the same application scope are created within same application domain. Garbage Collection: It is Automatic Memory Manager for .Net Framework. It manages the memory allocated to .Net Framework. When a variable is defined it gets a space in memory (stack) and when an object is created memory for the object is allocated in heap. When an object is assigned to a variable it increments the reference counts for the object and when program control comes out of the function the scope of variable gets ended Or NULL is assigned to variable it decrements the reference count of object by 1. When reference count of one object becomes zero GC acts call destructor of object and then releases the memory acquired by the object. Can .Net Components can be used from a COM? Yes, can be used. But There are few restrictions such as COM needs an object to be created. So static methods, parameterized constructor can not be used from COM. These are used by COM using a COM Callable Wrapper (CCW). TlbImp.exe and TlbExp.exe How does .NET Remoting work? It involves sending messages along channels. Two of the standard channels are HTTP and TCP. TCP is for LANs only and HTTP can be used on LANs or WANs (internet). TCP uses binary serialization and HTTP uses SOAP (.Net Runtime Serialization SOAP Formatter). There are 3 styles of remote access: SingleCall: Each incoming request is handled by new instance. Singleton: All requests are served by single server object. Client-Activated Object: This is old state-full DCOM model. Where client receives reference to the remote object and keep until it finished with it. DLL-HELL: Situations where we have to put same name Dlls in single directory where are Dlls are of different versions. Versioning: MajorVersion.MinorVersion.BuildNumber.Revision Boxing and Un-Boxing: Implicit(automatic) conversion of value type to reference type is known as Boxing And Explicit (manual) conversion of Reference type to value type is said to be Un-boxing. (conversion of Integer variable to object type) .Net Object Oriented Programming Concepts Class:
Class is concrete representation of an entity. It represents a group of objects, which posses similar attributes and behavior. Provides Abstraction and Encapsulations. A category name that can be given to group of objects of similar kind. Object: Object represents/resembles a Physical/real entity. An object is simply something you can give a name. Object Oriented Programming: It is a Style of programming that represents a program as a system of objects and enables code-reuse. Encapsulation: Binding of attributes and behaviors. Hiding the implementation and exposing the functionality. Abstraction: Hiding the complexity. Defining communication interface for the functionality and hiding rest of the things. In .Net destructor can not be abstract. Can define Either Finalize / Destructor. For Destructor access specifiers can not be assigned. It is Private. Overloading: Adding a new method with the same name in same/derived class but with different number/types of parameters. Implements Polymorphism. Overriding: When we need to provide different implementation than the provide by base class, We define the same method with same signatures in the derived class. Method must be Protected/Protected-Friend/Public for this purpose. (Base class routine can be called by Mybase.Method, base.Method). Shadowing: When the method is defined as Final/sealed in base class and not overridable and we need to provide different implementation for the same. We define method with Shadows/new. Inheritance: Gives you ability to provide is-a relationship. Acquires attributes and behaviors from another. When a class acquires attributes and behaviors from another class. (must not be Final or sealed class in .Net) Abstract Class: Instance can not be created. Optionally can have one or more abstract methods but not necessary. Can provide body to Classes. Interface: What a Class must do, But not how-to. Bridge for the communication when the caller does not know to whom he is calling. Describes externally visible behavior of element. Only Public members which defines the means of the communication with the outer world. Can-be-Used-As Relationship. Can not contain data but can declare property. There can be no implementation. Interface can be derived from another interface. Polymorphism: Mean by more than one form. Ability to provide different implementation based on different no./type of parameters. A method behaves differently based on the different input parameters. Does not depend on the Return-Type.
Pure-Polymorphism: Make an method abstract/virtual in base class. Override it in Derived Class. Declare a variable of type base class and assign an object of derived class to it. Now call the virtual/abstract method. The actual method to be called is decided at runtime. Early-Binding: Calling an non-virtual method decides the method to call at compile time is known as EarlyBinding. Late-Binding: Same as pure-polymorphism. Identifiers/Access Specifies and scope: VB.NET: Private, Protected, Friend, Protected Friend, Public. C#: private, protected, internal, protected internal, public. What is a Delegate? A strongly typed function pointer. A delegate object encapsulates a reference to a method. When actual function needs to be called will be decided at run-time. Static Variable and Its Life-Time: VB.NET: Public Shared VAR As Type. C#: public static Type VAR; Life time is till the class is in memory. Constructor: Special Method Always called whenever an instance of the class is created. Destructor/Finalize: Called by GC just before object is being reclaimed by GC. ASP.Net Different Types of Caching? Output Caching: stores the responses from an asp.net page. Fragment Caching: Only caches/stores the portion of page (User Control) Data Caching: is Programmatic way to Cache objects for performance. Authentication and Authorization: Authentication is identifying/validating the user against the credentials (username and password) and Authorization performs after authentication. Authorization allowing access of specific resource to user. Different Types of Directives: Page, Register, Control, OutputCache, Import, Implements, Assembly, Reference Difference between Server-Side and Client-Side: Server-Side code is executed on web-server and does not transmitted to client, while clientside code executed on client(browser) and is rendered to client along with the content. Difference Server.Transfer and Response.Redirect: Both ends the processing for the current request immediately. Server.Transfer start executing the another resource specified as parameter without acknowledgement to client(browser) while Response.Redirect intimate client that your requested resource is available at this location and then client request for that resource. Different Types of Validators and Validation Controls: RequiredFieldValidator, RangeValidator, RegularExpressionValidator, CompareValidator, CustomValidator, ValidationSummary
How to Manage State in ASP.Net? Client based: ViewState, QueryString and Cookies Server based: Session, Application. Difference between User Control and Custom Control: CUSTOM Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls. Attributes can be set visually at design time. Can be used by Multiple Applications (If Shared Dlls), Even if Private can copy to bin directory of webApp add reference and use. Normally designed to provide common functionality independent of consuming Application. 3 Types of Session State Modes? InProc(cookieless, timeout), StateServer (Server, Port stateConnectionString="tcpip=server:port"), SQLServer (sqlconnectionstring) and Off. What is ViewState and How it is managed, Its Advantages/Benefits? ViewState is a special object that ASP.NET uses to maintain the state of page and all webcontrols/ServerControls within it. It is in this object preserves the states of various FORM elements during post-backs. It is rendered to client(browser) as a Hidden variable __VIEWSTATE under <form>tag. We can also add custom values to it. What is web.config and machine.config: machine.config is default configuration for all applications running under this version, located in %WinDir%\Microsfot.Net\Framework\Version. Settings can be overridden by Web.Config for an specific application Web.Config resides in applications root/virtual root and exists in subsequent folders. Role of Global.asax: Optional file contains the code to handle Application level events raised by ASP.Net or By HttpModule. This file resides in application root directory. Application_Start, _End, _AuthenticateRequest, _Error, Session_Start, _End, BeginRequest, EndRequest. This file is parsed and compiled into dynamically generated class derived from HttpApplication. Page Life Cycle: Init, LoadViewState, LoadPostBackData, Load, RaisePostBackDataChangedEvent, RaisePostBackEvents, Pre-Render, SaveViewState, Render, Unload, (IpostBackDataChangedEventHandler and IpostBackEventHandler) Error, CommitTransaction, AbortTransaction, Abort inetinfo.exe, aspnet_isapi.dll aspnet_wp.exe, HttpModules (OutputCache, Session, Authentication, Authorization, Custom Modules Specified) and Then HttpHandlers PageHandlerFactory for *.aspx Can the action attribute of a server-side <form>tag be set to a value and if not how can you possibly pass data from a form to a subsequent Page? No assigning value will not work because will be overwritten at the time of rendering. We can assign value to it by register a startup script which will set the action value of form on clientside. Rest are Server.Transfer and Response.Redirect. ASP.Net List Controls and differentiate between them? RadioButtonList, CheckBoxList, DropDownList, Repeater, DataGrid, DataList Type Of Code in Code-Behind class: Server-Side Code. What might be best suited to place in the Application_Start and Session_Start: Application level variables and settings initialization in App_Start User specific variables and settings in Session_Start
Difference between inline and code-behind. Which is best? Inline is mixed with html and code-behind is separated. Use code-behind, Because Inline pages are loaded, parsed, compiled and processed at each first request to page and remains in compiled code remains in cache until it expires, If expires it again load, parse and compile While code-behind allows to be pre-compiled and provide better performance. Which Template must provide to display data in Repeater? ItemTemplate. How to Provide Alternating Color Scheme in Repeater? AlternatingItemTemplate What base class all Web Forms inherit from? System.Web.UI.Page What method do you use to explicitly kill a users Session? HttpContext.Current.Session.Abandon() How do you turn off cookies in one page of your asp.net application? We will not use it. But can not turn off cookies from server. To allow or not is a client side functionality. Which two properties are on every validation control? ControlToValidate and Text, ErrorMessage How do you create a permanent cookie? Set expires property to Date.MaxValue (HttpCookie.Expires = Date.MaxValue) What is the standard you use to wrap up a call to a Web Service? SOAP Which method do you use to redirect to user to another page without performing a round trip to Client? Server.Transfer(AnotherPage.aspx) What is transport protocol you use to call a Web-Service SOAP? HTTP-POST A Web Service can only be written in .NET? FALSE Where on internet would you look for Web services? www.uddi.org How many classes can a single .NET DLL contain? Unlimited How many namespaces are in .NET version 1.1? 124 What is a bubbled event? When you have a complex control like DataGrid. Writing an event processing routine for each object (cell, button, row etc.). DataGrid handles the events of its constituents and will raise its own defined custom events. Difference between ASP Session State and ASP.Net Session State? ASP: relies on cookies, Serialize all requests from a client, Does not survive process shutdown, Can not maintained across machines in a Web farm/garden.
Layouts of ASP.NET Pages: GridLayout and FlowLayout Web User Control: Combines existing Server and HTML controls by using VS.Net. to create functional units that encapsulate some aspects of UI. Resides in Content Files, which must be included in project in which the controls are used. Composite Custom Control: combination of existing HTML and Server Controls. Rendered custom control: create entirely new control by rendering HTML directly rather than using composition. Where do you store the information about users Locale? Page.Culture should Validation occur on Client/Server Side for Date Input? Both. Client-side reduces extra round-trip. Server-Side ensures prevention against hacking and failure against automated requests. HTTP GET and HTTP POST: As their names imply, both HTTP GET and HTTP POST use HTTP as their underlying protocol. Both of these methods encode request parameters as name/value pairs in the HTTP request. The GET method creates a query string and appends it to the script's URL on the server that handles the request. For the POST method, the name/value pairs are passed in the body of the HTTP request message. Web Services Discovery: Even though advertising of a web service is important, it is optional. Web services can be private as well as public. Depending on the business model, some business-to -business (B2B) services would not normally be advertised publicly. Instead, the web service owners would provide specific instructions on accessing and using their service only to the business partner. To advertise web services publicly, authors post discovery files on the Internet. Potential web services clients can browse to these files for information about how to use the web services the WSDL (Web Service Description Language). Think of it as the yellow pages for the web service. All it does is point you to where the actual web services reside and to the description of those web services. The process of looking up a service and checking out the service description is called Web Service discovery. There are two ways of advertising the service: static and dynamic. In both of these, XML conveys the locations of web services. Static discovery is easier to understand because it is explicit in nature. If you want to advertise your web service, you must explicitly create the .disco discovery file and point it to the WSDL. As opposed to explicitly specifying the URL for all web services your site supports, you can enable dynamic discovery, which enables all web services underneath a specific URL on your web site to be listed automatically. For your web site, you might want to group related web services under many different directories and then provide a single dynamic discovery file in each of the directory. Web Services and Security: We incorporate security into web service in two ways: system security and application security. System -level security allows for restricting access to the web services from unauthorized clients. It is done in a declarative fashion, whereas application - level security is more flexible. With system-level security, you will most likely have the list of authorized clients' IP addresses that you will let access your web service through the use of some configuration - management tools. With application-level security, you will incorporate the authentication into your web service, thus providing a more flexible configuration.
In system level security client send a user name and password to web server. This pair can be in plain text format or in some encrypted format. Once server authenticates the user it can access the services available to server. In application level security mode your web services involves taking security into your own hands. You can program your web services so that all of their methods require an access token, which can be obtained from the web service after sending in the client's username and password. The client credentials can be sent to the server through SSL (Secure Sockets Layer), which eliminates the risk of sending clear-text passwords across the wire. Through this SSL channel, the server returns an access token to the caller, who can use it to invoke all other web service methods. Web Form Events The first event that happens in the life of a Web Form is the Init event. This is raised so that we can have initialization code for the page. The controls on the page are not yet created at this point. This event is raised once for each user of the page. The Load event follows the Init event. Subsequently, it is raised each time the page is requested. When this event is raised, all child controls of the Web Form are loaded and accessible. You should be able to retrieve data and populate the controls so that they can render themselves on the page when sent back to the client. The PreRender event happens just before the page is rendered and sent back to the client. We don't often handle this event; however, it depends on the situation. The last event in the life of a Web Form is the Unload event. This happens when the page is unloaded from memory. Final cleanup should be done here. Lifecycle Of A Web Form: In ASP .NET, the web page starts its life when a client requests a particular page. IIS parses and runs the scripts on the ASP page to render HTML content. As soon as the page rendering is complete, the page's life ceases; only the view states of the page persist between requests to the page. These view states allow the controls on the server to appear as if they are still present to handle server events. Using Web Services: In Visual Studio.NET IDE, you can choose Project >> Add Web Reference and then type in the URL where the web service resides. For example, we'll point to the web service we created on local server, than is PubsWS (suppose). The URL to this web service on our server is http://localhost/PubsWS/PubsWS.asmx. After adding the web reference, you can access the proxy object to the web service you are calling via the type servername.proxyObjectName. For your case, it is localhost.PubsWS. The following code excerpt demonstrates how to use the web service through the proxy. We create an instance of the proxy object and then ask it to relay the message to the real web service to get the list of authors. The result will be streamed back in XML format, which is reconstructed into a DataSet object. [C#] localhost.PubsWS ws = new localhost.PubsWS( ); DataSet ds = ws.GetAuthors( ); ASP.NET Session-State Management: ASP.NET improves upon ASP session-state management by moving to an out-of-process model. By having all web servers in the farm pointing to a common server that hosts the outof-process state manager, the web client can be redirected around the farm without losing the session states. By using an out-of-process model, we no longer have the problem of losing session states when the IIS process is cycled. This means that if the web server application crashed for whatever reason and restarted within the session time-out duration, the web
clients could still have all their session states intact. Of course, if the out-of-process state manager crashed, that is a whole different issue. This leads to the next improvement of ASP.NETthe ability to persist session state to a database. There are two levels of configuration: machine and application. Machine-level configuration associates with the machine.config file stored in WinNT\Microsoft.NET\ Framework\\CONFIG\machine.config, while the application-level configuration uses the web.config file in the application root directory. The application-level configuration overrides the machine -level configuration. Acronyms CCW COM Callable Wrapper CLI Common Language Infrastructure. This is a subset of the CLR and base class libraries that Microsoft has submitted to ECMA so that a third-party vendor can build a .NET runtime on another platform. CLR Common Language Runtime CLS Common Language Specification COFF Common Object File Format COM Component Object Model CTS Common Type System DISCO Discovery of Web Services. A Web Service has one or more. DISCO files that contain information on how to access its WSDL. DNA Distributed interNet Applications Architecture. DOM Document Object Model GDI Graphical Device Interface GAC Global Assembly Cache GUID Globally Unique Identifier HTTP Hyper Text Transfer Protocol IDL Interface Definition Language IL Intermediate Language MSIL Microsoft Intermediate Language MS-DTC Microsoft Distributed Transaction Coordinator N-Tier Multi-Tier OLTP Online Transaction Processing OLAP Online Analytical Processing PE Portable Executable
RAD Rapid Application Development RCW Runtime Callable Wrapper SMTP Simple Mail Transfer Protocol SOAP Simple Object Access Protocol TCP Transport Control Protocol TLB Type Library UDF Uniform Data Format UI User Interface URL Uniform Resource Locator UDDI -Universal Description, Discovery and Integration WAP- Wireless Access Protocol WSDL- Web Services Definition Language WML Wireless Markup Language XML Extensible Markup Language
thanks in advance
This is realy a good site for interview.I have a small request that is please add the answer below the question.
All the question and their answer are very good and are very useful for us.Plz send this type of more question to me on the id [email protected]
mail me at [email protected]
Mark u did a gr8 job man!!! this blog is jus awesome... i dont know, why dont ppl understand tht they jus need to ve an idea abt wht will be asked.... other than crammin the complete MSDN... i jus saw...ppl askin for more... when thrs already a set of arnd thousand ques in this page itself... hahahaa. Adios Amigos
Thanks for the question and answer..i was quite lucky in my interview that the person who was taking my interview ask me the same question i got thru to the interview. but i would like clear some more doubts what does EnableViewStateMac does? what is bubble event? what is delegates?(in detail i know its like pointer in C++) so far i can remember this much....? thanking you, vinay
# problem faced with Tool Box in asp.net 8/12/2006 9:34 AM Bharat Agrawal
hi . I m using visual studio web devloper 2005 express edition ..it was runnung very fine but now I dont know what changes I hve made in toolbox setting from which I m not able to use all toolbox controls ...only Html controls are highlighted to be used ..I can see all the controls but they r not highlighted ...initially all of them were working very fine ...plzzz help me out .
hello sir/mam i m one year experience asp.net developer and want to face interview for experience base. can u send me interview question. from gaurav goel mail id [email protected]
I have two year experience on .NET as Asst. Programmer and i have good knowledge on .NET plateform.but now i am going to join interviews on .NET at the level of two year experience.I want to check what type of question can be asked in interviews.so please send me immediatly interview question on .NET at two year experience level.I shell highly obliged to you.
I have two year experience on .NET as Asst. Programmer and i have good knowledge on .NET plateform.but now i am going to join interviews on .NET at the level of two year experience.I want to check what type of question can be asked in interviews.so please send me immediatly interview question on .NET at two year experience level (ASP.NET, C#).I shell highly obliged to you. M.MANIKANDAN
after studying some dotnet books i searched for the interview Questions, and i found this page helpful with vast critereia. if you can send Questions via email pls send. Thanks for support. [email protected]
Hi ... the quesions were too good and very usefull for interview.i am in searching mode... with 3+ yrs, so please send me more interview questions in asp.net,C#.net, sql server 2000. mail me at : [email protected] , [email protected]
I have to for interview of .Net Please somebody tell me 1). what are the event which are there in datagrid for ASP.NET with csharp 2). What are object that can be placed in in datagrid 3). What is code for placing the text box in the datagird please give me some URL or the code of the last answer you can email me on [email protected] HELP WILL BE APPERIACATED
these questions are good. Please send the interview questions for 2 yesra exp candidates And if any body can send two ASP.net small projects with explanation .I will be great ful to you . And good resume format because i did not get the correct resume format Thanks alot fofr all who ever is sending.
Post Feedback
Title: Name: Url:
Comments:
Submit
Remember Me?