tag:blogger.com,1999:blog-51990877242478299802024-03-10T15:09:35.099-07:00asp.net interview questionsasp.net interview questions and answersUnknownnoreply@blogger.comBlogger69125tag:blogger.com,1999:blog-5199087724247829980.post-92069952846757424262012-08-15T13:24:00.001-07:002013-03-02T13:16:19.048-08:00Software development environments<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial, Helvetica, sans-serif;"><b>What are the different environments in your development process or development life cycle at your company?</b><br />This is a general interview question and not very specific to ASP.NET. Usually, the interviewer asks this question to <b>measure your understanding of the different environments and their role in software development</b>. Some interviewers, may also ask this question, to check if you really have the work experience you are claiming or <b><span style="color: #990000;">just faking</span></b> it.</span>
<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br /><br/>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>1.</b> Development</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b>2.</b> QA</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b>3.</b> Staging</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b>4.</b> UAT (User Acceptance Testing)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b>5.</b> Production</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>1. Development Environment</b> - All the developers check in their current work into development environment.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>2. QA (Quality Assurance) Environment</b> - This is the environment, where testers (QA) test the application. QA cannot test on development environment, because developers are continuously checking in new code. So, if there is a bug, we don't know, if it's caused by the old or new code. In short, if development is going on in the same environment it would be difficult to keep up with the current state. There will be lot of confusion, if the developer is trying to fix in the same area as the tester is testing. Without development and QA environment being seperate their is no way to do proper testing.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>3. Staging Environment </b>- Many organisations, try to keep their staging environment as identical as possible to the actual production environment. The primary reason for this environment is to identify any deployment related issues. Also, if you are developing a B2B (Business to Business) application, you may be interfacing with other service provider systems. Many organisations, usually setup their staging environment to interface with the service providers as well, for complete end to end testing.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>4. Production Environment</b> - The actual live environment, that we use for day to day business. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Note:</b> In general, the code flows from <b>Development</b> => <b>QA</b> => <b>Staging</b> => <b>Production</b></span>
</div>Unknownnoreply@blogger.com10tag:blogger.com,1999:blog-5199087724247829980.post-49369060738694139582011-12-12T11:53:00.000-08:002013-03-02T13:19:16.707-08:00When I create a new ASP.NET 4 web application, the web.config file is almost empty. What happened to all the configuration elements that were there prior to ASP.NET 4?<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">All the major configuration settings are moved into machine.config file, and all the applications will inherit the setting from this file. If an application needs to override the default settings, we can do so using the application specific configuration (web.config) file. ASP.NET 4 applications have clean web.config files.</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><b>If you create a new asp.net 4 empty web application, the only entry that you will find is shown below</b>.</span><br />
<table><tbody>
<tr><td><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXLWBpRaT_FNPvIsmLsPiJ_luwbd-npbNbi2JhrHeIBbZEz3po8hYzibjRLnfMaJEEkaJo73dPxkLBbbt7QnkLYln-X3sfz3aKUtzZg4qvU61Z3aGTSUxKu0NjuhNEhJXTsPCGQAcAzONx/s1600/CleanWebConfig.png" /></td></tr>
</tbody></table><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><b>Note:</b> If you create a <b><span class="Apple-style-span" style="color: #0b5394;">new ASP.NET Web Application</span></b>, instead of a <b>new ASP.NET <span class="Apple-style-span" style="color: red;">Empty </span>Web Application</b>, you will find a lot more confiuration entries in the web.config file. This is because, the template for ASP.NET web application overrides some of the default settings inherited from machine.config.</span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>Unknownnoreply@blogger.com6tag:blogger.com,1999:blog-5199087724247829980.post-42345833776858720792011-12-09T10:21:00.000-08:002013-03-02T13:20:39.852-08:00Difference between EnableViewState and ViewStateMode properties<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">1. Using <b>EnableViewState</b> property we only have 2 options</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> We can turn off view state altogether,</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> </span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> </span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> </span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> </span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> </span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> </span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">or</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> </span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Enable viewstate for the entire page and then turn it off on a control-by-control basis.</span><br />
<br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">2. If you want to turn of <b>ViewState</b> for the entire page and only enable it for specific controls on the page, then we have to use <b>ViewStateMode</b> property in conjunction with <b>EnableViewState</b>.</span><br />
<br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">3. <b>EnableViewState</b> property only accepts true or false values and the default value is true, where as <b>ViewStateMode</b> property can have a value of - Enabled, Disabled and inherit. Inherit is the default value for <b>ViewStateMode</b> property.</span><br />
<br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">4. <b>ViewStateMode</b> property is introduced in ASP.NET 4, where as <b>EnableViewState</b> exists from a long time.</span><br />
<br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">5. If <b>EnableViewState</b> is to True, only then the <b>ViewStateMode</b> settings are applied, where as, if <b>EnableViewState</b> is set to False then the control will not save its view state, regardless of the <b>ViewStateMode</b> setting. In short if <b>EnableViewState</b> is set to False, <b>ViewStateMode</b> setting is not respected.</span><br />
<br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">6. To disable view state for a page and to enable it for a specific control on the page, set the <b>EnableViewState</b> property of the page and the control to true, set the <b>ViewStateMode</b> property of the page to Disabled, and set the <b>ViewStateMode</b> property of the control to Enabled.</span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>Unknownnoreply@blogger.com8tag:blogger.com,1999:blog-5199087724247829980.post-36047800155593939192011-11-28T13:52:00.000-08:002013-03-02T13:21:41.767-08:00Dot Net Videos<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />
<h2>What are generics?</h2><iframe allowfullscreen="" frameborder="1" height="315" src="http://www.youtube.com/embed/ecbv4bsxkvk" width="560"></iframe><br />
<br />
<h2>What is a SQL Injection Attack?</h2><iframe allowfullscreen="" frameborder="1" height="315" src="http://www.youtube.com/embed/uSw0IoSr3Hk?rel=0" width="560"></iframe>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5199087724247829980.post-81969965597917765522011-09-03T08:26:00.000-07:002013-03-02T13:23:55.605-08:00ASP.NET Page is very slow. What will you do to make it fast<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">This is a very common asp.net interview question asked in many interviews. There are several reasons for the page being slow. We need to identify the cause. </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Find out which is slow, is it the <strong>application </strong>or the <strong>database</strong> : If the page is executing SQL queries or stored procedures, run those on the database and check how long do they take to run. If the queries are taking most of the time, then you know you have to tune the queries for better performance. To tune the queries, there are several ways and I have listed some of them below.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> a) Check if there are indexes to help the query</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> b) Select only the required columns, avoid <strong><span style="color: blue;">Select *.</span></strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> c) Check if there is a possiblity to reduce the number of joins</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> d) If possible use <strong><span style="color: blue;">NO LOCK </span></strong>on your select statements</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> e) Check if there are cursors and if you can replace them with joins</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> If the queries are running fast, then we know it is the <strong>application code </strong>that is causing the slowness. Isolate the page event that is causing the issue by turning tracing on. To turn tracing on, set <strong><span style="color: blue;">Trace="true"</span></strong> in the page directive. Once you have tracing turned on you should see trace information at the bottom of the page as shown in the image below. In this case Page Load event is taking the maximum time. So we know, the code in <strong><span style="color: blue;">Page_Load </span></strong>event is causing the issue. Once you look at the code, you should be able to nail down the issue.</span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<table><tbody>
<tr><td><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXwSM5i_z8ozhRjMM29ounvScZ70xrzTUOY0msforWD4T5FRcJJlDdESg4uXVmvpCSnADR_lOIxsF3c6Cow2Qw_2ku4YofbiBJfhiWhCKQbmCYgxmnd5oxMfl3dQmUqK8qWonP2Rcupwzi/s1600/PageSlow.png" xaa="true" /></td></tr>
</tbody></table></tbody></tr><br />
<br />
</td>Unknownnoreply@blogger.com48tag:blogger.com,1999:blog-5199087724247829980.post-74945535804196940912011-07-21T13:03:00.000-07:002013-03-02T13:33:49.049-08:00What is SQL Injection Attack<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial, Helvetica, sans-serif;">Let us understand <strong>SQL injection attack</strong>, with an example. I have an <span style="color: #660000;"><strong>Employee Search Page</strong> </span>as shown in the image below. This webform has a very simple functionality. You enter the ID of the employee, you want to search and click the <strong><span style="color: #660000;">Search Employee button</span></strong>. If a match is found in the database, we show the employee record in the <span style="color: #660000;">GridView</span>.</span><br />
<table><tbody>
<tr><td><br />
<b><span style="color: #660000;">Employee Search Page</span></b><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVDhCNKHc9racuTyqKqJ2Dnudk5EJRSPVKi7G7kk2ASMfh25yBCOjJnB-FOVo0YBrPHWNsbmm2KGiz25LuTz8hVEDREdjOQUDUR9bVWtBxVcfD-kOpLJivSxqrlasDJkTwEkhtudw8zz8C/s1600/EmployeeSearch.png" t$="true" /></td></tr>
</tbody></table>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><b>Here is a youtube video that I have recorded on SQL Injection. Hope, you will find it useful.<br /></b></span><br />
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/uSw0IoSr3Hk" width="560"></iframe>
<br /><span style="font-family: Arial, Helvetica, sans-serif;"><br />The HTML for the <strong><span style="color: #660000;">Employee Serach Page </span></strong>is shown below. As you can see from the HTML, the <strong><span style="color: #660000;">Employee Serach Page</span></strong> contains TextBox, Button and a GridView control.</span><br />
<table><tbody>
<tr><td><br />
<b><span style="color: #660000;">Employee Search Page HTML</span></b><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgewf-BM4my_nDraixdmVApOmall8C7PUH3x_jFY8De-NSTPzqCm5vGhfCqFohhmy1mN5J2Qzucn73ygLFZfYHIjUfeizknJBSmJjBej_Cy2GQYOF_DzmhsP72mNUve9fQViyZVw9uhTPPj/s1600/EmployeeSearchPageHTML.png" t$="true" /></td></tr>
</tbody></table>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
The <strong><span style="color: #660000;">codebehind</span></strong> page for the EmployeeSearchPage is shown below. </span><br />
<table><tbody>
<tr><td><b><span style="color: #660000;">Employee Search Page Code Behind</span></b><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu3iefRUk61TJgoae2w0yVJKRFRUjp-EyFXFdYkIz5YITpt5UsebjUSC5pbfgEECiJDxrTfmuCCGy4I3iSyL8P-udUn_zOkFgdI4QdnFugdRJK-cLOCOgU2RMnXSZPv6wAdTtRd0WxwG9Z/s1600/EmployeeSearchPageCodeBehind.png" t$="true" /></td></tr>
</tbody></table>
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
The <strong><span style="color: #660000;">Button1_Click</span></strong> event handler has the required ADO.NET code to get data from the database. This code is highly <strong><span style="color: #660000;">susceptible to sql injection attack </span></strong>and I will never ever have code like this in production environment. The <strong><span style="color: #660000;">second line in Button1_Click event handler</span></strong>, dynamically builds the sql query by concatenating the <strong><span style="color: #660000;">Employee ID</span></strong> that we typed into the <strong><span style="color: #660000;">TextBox</span></strong>. </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">So, for example, if we had typed 2 into the <strong><span style="color: #660000;">Employee ID textbox</span></strong>, we will have a SQL query as shown below.</span><br />
<span style="color: #0b5394; font-family: Arial, Helvetica, sans-serif;"><strong>Select * from Employees where Id=2</strong></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">If a malicious user, types something like <strong><span style="color: #660000;">2; Delete from Employees</span></strong> into the TextBox, then we will have a SQL query as shown below.</span><br />
<span style="color: #0b5394; font-family: Arial, Helvetica, sans-serif;"><strong>Select * from Employees where Id=2; Delete from Employees</strong></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">When this query is executed, we loose all the data in the <strong><span style="color: #660000;">Employees</span></strong> table. This is <strong><span style="color: #660000;">SQL Injection Attack</span></strong>, as the user of the application is able to inject SQL and get it executed against the database. It is very easy to avoid SQL Injection attacks by using either <strong><span style="color: #660000;">parameterized queries</span></strong> or using <strong><span style="color: #660000;">stored procedures</span></strong>.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">You may be thinking, how will the user of the application know the name of the table. Well, one way is to <strong><span style="color: #660000;">simply guess </span></strong>or <strong><span style="color: #660000;">inject a sql syntax error</span></strong>. The injected SQL syntax error causes the page to crash and can possibly reveal the name of the table as shown below. However, proper exception handling and custom error pages can be used to prevent the end user from seeing the yello screen of death. The screen shot below shows the table name <strong><span style="color: #660000;">Employees</span></strong>.</span><br />
<table><tbody>
<tr><td><br />
<b><span style="color: #660000;">Page crash revealing Employees table name</span></b><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9tSTWokAAQ0iKILqK-ZNy_9QVcs6PRYTFHBZ0bbQJMk-NZRp70X-pMz6kTFZLPwnRXsxc3r8A8j1s7-sbZinjtBIkKZyRBmeqt4v5Szo_z5JyMvmX1PIBGR6qaV_xeQTT8ob4Lxq2yQgj/s1600/PageCrash.png" t$="true" /></td></tr>
</tbody></table>
<span style="font-family: Arial, Helvetica, sans-serif;"><b><br />To solve SQL injection attack, create a Stored Procedure as shown below.
</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">Create Procedure </span>spGetEmployees</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">@Id <span style="color: blue;">int</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">as</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">Begin</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: blue;">Select * from</span> Employees <span style="color: blue;">where </span>Id=@Id</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">End</span><br /><br /><b>Modify the codebehind page for the EmployeeSearchPage, to use the stored procedure as shown below</b></span>
<br />
<table style="border: 1px solid black;"><tbody>
<tr><td><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">using </span>System;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">using </span>System.Data;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">using </span>System.Data.SqlClient;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: blue;">namespace </span>TestWeb</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <span style="color: blue;">public partial class</span> <span style="color: #3d85c6;">EmployeeSearch </span>: System.Web.UI.<span style="color: #3d85c6;">Page</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> {</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <span style="color: blue;">protected void</span> Page_Load(<span style="color: blue;">object </span>sender, <span style="color: #3d85c6;">EventArgs </span>e)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> {</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> }</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <span style="color: blue;">protected void</span> Button1_Click(<span style="color: blue;">object </span>sender, <span style="color: #3d85c6;">EventArgs </span>e)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> {</span><br />
<span style="color: #6aa84f; font-family: Arial, Helvetica, sans-serif;"> // Create the SQL Connection object. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <span style="color: #3d85c6;">SqlConnection </span>con = <span style="color: blue;">new </span><span style="color: #3d85c6;">SqlConnection</span><br /> (<span style="color: #cc0000;">"server=localhost; database=TestDB; integrated security=SSPI"</span>);</span><br />
<span style="color: #6aa84f; font-family: Arial, Helvetica, sans-serif;"> // Create the SQL command object. Pass the stored procedure name </span><br />
<span style="color: #6aa84f;"><span style="font-family: Arial, Helvetica, sans-serif;"> // as a parameter to the constructor </span><span style="font-family: Arial, Helvetica, sans-serif; text-align: left;">of the SQL command class</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <span style="color: #3d85c6;">SqlCommand </span>cmd = <span style="color: blue;">new </span><span style="color: #3d85c6;">SqlCommand</span>(<span style="color: #cc0000;">"spGetEmployees"</span>, con);</span><br />
<span style="color: #6aa84f; font-family: Arial, Helvetica, sans-serif;"> // Create the SQL parameter object, specifying the name and the value </span><br />
<span style="color: #6aa84f; font-family: Arial, Helvetica, sans-serif;"> // we want to pass to the SP.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <span style="color: #3d85c6;">SqlParameter </span>paramId = <span style="color: blue;">new </span><span style="color: #3d85c6;">SqlParameter</span>(<span style="color: #cc0000;">"@Id"</span>, txtEmployeeId.Text);</span><br />
<span style="color: #6aa84f;"><span style="font-family: Arial, Helvetica, sans-serif;"> // Associate the Id parameter object with the command object, using <br /> // parameters collection property </span><span style="font-family: Arial, Helvetica, sans-serif; text-align: left;">of the SQL Command object. </span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> cmd.Parameters.Add(paramId);</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <span style="color: #6aa84f;">// Specify the command type as stored procedure. This tells the command <br /> // object, that the command </span></span><span style="font-family: Arial, Helvetica, sans-serif; text-align: left;"><span style="color: #6aa84f;">is a SQL stored procedure and not an adhoc sql query</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> cmd.CommandType = <span style="color: #3d85c6;">CommandType</span>.StoredProcedure;</span><br />
<span style="color: #6aa84f; font-family: Arial, Helvetica, sans-serif;"> // Open the connection</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> con.Open();</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <span style="color: #6aa84f;">// Execute the command and assign the returned results as the data source for </span></span><br />
<span style="color: #6aa84f; font-family: Arial, Helvetica, sans-serif;"> // the employyes girdview</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> gvEmployees.DataSource = cmd.ExecuteReader();</span><br />
<span style="color: #6aa84f; font-family: Arial, Helvetica, sans-serif;"> // Call the DataBind() method, to bind the results to the employees grid view control</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> gvEmployees.DataBind();</span><br />
<span style="color: #6aa84f; font-family: Arial, Helvetica, sans-serif;"> // Finally close the sql server connection object</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> con.Close();</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> }</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> }</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}</span></td></tr>
</tbody></table>
</div>Unknownnoreply@blogger.com27tag:blogger.com,1999:blog-5199087724247829980.post-77218878319407414992011-07-12T10:21:00.000-07:002013-03-02T13:30:20.573-08:00Reusable SQL function to split a string<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Write a reusable split function that can be used to split any given string with a given delimiter?</strong></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">To further understand the question better, consider the examples below</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Input String : <strong>123|456|234|435</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Delimiter Character : <strong>|</strong> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>The output should be as shown below:</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">101</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">102</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">103</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">104</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">105</span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong><span style="color: blue;">Create Function</span></strong> SplitFunction (@InputString <strong><span style="color: blue;">nvarchar</span></strong>(<strong><span style="color: magenta;">max</span></strong>), @Delimiter <strong><span style="color: blue;">Char</span></strong>(1))</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong><span style="color: blue;">Returns</span></strong> @ResultTable <strong><span style="color: blue;">Table</span></strong> (Items nvarchar(4000))</span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong>as</strong></span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong>Begin</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Declare</span></strong> @Index <strong><span style="color: blue;">int</span></strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Declare</span></strong> @Slice <strong><span style="color: blue;">nvarchar</span></strong>(4000)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Set</span></strong> @Index = 1</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">If</span></strong>(@InputString is null)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Begin</span></strong></span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong> Return</strong></span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong> End</strong></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">While</span></strong> (@Index != 0)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Begin</span></strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Set</span></strong> @Index = CHARINDEX(@Delimiter, @InputString)</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">If</span></strong>(@Index != 0)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Begin</span></strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Select</span></strong> @Slice = LEFT(@InputString, @Index - 1)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">End</span></strong></span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong> Else</strong></span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong> Begin</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Select</span></strong> @Slice = @InputString</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">End</span></strong></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Insert into</span></strong> @ResultTable(Items) <strong><span style="color: blue;">Values</span></strong> (@Slice)</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">SET</span></strong> @InputString = RIGHT(@InputString, LEN(@InputString) - @Index)</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">If</span></strong>(LEN(@InputString)) = 0</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">Begin</span></strong></span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong> Break;</strong></span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong> End</strong></span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong> End</strong></span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong> Return</strong></span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong>End</strong></span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">When we execute <strong><span style="color: blue;">Select</span> * <span style="color: blue;">from</span> SplitFunction('123|456|234|435','|')</strong>, we get the desired output. You may try with different inputs and delimiters.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">This split function is a classic example for <strong>multi-statement table valued function in SQL server</strong>.</span>Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-5199087724247829980.post-52769163281418601302011-06-09T10:59:00.000-07:002013-03-02T13:28:58.276-08:00Interview Questions related to Dependency Injection<div style="display:block;float:right;margin: 5px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://venkataspinterview.blogspot.com/2011/06/explain-dependency-injection-with.html">It is very important that, you understand the concept of dependency injection before you read these questions. Please read Dependency Injection with an example article if you have not done so already.</a> </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>When do you use Setter Injection over Constructor Injection and vice versa ?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Constructor Injection is normally the standard for dependency injection. Constructor Injection, ensures that all the dependency objects are initialized before we attempt to invoke any methods or peroperties, thus avoiding null reference exceptions. </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Setter Injection is used rarely in exceptional cases. For example, if I have a class that has several methods which does not depend on any other objects, and now I need to introduce a new method with in this class, which depends on another object. We can use, constructor injection here, but we need to change the exisitng constructor calls at all the other places. This can become cumbersome, especially if the project is a huge one. Hence, Setter Injection could be a choice when we want to change the legacy code. </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Setter Injection, enables you to inject the object, just before you need it. So, if the object is an expensive object to create, and you want to create it as late as possible, then setter injection is your choice.</span><br />
<div style="display:block;float:right;margin: 5px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>What are the advantages of using Dependency Injection?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Dependency Injection allows us to develop very loosely coupled systems.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Easy to swap in a different implementation of a component, as long as the component implements the interface type.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> Dependency Injection, allows objects to be mocked with in the Unit Tests. This is the greatest advantage of Dependency Injection.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>What Dependency Injection Container have you used in your project?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">There are lot of Dependency Injection Containers available in the market. I have included, the very commonly used list of Dependency Injection Containers for your quick refernce.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Unity</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Castle Windsor </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> StructureMap </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>4.</strong> Spring.NET </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>I have used Unity in most of my projects.<br />
<br />
If you can improve any of these answer further, please feel free to do so by submitting the form below. Thank you very much for your contribution.</strong></span>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5199087724247829980.post-11269615378004883682011-06-08T13:32:00.000-07:002013-03-02T13:27:25.477-08:00Explain Dependency Injection with an example<span style="font-family: Arial, Helvetica, sans-serif;">One of the very common interview questions, asked these days. This is the most common approach used today to solve dependencies between objects. In many of the enterprise class ASP.NET application, Dependency Injection is a common standard to follow. Let us understand Dependency Injection with an example.</span><br />
<div style="display:block;float:right;margin: 5px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><table><tbody>
<tr><td><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQYkLv3QMPYhbIrJv_aY99n-lyayNtM9uVmFwWjW8yFpGvipaabjHjyk9qm64L-iPNJfvwShSGZRSOff-YuNX3TpRhpjxxq93YA6vnmYOnYhuSXYZjk2m5ne75ggHDvweIJW9r5WPx-8qg/s1600/DependencyInjection.png" t8="true" /></td></tr>
</tbody></table><br />
<span style="font-family: Arial, Helvetica, sans-serif;">In the example above, <span style="color: blue;">Employee</span> class depends on <span style="color: blue;">EmployeeDAL</span> class to get the data from the database. In <span style="color: blue;">GetAllEmployees()</span> method of the <span style="color: blue;">Employee</span> class, we create an instance of the <span style="color: blue;">EmployeeDAL</span> (Employee Data Access Layer) class and then invoke <span style="color: blue;">SelectAllEmployees()</span> method. This is tight coupling, <span style="color: blue;">EmployeeDAL</span> is tightly copuled with the <span style="color: blue;">Employee</span> class. Everytime the <span style="color: blue;">EmployeeDAL</span> class changes, the <span style="color: blue;">Employee</span> class also needs to change. <span style="color: blue;">EmployeeDAL</span> cannot be mocked and hence unit testing becomes cumbersome and time consuming. </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">The same example can be re-written using dependency injection as shown below. First thing to notice is that, we are using <strong><span style="color: #20124d;">interface types instead of concrete types</span></strong>. Using interfaces help us to plugin any implemenation of the interface, with less or no code modification at all. We are not creating the instance of the <span style="color: blue;">EmployeeDAL</span> in the <span style="color: blue;">Employee</span> class, instead we are passing it as a parameter to the constructor of the <span style="color: blue;">Employee</span> class. As, we are injecting an instance of a class into a class that depends on it, we can call this process as <strong>Dependency Injection</strong>.</span><br />
<div style="display:block;float:right;margin: 5px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><table><tbody>
<tr><td><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4VuxfGo52VIfg4Upt7l9DEJWAkAMkiG9dxdVQrYGQZ8Z29CyIwlnRN6c10aDvKKvFILP-xiJh9TT7-rUcMYcyOdHk9H4HXVMCpNdE_Yq_CEIUirFxF7OZN2z8mp_dDe2tDMVG1TbTY-X5/s1600/ConstructorInjection.png" t8="true" /></td></tr>
</tbody></table><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Dependency Injection is of 2 types.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Constructor Injection</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Setter Injection.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">We have already seen how to use Constructor Injection in the example above. An, example for Setter Injection is shown below. We are injecting an object instance through the Setter property, instead of a constructor. Hence, we call Setter Injection. It is very important to use the property <span style="color: blue;">EmployeeDataObject</span> to access the instance of <span style="color: blue;">IEmployeeDAL</span>, rather than the private variable <span style="color: blue;">employeeDAL</span>. The property checks to see if <span style="color: blue;">employeeDAL</span> is null, and throws the exception accordingly.</span><br />
<table><tbody>
<tr><td><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOETdFNu3fElrECfikA8BpIOhmvmVlMQ6szsJPyPV84UIlGSnpA7Ea1uUGqgGcis5neuB6y1M64huNQ9XLMBHGY92v8-Wl46GB1e_sJkCgt5v3ApJCxct73b9Z6PaWIzl2-zOAbxv8OVnL/s1600/SetterInjection.png" t8="true" /></td></tr>
</tbody></table><br />
<span style="font-family: Arial, Helvetica, sans-serif;">For other follow up interview questions on Dependency Injection, please read the articles below. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://venkataspinterview.blogspot.com/2011/06/interview-questions-related-to.html">1. When do you choose Setter Injection over Constructor Injection and vice versa ?</a> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://venkataspinterview.blogspot.com/2011/06/interview-questions-related-to.html">2. What are the advantages of using Dependency Injection ?</a> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://venkataspinterview.blogspot.com/2011/06/interview-questions-related-to.html">3. What Dependency Injection Container have you used in your project ?</a> <br />
<br />
<b>If you can improve any of these answer further, please feel free to do so by submitting the form below. Thank you very much for your contribution.</b><br />
</span>Unknownnoreply@blogger.com5United States37.09024 -95.71289100000001310.70899 -156.97250350000002 63.47149 -34.45327850000001tag:blogger.com,1999:blog-5199087724247829980.post-35661812210221635242011-06-06T13:53:00.000-07:002013-03-02T13:25:41.864-08:00Interview Questions related to strong named assemblies<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Can you copy a weak named assembly into GAC?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>No</strong>, an assembly has to be strongly named to be copied into the GAC</span><br />
<div style="display:block;float:right;margin: 5px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>What is the difference between a strong and weak named assemblies?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">The following are the differences between a strong and weak named assemblies</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Weak named assemblies can be duplicated and tampered with, where as strong named assemblies cannoth be tampered and duplicated. </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Strong named assemblies can be copied into GAC, where as weak named assemblies cannot be copied.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> A single copy of strong named assembly present in the GAC can be shared with multiple applications, where as weak named assembly must be copied into the bin directory of each project.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>What is the main advantage of strong naming an assembly?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">A shared assembly that is strongly named solves the DLL hell problem, that microsoft is notoriously known for. Please follow the articles below, to understand DLL hell and the solution.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://venkataspinterview.blogspot.com/2011/05/what-is-dll-hell-in-net.html">What is DLL hell</a></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://venkataspinterview.blogspot.com/2011/06/how-is-dll-hell-problem-solved-in-net.html">How is DLL hell problem solved</a></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Can a strong named assembly refer, a weak named assembly and why?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">No, a strong named assembly cannot reference, another weak named assembly. If this is possible, the DLL hell problem will reoccur. </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Explantion:</strong> When you reference a strong named assembly, you expect to get certain benefits, such as versioning and naming protection. If the strong named assembly then references an assembly with a simple name, which does not have these benefits, you lose the benefits you would derive from using a strong named assembly and revert to DLL conflicts. Therefore, strong named assemblies can only reference other strong named assemblies.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>What is the downside of strong naming an executable (.EXE) ?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">A strongly named assembly cannot reference a weak named assembly. Therefore, strong naming an EXE prevents the EXE from referencing weak named dlls, that are deployed with the application. For this reason, the Visual Studio project system does not strong name application EXEs. Instead, it strong-names the Application manifest, which internally points to the weak named application EXE. In addition, you may want to avoid strong-naming components that are private to your application. In this case, strong-naming can make it more difficult to manage dependencies and add unnecessary overhead for private components.<br />
<br />
<b>If you can improve any of these answer further, please feel free to do so by submitting the form below. Thank you very much for your contribution.</b></span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5199087724247829980.post-75474717252905900392011-06-06T12:48:00.000-07:002013-03-02T13:36:59.458-08:00What is the process for strong naming an assembly<table><tbody>
<tr><td style="width:650px">
<div style="display:block;float:right;margin: 5px;">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div><span style="font-family: Arial, Helvetica, sans-serif;"><strong>What is the process for strong naming an assembly ?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">or</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>What is the purpose of strong naming tool ( sn.exe ) in .NET ?</strong></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">In .NET, the <strong>assembly name </strong>usually consists of <strong>4 parts </strong>as listed below.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Simple Textual Name</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Version Number (The version number is also divided into 4 parts)</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> Culture</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>4.</strong> Public Key Token </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">If an assembly contains, all the 4 parts, then the assembly is a <strong>strongly named assembly</strong>, other wise the assembly is called as a <strong>weak named assembly</strong>. In general, when you compile any .NET application, the generated assembly by default will have the Simple Textual Name, Version Number and Culture but not the public key token. If you have to sign the assembly with a public key token, you first have to generate the key pair using <strong>key generation tool </strong>called <strong>strong naming tool (sn.exe)</strong>. The generated key pair will consist of a <strong>private and a public key</strong> and are written into a key file. <strong>Key files</strong> have the extension of <strong>.snk</strong>. </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">We now have to associate the <strong>key file </strong>with the <strong>project</strong>, so that when we compile the project, the generated assembly is signed using the key pair. To do this, In <strong><span style="color: blue;">AssemblyInfo.cs</span></strong> file of the project, specify <strong><span style="color: blue;">AssemblyKeyFile</span></strong> attribute as shown below.</span><br />
<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"> [assembly: AssemblyKeyFile("MyKey.snk")]</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">The last and final step is to build the project which will automatically sign the assembly using the key file. This process generates the strongly named assembly.</span><br />
<div style="display:block;float:right;margin: 5px;">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>In short, there are 3 simple steps to generate a strongly named assembly.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Generate the key pair using strong naming tool, SN.exe.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Associate the generated Key file to the project using AssemblyKeyFile, which is present in AssemblyInfo.cs file.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> Build the project.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Once, you have strongly named the assembly, you can copy it to GAC. There are 2 ways to copy an assembly into GAC.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> <strong>Using simple drag and drop</strong> : Drag the generated assembly into the GAC folder. Usually the path for GAC is <strong>c:\windows\assembly</strong>. On some machines this could be <strong>c:\winnt\assembly</strong>.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2. Use GAC utility</strong> : Use GAC Utility tool(<strong>gacutil.exe</strong>) as shown below in visual studio command prompt. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> <strong><span style="color: blue;">gacutil.exe -i C:\MyAssembly.dll (- i stands for install)</span></strong></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Once, you have successfuly copied the assembly into GAC, notice the four parts of the assembly name. The <strong>culture</strong> column could be empty, indicating that the assembly is language neutral. </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Please click here to read few other follow up interview questions related to strong named assemblies.<br />
<br />
<strong>If you can improve this answer further, please feel free to do so by submitting the form below. Thank you very much for your contribution.</strong></span>
</td></tr>
</tbody></table>Unknownnoreply@blogger.com13tag:blogger.com,1999:blog-5199087724247829980.post-25391551000894163442011-06-03T11:18:00.000-07:002013-03-02T13:43:28.935-08:00ASP.NET Interview Questions Index<table><tr><td style="color: #0066cc; font-family: Arial; font-size: small;"><br />
<span style="color: black;"><strong>On this page you can see list of all ASP.NET Interview Questions by topic. In most of the interviews, these questions are very frequently asked. If you have an asp.net question that is asked in a previous interview, please post it here.</strong></span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/12/when-i-create-new-aspnet-4-web.html"><span style="color: #0066cc; text-decoration: none;">When I create a new ASP.NET 4 web application, the web.config file is almost empty. What happened to all the configuration elements that were there prior to ASP.NET 4?</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/12/difference-between-enableviewstate-and.html"><span style="color: #0066cc; text-decoration: none;">What is the difference between EnableViewState and ViewStateMode properties</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/09/aspnet-page-is-very-slow-what-will-you.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Page is very slow. What will you do to make it fast</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/07/what-is-sql-injection-attack.html"><span style="color: #0066cc; text-decoration: none;">Explain SQL Injection Attack with an example</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/06/explain-dependency-injection-with.html"><span style="color: #0066cc; text-decoration: none;">Explain Dependency Injection with an example ?</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/06/interview-questions-related-to.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions related to Dependency Injection ?</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/06/what-is-process-for-strong-naming.html"><span style="color: #0066cc; text-decoration: none;">What is the process of strong naming an assembly ?</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/06/interview-questions-related-to-strong.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions related to strong named assemblies</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/06/how-is-dll-hell-problem-solved-in-net.html"><span style="color: #0066cc; text-decoration: none;">How is the DLL HELL problem solved in .NET?</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/05/what-is-dll-hell-in-net.html"><span style="color: #0066cc; text-decoration: none;">What is DLL HELL in .NET?</span></a><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/03/what-is-difference-between-layers-and.html"><span style="color: #0066cc; text-decoration: none;">What is the difference between layers and tiers?</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/03/what-are-advantages-and-disadvantages.html"><span style="color: #0066cc; text-decoration: none;">What are the advantages and disadvantages of a layered architecture</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2010/06/what-is-difference-between-const-and.html"><span style="color: #0066cc; text-decoration: none;">What is the difference between const and static read-only member?</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2010/06/linq-interview-questions-part-1.html"><span style="color: #0066cc; text-decoration: none;">Linq Interview Questions Part 1</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2010/06/linq-interview-questions-part-2.html"><span style="color: #0066cc; text-decoration: none;">Linq Interview Questions Part 2</span></a> <br />
<br />
<a href="http://venkataspinterview.blogspot.com/2010/01/best-pactices-in-developing-aspnet.html"><span style="color: #0066cc; text-decoration: none;">Best pactices in developing asp.net web applications - Part 1</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2010/01/best-pactices-in-developing-aspnet_09.html"><span style="color: #0066cc; text-decoration: none;">Best pactices in developing asp.net web applications - Part 2</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2009/01/aspnet-interview-questions-on-data.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on Data Access Security</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/11/aspnet-interview-questions-on-http.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on HTTP modules and HTTP Handlers</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/11/aspnet-interview-questions-on-themes.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on Themes and Skins</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/11/aspnet-interview-questions-on-dataset.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on DataSet</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/11/aspnet-interview-questions-on.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on Globalization</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/11/c-interview-questions-arrays.html"><span style="color: #0066cc; text-decoration: none;">C# Interview Questions - Arrays</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/11/xml-interview-questions-validating-xml.html"><span style="color: #0066cc; text-decoration: none;">XML Interview Questions - Validating XML documents</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/11/xml-related-interview-questions.html"><span style="color: #0066cc; text-decoration: none;">XML related Interview Questions</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-caching_24.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on caching application data</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-fragment.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on fragment caching</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-caching.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on caching</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/application-build-related-aspnet.html"><span style="color: #0066cc; text-decoration: none;">Application build related ASP.NET Interview Questions</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-master.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on Master Pages</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-passport.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on Passport authentication</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/ssl-and-https-related-aspnet-interview.html"><span style="color: #0066cc; text-decoration: none;">SSL and HTTPS related ASP.NET Interview Questions</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-forms-authentication-related.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on forms authentication</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/08/aspnet-interview-questions-on-windows.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on windows authentication</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/frequently-asked-adonet-interview.html"><span style="color: #0066cc; text-decoration: none;">Frequently asked ADO.NET Interview Questions</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/basic-adonet-interview-questions.html"><span style="color: #0066cc; text-decoration: none;">Basic ADO.NET Interview Questions</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/interview-questions-on-aspnet-controls.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions on ASP.NET controls</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-interview-questions-on-cookies.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on Cookies</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-events-related-interview.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Events related Interview Questions</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/interview-questions-on-aspnet-exception.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions on ASP.NET Exception Handling</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/managed-code-and-unmanaged-code-related.html"><span style="color: #0066cc; text-decoration: none;">Managed Code and Unmanaged Code related ASP.NET Interview Questions</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/interview-questions-on-aspnet-page.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions on ASP.NET Page navigation techniques</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/interview-questions-on-query-strings-in.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions on Query Strings in ASP.NET</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-interview-questions-on-web.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on web application Security</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-session-state-and-application.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Session State and Application State Interview Questions</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/techniques-to-send-data-from-one-web.html"><span style="color: #0066cc; text-decoration: none;">Techniques to send data from one web form to another web form</span></a> <br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-interview-questions-on-tracing.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on Tracing</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/transactions-related-aspnet-interview.html"><span style="color: #0066cc; text-decoration: none;">Transactions related ASP.NET Interview Questions</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/interview-questions-on-aspnet.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions on ASP.NET Validation controls</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-viewstate-related-interview.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET ViewState related Interview Questions</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/web-application-maintainance-related.html"><span style="color: #0066cc; text-decoration: none;">Web Application maintainance related ASP.NET Interview Questions</span></a> <br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-web-farm.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on web farm and web garden</span></a> <br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-web-user.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Interview Questions on web user controls</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/interview-questions-on-aspnet-custom.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions on ASP.NET Custom Controls</span></a><br />
<br />
<a href="http://venkataspinterview.blogspot.com/2008/10/interview-questions-on-cascading-style.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions on cascading style sheets</span></a></td></tr>
</table>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5199087724247829980.post-85089016754359345332011-06-02T12:42:00.000-07:002013-03-02T13:44:39.824-08:00Search Results<div id="cse-search-results"></div><script type="text/javascript">
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "cse-search-box";
var googleSearchFrameWidth = 800;
var googleSearchDomain = "www.google.com";
var googleSearchPath = "/cse";
</script><br />
<script src="http://www.google.com/afsonline/show_afs_search.js" type="text/javascript">
</script>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5199087724247829980.post-54349441180996467512011-06-01T12:20:00.000-07:002013-03-02T13:46:27.542-08:00How is the DLL HELL problem solved in .NET<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://venkataspinterview.blogspot.com/2011/05/what-is-dll-hell-in-net.html">Please read What is dll hell? interview question, before proceeding with this article.</a> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">In short, the dll hell problem is solved in .NET by signing the shared assemblies with strong name. <a href="http://venkataspinterview.blogspot.com/2011/06/what-is-process-for-strong-naming.html">Please follow this article, to understand the process of strong naming an assembly.</a><br />
<br />
In dot net all the shared assemblies are usually in the GAC. GAC stands for Global Assembly Cache. The path for GAC is <strong>C:\[OperatingSystemDirectory]\assembly</strong>. For example on my computer the path is <strong>C:\WINDOWS\assembly</strong>. The image below shows the shared assemblies in the GAC.</span><br />
<table><tbody>
<tr><td><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNxBE3pJ0AvNvm-cSF4X3x24B0q_KIo7ALLuQnNC5UE_xZnvLvu780lmmeZrKvGRNOq_CP1vhWB0sb2CWVlwvgoRgpHPYo1Ij5VuYIAE9ccTmN1IGpRN41KOgva9w0rCKC-3vRadXFFnVa/s1600/GAC.png" t8="true" /></td></tr>
</tbody></table><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Only strong named assemblies can be copied into GAC. Strong named assemblies in .NET has 4 pieces in its name as listed below.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Simple Textual Name</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Version Number</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> Culture</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>4.</strong> Public Key Token</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">All these four pieces put together, is called as the fully qualified name of the assembly. In the GAC image above <strong>Accessibility assembly </strong>has a <strong>version of 2.0.0.0</strong>.</span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Now consider the example below:</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1</strong>. I have 2 applications, <strong>Application - A1</strong> and <strong>Application - A2</strong> which relies on the shared assembly <strong>Accessibility.dll (Version 2.0.0.0)</strong> as shown in the image below.</span><br />
<table><tbody>
<tr><td><br />
<img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkzRJTQfvIlL54fo9uDRqPQWhg3tfNvvuPz71vpki7BH6oFv7JORN-P0PE9sn2YLgFzvaYM5-IUoTMm8ZsLSgq6Hfwi_6ZllE5cUXDlYlUr2BibH39atZx1_FU8qhm0l8OU20WwOT2s715/s1600/Dll+Hell+Solved.png" t8="true" /></td></tr>
</tbody></table><span style="font-family: Arial, Helvetica, sans-serif;"><br />
<strong>2.</strong> Now, I have a latest version of <strong>Application - A2</strong> available on the internet.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> I download the latest version of <strong>A2</strong> and install it on my machine. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>4.</strong> This new installation copies a newer version of <strong>Accessibility.dll </strong>into the GAC with version <strong>3.0.0.0.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>5.</strong> So, in the GAC we now have <strong>2 versions of Accessibility.dll.</strong> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>6.</strong> <strong>Application - A1</strong> continues to use <strong>Accessibility.dll (version 2.0.0.0)</strong> and <strong>Application - A2 uses Accessibility.dll (version 3.0.0.0)</strong> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>7.</strong> So, now the assemblies are able to reside side by side in the GAC. For this reason dot net assemblies are also said to be supporting <strong>side by side execution.<br />
<br />
If you can improve this answer further, please feel free to do so by submitting the form below. Thank you very much for your contribution.</strong></span>Unknownnoreply@blogger.com36tag:blogger.com,1999:blog-5199087724247829980.post-18811547323377016642011-05-31T11:57:00.000-07:002013-03-02T13:47:46.583-08:00What is DLL HELL in .NET<span style="font-family: Arial, Helvetica, sans-serif;">Let us try and understand DLL HELL problem with an example. Please refer to the image below. <a href="http://venkataspinterview.blogspot.com/2011/06/how-is-dll-hell-problem-solved-in-net.html">If you want to know how dll hell problem is solved in .net, you can read this article.</a></span><br />
<br />
<table><tbody>
<tr><td><div style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="1" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAYz37Xijuq4JQzCHIbjWfDb9fGAuzU72_0nXuiQ3r9fbQgLl8JRImRcPxKLs3Q100F9fdue_MyEZHgXtHHYgdZtmXO__ywnSG4UgD60VCw7qmDYg6J9vYWfNFLWoGsKaEskWRf1bbEZie/s1600/DllHell.png" t8="true" /></div></td></tr>
</tbody></table>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> I have 2 applications, A1 and A2 installed on my computer. </span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Both of these applications use shared assembly shared.dll</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> Now, I have a latest version of Application - A2 available on the internet.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>4.</strong> I download the latest version of A2 and install it on my machine.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>5.</strong> This new installation has over written Shared.dll, which is also used by Application - A1.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>6.</strong> Application - A2 works fine, but A1 fails to work, because the newly installed Shared.dll is not backward compatible.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">So, DLL HELL is a problem where one application will install a new version of the shared component that is not backward compatible with the version already on the machine, causing all the other existing applications that rely on the shared component to break. With .NET versioning we donot have DLL HELL problem any more.<br />
<br />
<a href="http://venkataspinterview.blogspot.com/2011/06/how-is-dll-hell-problem-solved-in-net.html">How is the DLL HELL problem solved in .NET, is another very important .net interview question. Click here to read.</a><br />
<br />
<strong>If you can improve this answer further, please feel free to do so by submitting the form below. Thank you very much for your contribution.</strong></span>
<br/>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>Unknownnoreply@blogger.com9tag:blogger.com,1999:blog-5199087724247829980.post-90710377523931128302011-05-22T03:49:00.000-07:002013-03-02T13:50:55.393-08:00ASP.NET Interview Questions by topic<div dir="ltr" style="text-align: left;" trbidi="on">
<table><tbody>
<tr><td><div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<span style="color: black;"><strong>On this page you can see list of all ASP.NET Interview Questions by topic. In most of the interviews, these questions are very frequently asked. If you have an asp.net question that is asked in a previous interview, please post it here.</strong></span></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://csharp-video-tutorials.blogspot.com/"><span style="color: #0066cc; text-decoration: none;">Free C# Video Tutorial</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.co.uk/2012/08/software-development-environments.html"><span style="color: #0066cc; text-decoration: none;">What are the different environments in your development process</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/12/when-i-create-new-aspnet-4-web.html"><span style="color: #0066cc; text-decoration: none;">When I create a new ASP.NET 4 web application, the web.config file is almost empty. What happened to all the configuration elements that were there prior to ASP.NET 4?</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/09/aspnet-page-is-very-slow-what-will-you.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Page is very slow. What will you do to make it fast</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/12/difference-between-enableviewstate-and.html"><span style="color: #0066cc; text-decoration: none;">What is the difference between EnableViewState and ViewStateMode properties</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/07/what-is-sql-injection-attack.html"><span style="color: #0066cc; text-decoration: none;">Explain SQL Injection Attack with an example ?</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/06/explain-dependency-injection-with.html"><span style="color: #0066cc; text-decoration: none;">Explain Dependency Injection with an example ?</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/06/interview-questions-related-to.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions related to Dependency Injection ?</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/06/what-is-process-for-strong-naming.html"><span style="color: #0066cc; text-decoration: none;">What is the process of strong naming an assembly ?</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/06/interview-questions-related-to-strong.html"><span style="color: #0066cc; text-decoration: none;">Interview Questions related to strong named assemblies</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/06/how-is-dll-hell-problem-solved-in-net.html"><span style="color: #0066cc; text-decoration: none;">How is the DLL HELL problem solved in .NET?</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/05/what-is-dll-hell-in-net.html"><span style="color: #0066cc; text-decoration: none;">What is DLL HELL in .NET?</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/03/what-is-difference-between-layers-and.html"><span style="color: #0066cc; text-decoration: none;">What is the difference between layers and tiers?</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2011/03/what-are-advantages-and-disadvantages.html"><span style="color: #0066cc; text-decoration: none;">What are the advantages and disadvantages of a layered architecture</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2010/06/what-is-difference-between-const-and.html"><span style="color: #0066cc; text-decoration: none;">What is the difference between const and static read-only member?</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2010/06/linq-interview-questions-part-1.html"><span style="color: #0066cc; text-decoration: none;">Linq Interview Questions Part 1</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2010/06/linq-interview-questions-part-2.html"><span style="color: #0066cc; text-decoration: none;">Linq Interview Questions Part 2</span></a> </div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2010/01/best-pactices-in-developing-aspnet.html"><span style="color: #0066cc; text-decoration: none;">Best pactices in developing asp.net web applications - Part 1</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2010/01/best-pactices-in-developing-aspnet_09.html"><span style="color: #0066cc; text-decoration: none;">Best pactices in developing asp.net web applications - Part 2</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2009/01/aspnet-interview-questions-on-data.html"><span style="color: #0066cc; text-decoration: none;">Data Access Security</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/11/aspnet-interview-questions-on-http.html"><span style="color: #0066cc; text-decoration: none;">HTTP modules and HTTP Handlers</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/11/aspnet-interview-questions-on-themes.html"><span style="color: #0066cc; text-decoration: none;">Themes and Skins</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/11/aspnet-interview-questions-on-dataset.html"><span style="color: #0066cc; text-decoration: none;">DataSet</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/11/aspnet-interview-questions-on.html"><span style="color: #0066cc; text-decoration: none;">Globalization</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/11/c-interview-questions-arrays.html"><span style="color: #0066cc; text-decoration: none;">C# Interview Questions - Arrays</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/11/xml-interview-questions-validating-xml.html"><span style="color: #0066cc; text-decoration: none;">XML - Validating XML documents</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/11/xml-related-interview-questions.html"><span style="color: #0066cc; text-decoration: none;">XML</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-caching_24.html"><span style="color: #0066cc; text-decoration: none;">Caching application data</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-fragment.html"><span style="color: #0066cc; text-decoration: none;">Fragment caching</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-caching.html"><span style="color: #0066cc; text-decoration: none;">Caching</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/application-build-related-aspnet.html"><span style="color: #0066cc; text-decoration: none;">Application build</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-master.html"><span style="color: #0066cc; text-decoration: none;">Master Pages</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-passport.html"><span style="color: #0066cc; text-decoration: none;">Passport authentication</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/ssl-and-https-related-aspnet-interview.html"><span style="color: #0066cc; text-decoration: none;">SSL and HTTPS</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-forms-authentication-related.html"><span style="color: #0066cc; text-decoration: none;">Forms authentication</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/08/aspnet-interview-questions-on-windows.html"><span style="color: #0066cc; text-decoration: none;">Windows authentication</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/frequently-asked-adonet-interview.html"><span style="color: #0066cc; text-decoration: none;">ADO.NET Interview Questions</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/basic-adonet-interview-questions.html"><span style="color: #0066cc; text-decoration: none;">Basic ADO.NET Interview Questions</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/interview-questions-on-aspnet-controls.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET controls</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-interview-questions-on-cookies.html"><span style="color: #0066cc; text-decoration: none;">Cookies</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-events-related-interview.html"><span style="color: #0066cc; text-decoration: none;">Events</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/interview-questions-on-aspnet-exception.html"><span style="color: #0066cc; text-decoration: none;">Exception Handling</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/managed-code-and-unmanaged-code-related.html"><span style="color: #0066cc; text-decoration: none;">Managed Code and Unmanaged Code</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/interview-questions-on-aspnet-page.html"><span style="color: #0066cc; text-decoration: none;">ASP.NET Page navigation techniques</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/interview-questions-on-query-strings-in.html"><span style="color: #0066cc; text-decoration: none;">Query Strings</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-interview-questions-on-web.html"><span style="color: #0066cc; text-decoration: none;">Web application Security</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-session-state-and-application.html"><span style="color: #0066cc; text-decoration: none;">Session State and Application State</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/techniques-to-send-data-from-one-web.html"><span style="color: #0066cc; text-decoration: none;">Techniques to send data from one web form to another web form</span></a> </div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-interview-questions-on-tracing.html"><span style="color: #0066cc; text-decoration: none;">Tracing</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/transactions-related-aspnet-interview.html"><span style="color: #0066cc; text-decoration: none;">Transactions</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/interview-questions-on-aspnet.html"><span style="color: #0066cc; text-decoration: none;">Validation controls</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/07/aspnet-viewstate-related-interview.html"><span style="color: #0066cc; text-decoration: none;">ViewState</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/web-application-maintainance-related.html"><span style="color: #0066cc; text-decoration: none;">Web Application maintainance</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-web-farm.html"><span style="color: #0066cc; text-decoration: none;">Web farm and Web garden</span></a> </div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/aspnet-interview-questions-on-web-user.html"><span style="color: #0066cc; text-decoration: none;">Web user controls</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/interview-questions-on-aspnet-custom.html"><span style="color: #0066cc; text-decoration: none;">Custom Controls</span></a></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<br /></div>
<div style="color: #0066cc; font-family: Arial; font-size: small;">
<a href="http://venkataspinterview.blogspot.com/2008/10/interview-questions-on-cascading-style.html"><span style="color: #0066cc; text-decoration: none;">Style sheets</span></a></div>
</td></tr>
</tbody></table>
</div>Unknownnoreply@blogger.com29tag:blogger.com,1999:blog-5199087724247829980.post-69268237810586026342011-03-10T14:39:00.000-08:002013-03-02T13:52:59.854-08:00What are the advantages and disadvantages of a layered architecture<span style="color: blue; font-family: Arial, Helvetica, sans-serif;"><strong>The following are the advantages of a layered architecture:</strong></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Layered architecture increases flexibility, maintainability, and scalability.</strong> In a Layered architecture we separate the user interface from the business logic, and the business logic from the data access logic. Separation of concerns among these logical layers and components is easily achieved with the help of layered architecture.</span><br />
<div style="display:block;float:right;margin: 5px;">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Multiple applications can reuse the components.</strong> For example if we want a windows user interface rather than a web browser interface, this can be done in an easy and fast way by just replacing the UI component. All the other components like business logic, data access and the database remains the same. Layered architecture allows to swap and reuse components at will.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Layered architecture</strong> enables teams to work on different parts of the application parallely with minimal dependencies on other teams.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Layered architecture </strong>enables develop loosely coupled systems.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Different components</strong> of the application can be independently deployed, maintained, and updated, on different time schedules.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Layered architecture </strong>also makes it possible to configure different levels of security to different components deployed on different boxes. sO Layered architecture, enables you to secure portions of the application behind the firewall and make other components accessible from the Internet.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Layered architecture </strong>also helps you to test the components independently of each other.</span><br />
<br />
<span style="color: red; font-family: Arial, Helvetica, sans-serif;"><strong>The following are the disadvantages of a layered architecture: </strong></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>There might be a negative impact </strong>on the performance as we have the extra overhead of passing through layers instead of calling a component directly.</span> <br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Development of user-intensive</strong> applications can sometime take longer if the layering prevents the use of user interface components that directly interact with the database.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>The use of layers helps</strong> to control and encapsulate the complexity of large applications, but adds complexity to simple applications.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Changes to lower level interfaces </strong>tend to percolate to higher levels, especially if the relaxed layered approach is used.</span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5199087724247829980.post-69745536004368487342011-03-10T14:31:00.000-08:002013-03-02T13:54:46.268-08:00What is the difference between layers and tiers<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br /><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Layers</strong> refer to logical seperation of code. <strong>Logical layers</strong> help you organise your code better. For example an application can have the following layers.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1)</strong>Presentation Layer or UI Layer</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2)</strong>Business Layer or Business Logic Layer</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3)</strong>Data Access Layer or Data Layer</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">The aboove three <strong>layers</strong> reside in their own projects, may be 3 projects or even more. When we compile the projects we get the respective layer DLL. So we have 3 DLL's now.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Depending upon how we deploy our application, we may have <strong>1 to 3 tiers</strong>. As we now have 3 DLL's, if we deploy all the DLL's on the same machine, then we have only <strong>1 physical tier but 3 logical layers.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">If we choose to deploy each DLL on a seperate machine, then we have <strong>3 tiers</strong> and <strong>3 layers</strong>.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">So, <strong>Layers</strong> are a logical separation and <strong>Tiers</strong> are a physical separation. We can also say that, <strong>tiers</strong> are the physical deployment of <strong>layers</strong>.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Tiers:</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1)</strong> Presenation Tier or UI Tier (Hosts the Presentation Layer or UI Layer). This can be considered as web server in case of an ASP.NET web application. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2)</strong> Application Tier or Business Tier (Hosts Business Layer or Business Logic Layer). </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3)</strong> Data Access Tier or Data Tier (Hosts Data Access Layer or Data Layer).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>4)</strong> Database Tier - SQL Server or Oracle (or any other database) which has tables, stored procedures and other database objects.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>In general the following are the responsibilities of each layer or tier:</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1)</strong>Presentation Layer or Tier is usually responsible for interacting with the user.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2)</strong>Business Layer or Tier is responsible for implementing the business logic of the application.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3)</strong>Data Access Layer or Tier is responsible for encapsulating the code that accesses the persistent data stores such as a relational database.</span>Unknownnoreply@blogger.com19tag:blogger.com,1999:blog-5199087724247829980.post-50225840193406744972010-06-27T06:04:00.000-07:002013-03-02T14:16:56.274-08:00What is the difference between const and static read-only member?<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>A const field must be initialized at the place where it is declared as shown in the example below.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">class Program</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> public const int Number = 100;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>It is a compile time error to declare a const without a value. The code below will generate a compiler error stating "<span style="color: red;">A const field requires a value to be provided</span>"</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">class Program</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> public const int Number;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>It is a compile time error to change the value of a constant. The following code will generate a compiler error stating "<span style="color: red;">The left-hand side of an assignment must be a variable, property or indexer</span>"</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">class Program</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> public const int Number = 100;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> static void Main()</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> {</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> Number = 200;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> }</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>It is not mandatory to initialize a static readonly field where it is declared. You can declare a static readonly field without an initial value and can later initialize the static field in a static constructor as shown below.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">class Program</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> public static readonly int Number;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> static Program()</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> {</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> Number = 100;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> }</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>Once a static readonly field is initialized, the value cannot be changed. The code below will generate a compiler error stating "<span style="color: red;">A static readonly field cannot be assigned to (except in a static constructor or a variable initializer)</span>"</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">class Program</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> public static readonly int Number;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> static Program()</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> {</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> Number = 100;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> }</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> static void Main()</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> {</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> Number = 200;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> }</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>In short, the difference is that static readonly field can be modified by the containing class, but const field can never be modified and must be initialized where it is declared. A static readonly field can be changed by the containing class using static constructor as shown below.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">class Program</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">{</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> // Initialize the static readonly field </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> // to an initial value of 100</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> public static readonly int Number=100;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> static Program()</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> {</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> //Value changed to 200 in the static constructor</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> Number = 200;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> }</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">}</span>Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-5199087724247829980.post-33107489476496823892010-06-27T05:55:00.000-07:002013-03-02T14:18:33.600-08:00LINQ Interview Questions Part 2<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br /><br />
<div class="separator" style="clear: both; text-align: center;"></div><span style="font-family: Arial, Helvetica, sans-serif;"><strong>What are the three main components of LINQ or Language INtegrated Query?</strong></span><br />
<div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Standard Query Operators</span></div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Language Extensions </span></div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> LINQ Providers</span></div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><span style="font-family: Arial, Helvetica, sans-serif;"><strong>How are Standard Query Operators implemented in LINQ?</strong></span></div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><span style="font-family: Arial, Helvetica, sans-serif;">Standard Query Operators are implemented as extension methods in .NET Framework. These Standard Query Operators can be used to work with any collection of objects that implements the IEnumerable<t> interface. A class that inherits from the IEnumerable<t> interface must provide an enumerator for iterating over a collection of a specific type. All arrays implement IEnumerable<t>. Also, most of the generic collection classes implement IEnumerable<t> interface.</span></div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><span style="font-family: Arial, Helvetica, sans-serif;"><strong>How are Standard Query Operators useful in LINQ?</strong></span></div><div style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;"><span style="font-family: Arial, Helvetica, sans-serif;">Standard Query Operators in LINQ can be used for working with collections for any of the following and more.</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Get total count of elements in a collection.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Order the results of a collection.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> Grouping.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>4.</strong> Computing average.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>5.</strong> Joining two collections based on matching keys.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>6.</strong> Filter the results</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>List the important language extensions made in C# to make LINQ a reality?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> Implicitly Typed Variables</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> Anonymous Types</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> Object Initializers</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>4.</strong> Lambda Expressions</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>What is the purpose of LINQ Providers in LINQ?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">LINQ Providers are a set of classes that takes a LINQ query and dynamically generates a method that executes an equivalent query against a specific data source.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>What are the four LINQ Providers that .NET Framework ships?</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>1.</strong> LINQ to Objects - Executes a LINQ query against a collection of objects</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>2.</strong> LINQ to XML - Executes an XPATH query against XML documents</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>3.</strong> LINQ to SQL - Executes LINQ queries against Microsoft SQL Server.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>4.</strong> LINQ to DataSets - Executes LINQ queries against ADO.NET DataSets.<br />
<br />
<br />
<strong>Write a program using LINQ to find the sum of first 5 prime numbers?</strong></span>Unknownnoreply@blogger.com7tag:blogger.com,1999:blog-5199087724247829980.post-83158429969470539582010-06-19T03:37:00.000-07:002013-03-02T14:21:01.955-08:00Linq Interview Questions Part 1<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br /><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><strong>What is LINQ?</strong></span> <br />
<span style="font-family: Arial, Helvetica, sans-serif;">LINQ, or Language INtegrated Query, is a set of classes added to the .NET Framework 3.5. LINQ adds a rich, standardized query syntax to .NET programming languages that allows developers to interact with any type of data.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><span style="font-family: Arial, Helvetica, sans-serif;"><strong>What are the advantages of using LINQ or Language INtegrated Query?</strong></span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">In any data driven application, you get data either from a Database, or an XML file or from collection classes. Prior to LINQ, working with each data source requires writing a different style of code. Moreover, working with external resources like data bases, XML files involves communicating with that external resource in some syntax specific to that resource. To retrieve data from a database you need to send it a string that contains the SQL query to execute, similarly, to work with an XML document involves specifying an XPath expression in the form of a string. The idea is that using LINQ you can work with disparate data sources using a similar style without having to know a separate syntax for communicating with the data source (e.g., SQL or XPath) and without having to resort to passing opaque strings to external resources.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">In any data driven web application or windows application, we use database as a datasource for the application. In order to get data from the database and display it in a web or windows application, we typically do the following.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">1. <strong>Prepare your SQL Statements.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">2. <strong>Execute SQL Statements against the database.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">3. <strong>Retrieve the results.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">4. <strong>Populate the Business Objects.</strong></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">5. <strong>Display the Data in the Web Form or Windows From.</strong></span><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFqLjAUlgL6Lv0AsFp9beoz5G-78t4SoeIHLmMKaV3Lv-fAqtTmbh8WzVCWYObVBqGv78QHtOeBynYEhahq-LdpjFQ8T2EyCzLx3SVnCkBX4piFe7kIZefinbSYkS9mjoR5k2R6_1Ho9xE/s1600/Sample.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="521" qu="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFqLjAUlgL6Lv0AsFp9beoz5G-78t4SoeIHLmMKaV3Lv-fAqtTmbh8WzVCWYObVBqGv78QHtOeBynYEhahq-LdpjFQ8T2EyCzLx3SVnCkBX4piFe7kIZefinbSYkS9mjoR5k2R6_1Ho9xE/s640/Sample.jpg" width="640" /></a></div><span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">In order to send a query to the database we must first establish a connection to the database. We then must encode the logic - the SQL query, its parameters, and the parameters' values - into strings that are supplied to the SqlCommand object. And because these inputs are encoded into opaque strings, there is no compile-time error checking and very limited debugging support. For example, if there is a spelling mistake in the SELECT query causing the Customets table name to be misspelled, this typographical error won't show up until runtime when this page is viewed in a web browser. These typographical errors are easy to make as there is no IntelliSense support. When we use LINQ, Visual Studio would display an error message alerting us about the incorrect table name.</span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Another mismatch between the programming language and the database is that the data returned by the database is transformed for us into objects accessible through the SqlDataReader, but these objects are not strongly-typed objects like we'd like. To get this data into strongly-typed objects we must write code ourselves that enumerates the database results and populates each record into a corresponding object. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">LINQ was designed to address all these issues. LINQ also offers a unified syntax for working with data, be it data from a database, an XML file, or a collection of objects. With LINQ you don't need to know the intricacies of SQL, the ins and outs of XPath, or various ways to work with a collection of objects. All you need be familiar with is LINQ's classes and the associated language enhancements centered around LINQ. </span><span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">In other words, LINQ provides type safety, IntelliSense support, compile-time error checking, and enhanced debugging scenarios when working with different datasources.</span>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-5199087724247829980.post-570920045378297102010-01-09T22:56:00.000-08:002013-03-02T14:22:56.504-08:00Best pactices in developing asp.net applications - Part 2<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: arial;">1. Do not catch general exception types - You should not catch Exception or SystemException. Catching generic exception types can hide run-time problems from the library user, and can complicate debugging. You should catch only those exceptions that you can handle gracefully.<br />
<br />
2. Use properties instead of visible instance fields.<br />
<br />
3. Follow the same naming conventions accross the solution. </span><br />
<span style="font-family: arial;"><br />
4. Remove unwanted commented code, Indent code properly.<br />
<br />
5. Use curly braces with in an if statement, even if there is a single statement in the if block. This will provide better readability.<br />
<br />
6. Make sure to refactor your code to move the duplicated code to common reusable functions.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
7. Move one time control settings into the .aspx page rather than having them in the code behind in if(!IsPostback) block.<br />
<br />
8. Use inheritance whereever possible, which enables code reuse and also reduces the amount of code we have to write and test.<br />
<br />
9. Move the reusable javascript functions to an external .js file instead of having them on the page.<br />
<br />
10. For controls that are declarativley specified on the page, tie the event handlers to the controls events on the aspx page rather than initializing them in the codebehind. If the controls are built dynamically then we donot have a choice.<br />
<br />
11. Make sure to check for nulls when using any type retrieved from a session, querystring or a database to avoid NullReferenceExceptions.<br />
<br />
12. Use foreach loop instead of using for loop which may lead to out of boundary run time exceptions.</span>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5199087724247829980.post-16592420437896434872010-01-09T22:43:00.000-08:002013-03-02T14:23:55.858-08:00Best pactices in developing asp.net applications - Part 1<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: arial;">1. Remove unused private fields and functions.<br />
<br />
2. Do not cast unnecessarily. Avoid duplicate casts where possible, since there is a cost associated with them.<br />
<br />
3. Properties that return arrays are prone to code inefficiencies. Consider using a collection or making this a method.<br />
<br />
4. To test for empty strings, check if String.Length is equal to zero. Constructs such as "".Equals(someString) and String.Empty.Equals(someString) are less efficient than testing the string length. Replace these with checks for someString.Length == 0.<br />
<br />
5. Methods in the same type that differ only by return type can be difficult for developers and tools to properly recognize. When extending a type, be sure not to define new methods that differ from base type methods only by type.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
6. Use stringbuilder instead of string types for string manipulation. </span><br />
<span style="font-family: arial;"><br />
7. Use String.Format instead of concatenating and appending strings.<br />
<br />
8. Use Type.TryParse rather than Convert.ToDestinationType(). For example use int.TryParse() rather than Convert.ToInt32() which might throw an exception.<br />
<br />
9. Override Equals() method wherever applicable in your classes.<br />
<br />
10. Consider passing base types as parameters - Using base types as parameters to methods improves re-use of these methods if you only use methods & properties from the parameter's base class. E.g. use Stream instead of FileStream as a parameter when only calling Stream.Read(), this makes the method work on all kind of streams instead of just File streams. <somelength;></span>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-5199087724247829980.post-44979689752153980972009-01-17T17:45:00.000-08:002013-03-02T14:24:46.787-08:00ASP.NET Interview Questions on Data Access Security<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: arial;"><strong>What are the best practices to follow to secure connection strings in an ASP.NET web application?</strong><br />
<strong>1. </strong>Always store connection strings in the site's Web.config file. Web.config is very secure. Users will not be able to access web.config from the browser.<br />
<strong>2.</strong> Do not store connection strings as plain text. To help keep the connection to your database server secure, it is recommended that you encrypt connection string information in the configuration file.<br />
<strong>3.</strong> Never store connection strings in an aspx page.<br />
<strong>4. </strong>Never set connection strings as declarative properties of the SqlDataSource control or other data source controls.</span><span style="font-family: arial;"><strong>Why is "Connecting to SQL Server using Integrated Security" considered a best practice?</strong>Connecting to SQL Server using integrated security instead of using an explicit user name and password, helps avoid the possibility of the connection string being compromised and your user ID and password being exposed.<br />
<br />
<strong>What is the advantage of storing an XML file in the applications App_Data folder? </strong><br />
The contents of the App_Data folder will not be returned in response to direct HTTP requests.<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<strong>What is Script injection? </strong><br />
A script injection attack attempts to send executable script to your application with the intent of having other users run it. A typical script injection attack sends script to a page that stores the script in a database, so that another user who views the data inadvertently runs the code.</span><span style="font-family: arial;"><strong>What is SQL injection?</strong>A SQL injection attack attempts to compromise your database by creating SQL commands that are executed instead of, or in addition to, the commands that you have built into your application.</span><span style="font-family: arial;"><strong>What are the best practices to keep in mind when accepting user input on a web application?<br />
1.</strong> Always use validation controls whenever possible to limit user input to acceptable values.<br />
<strong>2.</strong> Always check the IsValid property of the aspx page. Run the server side code only if the IsValid property value is true. A value of false means that one or more validation controls have failed a validation check.<br />
<strong>3.</strong> Always perform server side validation irrespective of client side validation being performed or not. This will protect your web application even if the client has by passed the client side validation by disabling javascript in the web browser.<br />
<strong>4. </strong>Also make sure to re validate user input in the business logic layer of your application.</span><span style="font-family: arial;"><strong>What are the steps to follow to avoid Script Injection attacks?<br />
1.</strong> Encode user input with the HtmlEncode method. This method turns HTML into its text representation.<br />
<strong>2.</strong> If you are using the GridView control with bound fields, set the BoundField object's HtmlEncode property to true. This causes the GridView control to encode user input when the row is in edit mode.</span><span style="font-family: arial;"><strong>What are the steps to follow to avoid SQL Injection attacks?</strong>Always use parameterized queries or stored procedures instead of creating SQL commands by concatenating strings together.<br />
<br />
<strong>Can you encrypt view state data of an aspx page? </strong><br />
Yes, you encrypt view state data of an aspx page by setting the page's ViewStateEncryptionMode property to true.</span>Unknownnoreply@blogger.com11tag:blogger.com,1999:blog-5199087724247829980.post-51379754083948350752008-11-26T11:43:00.000-08:002013-03-02T14:25:57.270-08:00List all the files in a directory on a web form in asp.net<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<span style="font-family: verdana;"><strong>Question : </strong><br />
<strong>List all the files in a directory </strong>on a web form. The files must be displayed in a gridview control. The name of the file and create date must be displayed.<br />
<br />
<strong>Answer:<br />
1.</strong> Create a new web form. Drag and drop a gridview control from the toolbox onto the webform.<br />
<br />
<strong>2.</strong> Create 2 bound fields for the gridview. One bound field will display the file name and the other will display the create date.<br />
<br />
<strong>3.</strong> The HTML for your web form should be as shown below.<br />
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ListFiles.aspx.cs" Inherits="ListFiles" %><br />
<html><br />
<head runat="server"><br />
<title>List all the files in a directory</title><br />
</head><br />
<body><br />
<form id="form1" runat="server"><br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"><br />
<Columns><br />
<asp:BoundField DataField="FileName" HeaderText="File Name"></asp:BoundField><br />
<asp:BoundField DataField="DateCreated" HeaderText="Date" DataFormatString="{0:d}"></asp:BoundField><br />
</Columns><br />
</asp:GridView><br />
</form><br />
</body><br />
</html><br />
<br />
<strong>4.</strong> In the code behind file write a function which can <strong>get the list of files from the directory and bind to the gridview</strong>. The function is as shown below.<br />
private void LoadFiles()<br />
{<br />
/* Create an instance of DirectoryInfo class for enumarating through the directory. */<br />
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(Server.MapPath("FilesDirectory"));<br />
/* Call the GetFiles() instance method of the DirectoryInfo class object, which will return a files list from the current directory */<br />
System.IO.FileInfo[] fiFiles = dirInfo.GetFiles();<br />
/* Create a DataTable which can be used as the datasource for the gridview */<br />
DataTable dtFileList = new DataTable("Files");<br />
/* Create a DataColumn for file name */<br />
DataColumn dcFileName = new DataColumn("FileName");<br />
/* Create a DataColumn for file create date */<br />
DataColumn dcDateCreated = new DataColumn("DateCreated", typeof(DateTime));<br />
/* Add the 2 data columns to the data table */<br />
dtFileList.Columns.Add(dcFileName);<br />
dtFileList.Columns.Add(dcDateCreated);<br />
/* Now loop through each FileInfo object and get the file name and file create date */<br />
foreach (System.IO.FileInfo f in fiFiles)<br />
{<br />
DataRow dtNewRow = dtFileList.NewRow();<br />
/* Get the file name using FileInfo object "Name" property */<br />
dtNewRow["FileName"] = f.Name.ToString();<br />
/* Get the file create date and time using FileInfo object "CreationTime" property */<br />
dtNewRow["DateCreated"] = f.CreationTime.ToShortDateString();<br />
/* Add the row to the DataTable */<br />
dtFileList.Rows.Add(dtNewRow);<br />
}<br />
/* Set the datatable as the DataSource for the gridview and call the DataBind() method */<br />
GridView1.DataSource = dtFileList;<br />
GridView1.DataBind();<br />
}<br />
<br />
<strong>5.</strong> Finally call the LoadFiles() method on the page load event handler as shown below.<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
LoadFiles();<br />
}<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6328538092426311";
/* 300 X 250 ASP */
google_ad_slot = "5610268581";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<strong>Testing the application:<br />
1.</strong> Right click on the project name in solution explorer, and left click on "NewFolder"<br />
<strong>2.</strong> Rename the "NewFolder" to "FilesDirectory"<br />
<strong>3.</strong> Drag and Drop some files into the directoy.<br />
<strong>4.</strong> Then run the application. All the files in the "FilesDirectory" folder will be shown in the gridview.</span>Unknownnoreply@blogger.com7