<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2358940550520121354</id><updated>2012-02-02T17:24:36.701-08:00</updated><category term='LINQ'/><category term='nHibernate'/><category term='Attachment'/><category term='Microsoft'/><category term='SilverLight'/><category term='.NETFramework'/><category term='Video Tutorial'/><category term='SharePoint'/><category term='AJAX'/><category term='Free ASP.NET  Hosting'/><category term='Java'/><category term='Answers'/><category term='Visual Studio 2010'/><category term='ASP.NET'/><category term='ADO.NET'/><category term='Pattern'/><category term='C#'/><category term='JQuery'/><category term='GMAIL'/><category term='WCF'/><category term='ASP.NET Interview Questions'/><category term='New Feature'/><category term='JSON'/><category term='Drag Drop'/><category term='.NET'/><title type='text'>ASP.NET</title><subtitle type='html'>ASP.Net, C#, SQL

You will find discussion topics for ASP.net, C#, AJAX, SQL, VB.net, .Net Framework, WCF, WPF, WWF, WSS 3.0, MOSS 2007, OOPs Concepts, SQL Server, Programming. For .Net Articles, Links, FAQ, Tips and Tricks,</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default?start-index=101&amp;max-results=100'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>104</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-8464554150965103738</id><published>2010-04-16T14:39:00.000-07:00</published><updated>2010-04-16T14:44:26.772-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='GMAIL'/><category scheme='http://www.blogger.com/atom/ns#' term='Attachment'/><category scheme='http://www.blogger.com/atom/ns#' term='New Feature'/><category scheme='http://www.blogger.com/atom/ns#' term='Drag Drop'/><title type='text'>GMail now supports drag-and-drop attachments through HTML5</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6LtjWBUswzw/S8jaErqUTHI/AAAAAAAAAQg/C10RRbqckoc/s1600/DragDropGmail.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 172px;" src="http://1.bp.blogspot.com/_6LtjWBUswzw/S8jaErqUTHI/AAAAAAAAAQg/C10RRbqckoc/s320/DragDropGmail.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5460854322161273970" /&gt;&lt;/a&gt;&lt;br /&gt;HTML5 is the future of the web, and Google continue to embrace it. The latest way in which Google’s array of services are taking advantage of HTML5 is in GMal: you can now drag and drop file attachments into messages as standard if you’re using Google Chrome 4 or Firefox 3.6.&lt;br /&gt;&lt;br /&gt;All you do is grab a file off your desktop and drag and drop it into a GMail compose window. The area above your message will change to say “Drop files here.” Do so in the target area and it will automagically be uploaded and attached to your message.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This goes a long way to solve one of the most common complaints of web users: why can’t I drag and drop a file into GMail the way I can on my desktop? Thanks to HTML5’s new APIs, you now can. We’re one step closer to a total lack of separation between the desktop and the web.&lt;br /&gt;&lt;br /&gt;Unfortunately, as we said earlier, the new drag and drop features are limited to Firefox 3.6 and the latest version of Chrome, but Google says they are working quickly to support the feature for other HTML5 browsers. Odd, since Safari 4 supports the drag-and-drop API, but it’s so far missing from Chrome. Another victim in the growing feud ween Apple and Google?&lt;br /&gt;&lt;br /&gt;Read more at GMail Blog&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-8464554150965103738?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/8464554150965103738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=8464554150965103738' title='69 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8464554150965103738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8464554150965103738'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2010/04/gmail-now-supports-drag-and-drop.html' title='GMail now supports drag-and-drop attachments through HTML5'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_6LtjWBUswzw/S8jaErqUTHI/AAAAAAAAAQg/C10RRbqckoc/s72-c/DragDropGmail.JPG' height='72' width='72'/><thr:total>69</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-6876381344100849232</id><published>2009-09-12T12:37:00.000-07:00</published><updated>2009-09-12T12:37:00.133-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>How to create  a Simple Windows Service in C#</title><content type='html'>&lt;p&gt;We all know what a &lt;a href="http://msdn.microsoft.com/en-us/library/d56de412%28VS.80%29.aspx"&gt;Windows Service&lt;/a&gt; is - a long running executable that's designed to work without user interaction. They can be configured to start when the system boots and they can be run without any users logged into the system. This tutorial is going to provide step-by-step instructions on how to build a Windows Service using C# and .NET.&lt;/p&gt;  &lt;p&gt;The first thing you're going to want to do is create a new Console Application in Visual Studio. I like to start building services as console applications so they can easily be tested and debugged before converting them to services.&lt;/p&gt;  &lt;p&gt;&lt;img alt="New Console Application Dialog" src="http://www.switchonthecode.com/sites/default/files/503/images/new_console_app.png" /&gt;&lt;/p&gt;  &lt;p&gt;In order to build services, we depend on some .NET objects location in the &lt;code&gt;System.ServiceProcess&lt;/code&gt; and &lt;code&gt;System.Configuration.Install&lt;/code&gt; assemblies. Go ahead and add those references to your project.&lt;/p&gt;  &lt;p&gt;&lt;img alt="Visual Studio Project References" src="http://www.switchonthecode.com/sites/default/files/503/images/references.png" /&gt;&lt;/p&gt;  &lt;p&gt;When you created the project, Visual Studio should have created a file called &lt;code&gt;Program.cs&lt;/code&gt;, which looks something like this:&lt;/p&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections.Generic;    &lt;br /&gt;using System.Linq;    &lt;br /&gt;using System.Text;    &lt;br /&gt;namespace MyWindowsService    &lt;br /&gt;{    &lt;br /&gt;class Program    &lt;br /&gt;{    &lt;br /&gt;static void Main(string[] args)    &lt;br /&gt;{    &lt;br /&gt;}    &lt;br /&gt;}    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;The only thing we need to do in order to make this class into a service is make &lt;code&gt;Program&lt;/code&gt; extend &lt;a href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.aspx"&gt;&lt;code&gt;System.ServiceProcess.ServiceBase&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections.Generic;    &lt;br /&gt;using System.Linq;    &lt;br /&gt;using System.Text;    &lt;br /&gt;using System.ServiceProcess;    &lt;br /&gt;namespace MyWindowsService    &lt;br /&gt;{    &lt;br /&gt;class Program : ServiceBase    &lt;br /&gt;{    &lt;br /&gt;static void Main(string[] args)    &lt;br /&gt;{    &lt;br /&gt;}    &lt;br /&gt;}    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;By extending &lt;code&gt;ServiceBase&lt;/code&gt;, we're given a bunch of service related functions we can override. At a minimum, every service should override &lt;code&gt;OnStart&lt;/code&gt; and &lt;code&gt;OnStop&lt;/code&gt;. These are where, as the names imply, your custom logic should go when the service is started and stopped.&lt;/p&gt;  &lt;p&gt;class Program : ServiceBase   &lt;br /&gt;{    &lt;br /&gt;static void Main(string[] args)    &lt;br /&gt;{    &lt;br /&gt;}    &lt;br /&gt;protected override void OnStart(string[] args)    &lt;br /&gt;{    &lt;br /&gt;base.OnStart(args);    &lt;br /&gt;//TODO: place your start code here    &lt;br /&gt;}    &lt;br /&gt;protected override void OnStop()    &lt;br /&gt;{    &lt;br /&gt;base.OnStop();    &lt;br /&gt;//TODO: clean up any variables and stop any threads    &lt;br /&gt;}    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;There are several other functions beyond start and stop like pause, continue, and shutdown, but they're not needed for a basic service. For all available functions, check out the &lt;a href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase_members.aspx"&gt;ServiceBase member list&lt;/a&gt; on MSDN. &lt;/p&gt;  &lt;p&gt;Now we need to add some information about our service - like a name. Let's add a constructor to &lt;code&gt;Program&lt;/code&gt; and put it there.&lt;/p&gt;  &lt;p&gt;class Program : ServiceBase   &lt;br /&gt;{    &lt;br /&gt;static void Main(string[] args)    &lt;br /&gt;{    &lt;br /&gt;}    &lt;br /&gt;public Program()    &lt;br /&gt;{    &lt;br /&gt;this.ServiceName = &amp;quot;My Service&amp;quot;;    &lt;br /&gt;}    &lt;br /&gt;protected override void OnStart(string[] args)    &lt;br /&gt;{    &lt;br /&gt;base.OnStart(args);    &lt;br /&gt;//TODO: place your start code here    &lt;br /&gt;}    &lt;br /&gt;protected override void OnStop()    &lt;br /&gt;{    &lt;br /&gt;base.OnStop();    &lt;br /&gt;//TODO: clean up any variables and stop any threads    &lt;br /&gt;}    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;The constructor is where you'd also set lots of other information about your service (if the default settings wouldn't work). These can include things like which events it can handle, what operation it can do (pause, stop, etc.), and what event log it should log information to (application, system, etc.). For us, however, the default settings will work just fine.&lt;/p&gt;  &lt;p&gt;We're very close to having a finished service. All that left is to tell Windows what service to run when your application it executed. Just like normal applications, execution begins in the &lt;code&gt;Main&lt;/code&gt; function. This is where we'll create an instance of our service and tell it to run.&lt;/p&gt;  &lt;p&gt;class Program : ServiceBase   &lt;br /&gt;{    &lt;br /&gt;static void Main(string[] args)    &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ServiceBase.Run(new Program());    &lt;br /&gt;}    &lt;br /&gt;public Program()    &lt;br /&gt;{    &lt;br /&gt;this.ServiceName = &amp;quot;My Service&amp;quot;;    &lt;br /&gt;}    &lt;br /&gt;protected override void OnStart(string[] args)    &lt;br /&gt;{    &lt;br /&gt;base.OnStart(args);    &lt;br /&gt;//TODO: place your start code here    &lt;br /&gt;}    &lt;br /&gt;protected override void OnStop()    &lt;br /&gt;{    &lt;br /&gt;base.OnStop();    &lt;br /&gt;//TODO: clean up any variables and stop any threads    &lt;br /&gt;}    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;That's it! The service implementation is complete. We can't install it yet though, because we haven't implemented an installer. To do that we need to add another class to our project called &lt;code&gt;MyWindowsServiceInstaller&lt;/code&gt;.&lt;/p&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections.Generic;    &lt;br /&gt;using System.Linq;    &lt;br /&gt;using System.Text;    &lt;br /&gt;namespace MyWindowsService    &lt;br /&gt;{    &lt;br /&gt;class MyWindowsServiceInstaller    &lt;br /&gt;{    &lt;br /&gt;}    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;When Visual Studio creates a class for you, it doesn't automatically make it public. It's very important that this class be made public. When you install a service, the installer will look through your assembly for public classes with a specific attribute. If it's not public, it won't find it.&lt;/p&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections.Generic;    &lt;br /&gt;using System.Linq;    &lt;br /&gt;using System.Text;    &lt;br /&gt;namespace MyWindowsService    &lt;br /&gt;{    &lt;br /&gt;public class MyWindowsServiceInstaller    &lt;br /&gt;{    &lt;br /&gt;}    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;This class needs to extend &lt;a href="http://msdn.microsoft.com/en-us/library/system.configuration.install.installer.aspx"&gt;&lt;code&gt;System.Configuration.Install.Installer&lt;/code&gt;&lt;/a&gt; and be given a RunInstaller attribute. This is the attribute that the service installer looks for when installing your service.&lt;/p&gt;  &lt;p&gt;using System;   &lt;br /&gt;using System.Collections.Generic;    &lt;br /&gt;using System.Linq;    &lt;br /&gt;using System.Text;    &lt;br /&gt;using System.Configuration.Install;    &lt;br /&gt;using System.ComponentModel;    &lt;br /&gt;namespace MyWindowsService    &lt;br /&gt;{    &lt;br /&gt;[RunInstaller(true)]    &lt;br /&gt;public class MyWindowsServiceInstaller : Installer    &lt;br /&gt;{    &lt;br /&gt;}    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;Now we need to configure how we want our service installed. We'll do this in the constructor for the class we just created.&lt;/p&gt;  &lt;p&gt;[RunInstaller(true)]   &lt;br /&gt;public class MyWindowsServiceInstaller : Installer    &lt;br /&gt;{    &lt;br /&gt;public MyWindowsServiceInstaller()    &lt;br /&gt;{    &lt;br /&gt;var processInstaller = new ServiceProcessInstaller();    &lt;br /&gt;var serviceInstaller = new ServiceInstaller();    &lt;br /&gt;//set the privileges    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; processInstaller.Account = ServiceAccount.LocalSystem;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; serviceInstaller.DisplayName = &amp;quot;My Service&amp;quot;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; serviceInstaller.StartType = ServiceStartMode.Manual;    &lt;br /&gt;//must be the same as what was set in Program's constructor    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; serviceInstaller.ServiceName = &amp;quot;My Service&amp;quot;;    &lt;br /&gt;this.Installers.Add(processInstaller);    &lt;br /&gt;this.Installers.Add(serviceInstaller);    &lt;br /&gt;}    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;This is pretty much the bare minimum when it comes to service options. We have to create a &lt;a href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceprocessinstaller.aspx"&gt;&lt;code&gt;ServiceProcessInstaller&lt;/code&gt;&lt;/a&gt; and a &lt;a href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.aspx"&gt;&lt;code&gt;ServiceInstaller&lt;/code&gt;&lt;/a&gt;. These two classes are responsible for installing the service. The &lt;code&gt;ServiceProcessInstaller&lt;/code&gt; installs information common to all services, and the &lt;code&gt;ServiceInstaller&lt;/code&gt; installs information for this specific service. &lt;/p&gt;  &lt;p&gt;The &lt;code&gt;Account&lt;/code&gt; property sets which privileges you'd like the service to run under. The default is &lt;code&gt;User&lt;/code&gt;, but then we'd have to specify a username and a password to determine the account. I chose &lt;code&gt;LocalSystem&lt;/code&gt;, which gives the service a lot (probably too much) access to the local computer.&lt;/p&gt;  &lt;p&gt;Services are identified by name, so you have to ensure &lt;code&gt;serviceInstaller.ServiceName&lt;/code&gt; is exactly the same as what you set in the constructor of &lt;code&gt;Program&lt;/code&gt;. The rest of the options are pretty obvious. All that's left is to add our two installers to the &lt;code&gt;Installers&lt;/code&gt; collection.&lt;/p&gt;  &lt;p&gt;We're done! All that's left to do now is install the service.&lt;/p&gt;  &lt;h5&gt;Installing The Service&lt;/h5&gt;  &lt;p&gt;Services are installed using a tool from Microsoft called &lt;a href="http://msdn.microsoft.com/en-us/library/50614e95%28VS.80%29.aspx"&gt;installutil.exe&lt;/a&gt;. This tool is free and is probably already on your computer. I doubt it's in your system path, so you might want to do a quick search for it and add it to your environment variables before continuing.&lt;/p&gt;  &lt;p&gt;All you have to do to install your service is open a command prompt, cd to your Release directory, and type:&lt;/p&gt;  &lt;p&gt;installutil MyWindowsService.exe&lt;/p&gt;  &lt;p&gt;&lt;img alt="installutil output" src="http://www.switchonthecode.com/sites/default/files/503/images/install.png" /&gt;&lt;/p&gt;  &lt;p&gt;Your service is now installed and ready to go. If you bring up your services manager, you should see one labeled &amp;quot;My Service&amp;quot;. Of course, if you start it, nothing will happen since we didn't actually put any code in the OnStart function.&lt;/p&gt;  &lt;p&gt;&lt;img alt="Windows Service List" src="http://www.switchonthecode.com/sites/default/files/503/images/service_list.png" /&gt;&lt;/p&gt;  &lt;p&gt;If you want to uninstall the service, you can do so with the same utility but with the &amp;quot;-u&amp;quot; flag.&lt;/p&gt;  &lt;p&gt;installutil -u MyWindowsService.exe&lt;/p&gt;  &lt;p&gt;There's a lot of power that we haven't even touched in Windows Services, but this tutorial should hopefully give you a starting point on which you can expand and build some much more complex solutions. All of the example code has been attached as a Visual Studio 2008 solution.&lt;/p&gt;  &lt;p&gt;Source:&lt;a title="http://www.switchonthecode.com" href="http://www.switchonthecode.com"&gt;http://www.switchonthecode.com&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-6876381344100849232?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/6876381344100849232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=6876381344100849232' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6876381344100849232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6876381344100849232'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/how-to-create-simple-windows-service-in.html' title='How to create  a Simple Windows Service in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-2352444225639308038</id><published>2009-09-11T12:33:00.000-07:00</published><updated>2009-09-11T12:33:00.144-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>How To Configure And Use Visual Studio Macros</title><content type='html'>&lt;p&gt;Microsoft Visual Studio has pretty much every operation you'd ever need right at your fingertips through the built in keystrokes. However, there are times when you'd like the text editor to do something that isn't built in. This is where macros come in. Macros can be wired up to keystrokes and can do pretty much unlimited modifications to your text - as long as you're willing to program it. In this tutorial, I'm going to demonstrate how to import an existing macro and configure a keystroke for it.&lt;/p&gt;  &lt;p&gt;I'm not going to show you how to write macros in this tutorial. For almost anything you need, someone has already probably written it anyway. It's just a Google search away. At some point in the future, however, I'll go into the details on how to write a custom macro.&lt;/p&gt;  &lt;p&gt;The macro I'm going to use in this tutorial is one I found especially useful a while ago that reverses the statements on either side of an assignment operator. So this:&lt;/p&gt;  &lt;p&gt;myVariable = myOtherVariable;&lt;/p&gt;  &lt;p&gt;Turns into this:&lt;/p&gt;  &lt;p&gt;myOtherVariable = myVariable;&lt;/p&gt;  &lt;p&gt;This macro is &lt;a href="http://www.codeproject.com/KB/macros/macroswapassignments.aspx"&gt;hosted on CodeProject&lt;/a&gt; and was written by someone named John C. &lt;/p&gt;  &lt;p&gt;All of Visual Studio's macros can be found using the Macro Explorer, which can be accessed through the Tools menu.&lt;/p&gt;  &lt;p&gt;&lt;img alt="VS Macros Menu" src="http://www.switchonthecode.com/sites/default/files/216/images/macro_explorer_menu.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;If you've never added a macro to Visual Studio, the explorer should look something like this:&lt;/p&gt;  &lt;p&gt;&lt;img alt="VS Macro Explorer" src="http://www.switchonthecode.com/sites/default/files/216/images/macro_explorer.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;Macros are placed into projects and grouped together in modules. Visual Studio has already created and added the MyMacros project with one module called Module1. As you can see, however, there are no macros in that module. This is where we're going to add the macro I linked to above. The first thing you'll want to do is right-mouse click on Module1 and add a new macro.&lt;/p&gt;  &lt;p&gt;&lt;img alt="New Macro Menu" src="http://www.switchonthecode.com/sites/default/files/216/images/new_macro_menu.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;As soon as you hit that menu item, the Macro IDE will display. This is where you'd program your macro, but in our case, this is where we past John C's macro.&lt;/p&gt;  &lt;p&gt;&lt;img alt="The Macro IDE" src="http://www.switchonthecode.com/sites/default/files/216/images/macro_ide.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;Visual Studio went ahead and put a blank macro in the module for you, but all we have to do is simply replace all of the text with John's macro.&lt;/p&gt;  &lt;p&gt;&lt;img alt="Macro IDE with content" src="http://www.switchonthecode.com/sites/default/files/216/images/macro_ide_filled.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;It's not quite ready to use yet. John named his module JohnUtils, but ours is named Module1. Before this macro can be used, we need to change the name of the module in John's code to Module1.&lt;/p&gt;  &lt;p&gt;Public Module JohnUtils&lt;/p&gt;  &lt;p&gt;Needs to change to:&lt;/p&gt;  &lt;p&gt;Public Module Module1&lt;/p&gt;  &lt;p&gt;That's it. Now when you save and close the Macro IDE, the new macro will be visible in the macro explorer.&lt;/p&gt;  &lt;p&gt;&lt;img alt="New Macro Explorer Contents" src="http://www.switchonthecode.com/sites/default/files/216/images/new_macro.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;Theoretically, this macro is ready to run. If you select some lines of code, right-mouse click on the macro and select &amp;quot;run&amp;quot;, it will execute on the lines you've selected. However, I don't want to have to use the mouse to run my macros. I want to hook them up to keystrokes. Fortunately, Visual Studio has a nice little keyboard editor where you can do just that. The first thing we need to do is bring up the keyboard editor, which is located under the Tools/Options menu.&lt;/p&gt;  &lt;p&gt;&lt;img alt="VS Keboard Editor" src="http://www.switchonthecode.com/sites/default/files/216/images/keyboard_editor.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;That list of commands contains every command available to Visual Studio - which is a lot. It also contains all of your macros. You'll want to filter the list by simply typing &amp;quot;macro&amp;quot; in the text box above the commands.&lt;/p&gt;  &lt;p&gt;&lt;img alt="Keyboard Editor Filtered" src="http://www.switchonthecode.com/sites/default/files/216/images/keyboard_editor_macro.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;As soon as you find the macro you want to hook up to a keystroke, simply click the shortcut keys text box and enter your keystroke. It can sometimes be difficult to find a keystroke not already used by Visual Studio, but from what I've learned, control+0 is not used anywhere. There's nothing wrong with using an existing keystroke, but it will replace whatever the original command was, so choose wisely. Once your keystroke is entered, just click the &amp;quot;Assign&amp;quot; button and everything is done. Now whenever you hit that keystroke, the selected macro will run.&lt;/p&gt;  &lt;p&gt;&lt;img alt="Keyboard Editor Shortcut Keys Closeup" src="http://www.switchonthecode.com/sites/default/files/216/images/shortcut_keys.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;There's still a lot to cover when it comes to macros, but this tutorial should give you a good introduction on how to import and use an existing macro. Look forward to more in-depth tutorials in the future on how to write your own Visual Studio macros. As always, questions and comments are always welcome.&lt;/p&gt;  &lt;p&gt;Source:&lt;a title="http://www.switchonthecode.com" href="http://www.switchonthecode.com"&gt;http://www.switchonthecode.com&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-2352444225639308038?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/2352444225639308038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=2352444225639308038' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/2352444225639308038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/2352444225639308038'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/how-to-configure-and-use-visual-studio.html' title='How To Configure And Use Visual Studio Macros'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-4111520489142206723</id><published>2009-09-06T21:19:00.001-07:00</published><updated>2009-09-06T21:19:16.844-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>How to make custom code snippet in Visual Studio</title><content type='html'>&lt;p&gt;A cool feature that Visual Studio has is the concept of a &amp;quot;code snippet.&amp;quot; You know those chunks of code that you need to type over and over again throughout your code? Perhaps your logging calls, or even more mundane than that, the generic code for try-catch blocks. Well, the folks behind Visual Studio came up with an idea to help keep that concept to a minimum - code snippets. Essentially, it is like having that repetitive code always on your clipboard, ready to &amp;quot;paste&amp;quot; into your code - except it is way more powerful than just copying and pasting code.&lt;/p&gt;  &lt;p&gt;If you have used Visual Studio for a while, you have probably run across some of the standard code snippets - you may even be using them intentionally all the time. Today we are going to look at first how to use snippets in your code (really easy to do), and then we are going to take a look at how you can write your own code snippets. It is in writing your own code snippets that you really start to see the power of the code snippet system, and hopefully after today's tutorial you can go off and streamline your own work flow by writing a couple snippets for yourself.&lt;/p&gt;  &lt;p&gt;So first, lets take a look at adding existing snippets to code. There are a number of ways to do this in Visual Studio, the most common of which is to use regular intellisense. For instance, below we are about to add a &lt;code&gt;for&lt;/code&gt; loop snippet:&lt;/p&gt;  &lt;p&gt;&lt;img alt="Intellisense Dropdown" src="http://www.switchonthecode.com/sites/default/files/120/images/snippet2.png" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;img alt="Visual Studio Context Menu" src="http://www.switchonthecode.com/sites/default/files/120/images/snippet3.png" /&gt;&lt;/p&gt;  &lt;p&gt;You can also get to a menu of just snippets by using the right click menu and choosing the option &amp;quot;Insert Snippet&amp;quot;. And, of course, if the mouse is too much work for you, there is a keyboard shortcut that will bring up this menu directly - ctrl-k + ctrl-x. Below, you can see the menu in action as we choose again to insert the &lt;code&gt;for&lt;/code&gt; loop snippet.&lt;/p&gt;  &lt;p&gt;&lt;img alt="Intellisense For Snippets" src="http://www.switchonthecode.com/sites/default/files/120/images/snippet1.png" /&gt;&lt;/p&gt;  &lt;p&gt;You might be wondering &amp;quot;why would I want to use a for loop snippet?&amp;quot; - cause after all, a for loop it really isn't that complex to write. Well, what it does is give you the full for loop framework with only a couple keystrokes. This is what inserting the for loop snippet will give you:&lt;/p&gt;  &lt;p&gt;&lt;img alt="Example Snippet Insert" src="http://www.switchonthecode.com/sites/default/files/120/images/snippet4.png" /&gt;&lt;/p&gt;  &lt;p&gt;If your not convinced that saved you that many keystrokes, theres another handy feature. See how the first &amp;quot;i&amp;quot; is highlighted and the second two are surrounded by dotted lines? That means that those variables are supposed to be the same - which mean that if you edit the first &amp;quot;i&amp;quot; right after you insert the code snippet, the other &amp;quot;i&amp;quot;s change to the new name automatically. That 'linkage' isn't kept around forever, as soon as you go and edit something other than the snippet, those dotted lines go away and any changes that you make later on don't automatically get propagated. But pretty cool, eh?&lt;/p&gt;  &lt;p&gt;Another handy feature of snippets, is that for many of them you not only have the ability to &amp;quot;insert&amp;quot; them, you also have the ability to surround other code with them. For instance, if you had highlighted some code, done a right click, you can pick &amp;quot;Surround With..&amp;quot; from that right click menu (it is right below &amp;quot;Insert Snippet&amp;quot; in the right click menu pictured above). Then, only the code snippets that can do a &amp;quot;surround&amp;quot; operation will appear, and you can pick one and add it. And surround does exactly what you might expect - for instance, in the case of the for loop, it will surround the code you had highlighted with the for loop structure pictured above. The keyboard shortcut for this &amp;quot;Surround With&amp;quot; action is ctrl-k + ctrl-s.&lt;/p&gt;  &lt;p&gt;Ok, enough on using code snippets - lets try and write one! For this tutorial, we are going to create a really simple snippet for performance timing. It will work as both an &amp;quot;insert&amp;quot; and &amp;quot;surround&amp;quot; code snippet, and this will be the code that it produces:&lt;/p&gt;  &lt;p&gt;&lt;img alt="Our Snippet Example" src="http://www.switchonthecode.com/sites/default/files/120/images/snippet5.png" /&gt;&lt;/p&gt;  &lt;p&gt;All it does is surround a block of code with a line at the start that captures the start time, and a line at the end that prints out the difference between the start time and the current time. There are two blocks that are set as editable - first, the name of the &lt;code&gt;startTime&lt;/code&gt; variable (which will also change the &lt;code&gt;startTime&lt;/code&gt; reference at the end of the snippet), and the &amp;quot;My function&amp;quot; part of the string, so that you can put a more descriptive name of exactly what you are timing.&lt;/p&gt;  &lt;p&gt;So how do we do this? Well, all a code snippet is is an xml file - and a relatively simple one at that. Here is the basic outline of a code snippet xml file:&lt;/p&gt;  &lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;    &lt;br /&gt;&amp;lt;CodeSnippets xmlns=&amp;quot;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;CodeSnippet Format=&amp;quot;1.0.0&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;Header&amp;gt;     &lt;br /&gt;&amp;lt;/Header&amp;gt;     &lt;br /&gt;&amp;lt;Snippet&amp;gt;     &lt;br /&gt;&amp;lt;/Snippet&amp;gt;     &lt;br /&gt;&amp;lt;/CodeSnippet&amp;gt;     &lt;br /&gt;&amp;lt;/CodeSnippets&amp;gt;&lt;/p&gt;  &lt;p&gt;Pretty standard initial xml declaration stuff. There is a &lt;code&gt;CodeSnippets&lt;/code&gt; block that can contain one or more &lt;code&gt;CodeSnippet&lt;/code&gt; blocks. Each &lt;code&gt;CodeSnippet&lt;/code&gt; block has a &lt;code&gt;Header&lt;/code&gt; block (for stuff like title and author) and a &lt;code&gt;Snippet&lt;/code&gt; block (for the actual snippet code). Below is an example &lt;code&gt;Header&lt;/code&gt; block:&lt;/p&gt;  &lt;p&gt;&amp;lt;Header&amp;gt;    &lt;br /&gt;&amp;lt;Title&amp;gt;Simple Performance Timing&amp;lt;/Title&amp;gt;     &lt;br /&gt;&amp;lt;Shortcut&amp;gt;Timing&amp;lt;/Shortcut&amp;gt;     &lt;br /&gt;&amp;lt;Description&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Code snippet for surrounding a section of code with     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; some performance timing.     &lt;br /&gt;&amp;lt;/Description&amp;gt;     &lt;br /&gt;&amp;lt;Author&amp;gt;Switch On The Code&amp;lt;/Author&amp;gt;     &lt;br /&gt;&amp;lt;SnippetTypes&amp;gt;     &lt;br /&gt;&amp;lt;SnippetType&amp;gt;SurroundsWith&amp;lt;/SnippetType&amp;gt;     &lt;br /&gt;&amp;lt;SnippetType&amp;gt;Expansion&amp;lt;/SnippetType&amp;gt;     &lt;br /&gt;&amp;lt;/SnippetTypes&amp;gt;     &lt;br /&gt;&amp;lt;/Header&amp;gt;&lt;/p&gt;  &lt;p&gt;Nothing crazy here - we give the snippet a title, a shortcut (which is what shows up in all the intellisense menus), a description and an author. With the &lt;code&gt;SnippetTypes&lt;/code&gt; block, you declare what type(s) this snippet supports - in this case, it can do both &amp;quot;SurroundsWith&amp;quot; and &amp;quot;Expansion&amp;quot; (i.e., insertion). So onto the actual definition of the snippet:&lt;/p&gt;  &lt;p&gt;&amp;lt;Snippet&amp;gt;    &lt;br /&gt;&amp;lt;Declarations&amp;gt;     &lt;br /&gt;&amp;lt;Literal&amp;gt;     &lt;br /&gt;&amp;lt;ID&amp;gt;startTime&amp;lt;/ID&amp;gt;     &lt;br /&gt;&amp;lt;ToolTip&amp;gt;Beginning Time Variable&amp;lt;/ToolTip&amp;gt;     &lt;br /&gt;&amp;lt;Default&amp;gt;startTime&amp;lt;/Default&amp;gt;     &lt;br /&gt;&amp;lt;/Literal&amp;gt;     &lt;br /&gt;&amp;lt;Literal&amp;gt;     &lt;br /&gt;&amp;lt;ID&amp;gt;message&amp;lt;/ID&amp;gt;     &lt;br /&gt;&amp;lt;ToolTip&amp;gt;Replace This With Your Description&amp;lt;/ToolTip&amp;gt;     &lt;br /&gt;&amp;lt;Default&amp;gt;My function&amp;lt;/Default&amp;gt;     &lt;br /&gt;&amp;lt;/Literal&amp;gt;     &lt;br /&gt;&amp;lt;Literal Editable=&amp;quot;false&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;ID&amp;gt;DiagnosticsDebug&amp;lt;/ID&amp;gt;     &lt;br /&gt;&amp;lt;Function&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleTypeName(global::System.Diagnostics.Debug)     &lt;br /&gt;&amp;lt;/Function&amp;gt;     &lt;br /&gt;&amp;lt;/Literal&amp;gt;     &lt;br /&gt;&amp;lt;/Declarations&amp;gt;     &lt;br /&gt;&amp;lt;Code Language=&amp;quot;CSharp&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;![CDATA[     &lt;br /&gt;&amp;#160;&amp;#160; long $startTime$ = Environment.TickCount;     &lt;br /&gt;&amp;#160;&amp;#160; $selected$ $end$     &lt;br /&gt;&amp;#160;&amp;#160; $DiagnosticsDebug$.WriteLine(String.Format(     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;$message$ took {0} ticks.&amp;quot;, Environment.TickCount - $startTime$));     &lt;br /&gt;&amp;#160;&amp;#160; ]]&amp;gt;     &lt;br /&gt;&amp;lt;/Code&amp;gt;     &lt;br /&gt;&amp;lt;/Snippet&amp;gt;&lt;/p&gt;  &lt;p&gt;There are two main sections here, &lt;code&gt;Declarations&lt;/code&gt; and &lt;code&gt;Code&lt;/code&gt;. It is in the declarations that we can declare the special variables that appear in multiple places in the code (like &lt;code&gt;startTime&lt;/code&gt;), or variables that just need to be edited when the snippet appears (like the &amp;quot;My function&amp;quot; string). As you can see, the first literal that we declare is &lt;code&gt;startTime&lt;/code&gt; - we give it a name to refer to it as in the snippet (in this case &amp;quot;startTime&amp;quot;), a tool tip that will appear for the user describing what the variable is, and a default value. We can then use this literal down inside the code snippet itself - refering to it as &lt;code&gt;$startTime$&lt;/code&gt;.&lt;/p&gt;  &lt;p&gt;The next literal is just as simple - it is the placeholder for the &amp;quot;My function&amp;quot; string, and we call it &lt;code&gt;message&lt;/code&gt;. You can see it down in the code in the output string refered to as &lt;code&gt;$message$&lt;/code&gt;. The third literal is kind of weird. It is not editable by the user (declared by the &lt;code&gt;Editable=&amp;quot;false&amp;quot;&lt;/code&gt; attribute), and it has a &lt;code&gt;Function&lt;/code&gt; tag. What this allows us to do is have the snippet figure out automatically if it should output the code using the full reference &lt;code&gt;System.Diagnostics.Debug&lt;/code&gt; or just the shorthand &lt;code&gt;Debug&lt;/code&gt;. If already have a &lt;code&gt;using System.Diagnostics;&lt;/code&gt; statement in your code, then there is no need for the full declaration, and the snippet realizes this. The work is actually done in that &lt;code&gt;SimpleTypeName&lt;/code&gt; function in the &lt;code&gt;Function&lt;/code&gt; tag. You can read more about this and the other available functions for use in snippets in the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms242312%28VS.80%29.aspx"&gt;MSDN docs&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;And that brings us down to the actual code inside the &lt;code&gt;Code&lt;/code&gt; tag. Most of this is the actual code that will appear after insertion, and we already explained what &lt;code&gt;$startTime$&lt;/code&gt; and &lt;code&gt;$message$&lt;/code&gt;. There are two other oddities here - &lt;code&gt;$selected$&lt;/code&gt; and &lt;code&gt;$end$&lt;/code&gt;. They are both reserved identifiers in code snippets - &lt;code&gt;$selected&lt;/code&gt; represents whatever the user had highlighted when they decided to do a &amp;quot;Surround With&amp;quot; snippet, and &lt;code&gt;$end$&lt;/code&gt; signifies where the caret should go after the user finishes inserting the snippet.&lt;/p&gt;  &lt;p&gt;And that is about it for defining a code snippet. There are, of course, a number of other optional attributes/tags that we did not hit on with this simple snippet, but the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms165392%28VS.80%29.aspx"&gt;MSDN docs&lt;/a&gt; do a pretty good job of explaining them. Below is the entire timing code snippet as a single block:&lt;/p&gt;  &lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;    &lt;br /&gt;&amp;lt;CodeSnippets xmlns=&amp;quot;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;CodeSnippet Format=&amp;quot;1.0.0&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;Header&amp;gt;     &lt;br /&gt;&amp;lt;Title&amp;gt;Simple Performance Timing&amp;lt;/Title&amp;gt;     &lt;br /&gt;&amp;lt;Shortcut&amp;gt;Timing&amp;lt;/Shortcut&amp;gt;     &lt;br /&gt;&amp;lt;Description&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Code snippet for surrounding a section of code     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; with some performance timing.     &lt;br /&gt;&amp;lt;/Description&amp;gt;     &lt;br /&gt;&amp;lt;Author&amp;gt;Switch On The Code&amp;lt;/Author&amp;gt;     &lt;br /&gt;&amp;lt;SnippetTypes&amp;gt;     &lt;br /&gt;&amp;lt;SnippetType&amp;gt;SurroundsWith&amp;lt;/SnippetType&amp;gt;     &lt;br /&gt;&amp;lt;SnippetType&amp;gt;Expansion&amp;lt;/SnippetType&amp;gt;     &lt;br /&gt;&amp;lt;/SnippetTypes&amp;gt;     &lt;br /&gt;&amp;lt;/Header&amp;gt;     &lt;br /&gt;&amp;lt;Snippet&amp;gt;     &lt;br /&gt;&amp;lt;Declarations&amp;gt;     &lt;br /&gt;&amp;lt;Literal&amp;gt;     &lt;br /&gt;&amp;lt;ID&amp;gt;startTime&amp;lt;/ID&amp;gt;     &lt;br /&gt;&amp;lt;ToolTip&amp;gt;Beginning Time Variable&amp;lt;/ToolTip&amp;gt;     &lt;br /&gt;&amp;lt;Default&amp;gt;startTime&amp;lt;/Default&amp;gt;     &lt;br /&gt;&amp;lt;Type&amp;gt;long&amp;lt;/Type&amp;gt;     &lt;br /&gt;&amp;lt;/Literal&amp;gt;     &lt;br /&gt;&amp;lt;Literal&amp;gt;     &lt;br /&gt;&amp;lt;ID&amp;gt;message&amp;lt;/ID&amp;gt;     &lt;br /&gt;&amp;lt;ToolTip&amp;gt;Replace This With Your Description&amp;lt;/ToolTip&amp;gt;     &lt;br /&gt;&amp;lt;Default&amp;gt;My function&amp;lt;/Default&amp;gt;     &lt;br /&gt;&amp;lt;/Literal&amp;gt;     &lt;br /&gt;&amp;lt;Literal Editable=&amp;quot;false&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;ID&amp;gt;DiagnosticsDebug&amp;lt;/ID&amp;gt;     &lt;br /&gt;&amp;lt;Function&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SimpleTypeName(global::System.Diagnostics.Debug)     &lt;br /&gt;&amp;lt;/Function&amp;gt;     &lt;br /&gt;&amp;lt;/Literal&amp;gt;     &lt;br /&gt;&amp;lt;/Declarations&amp;gt;     &lt;br /&gt;&amp;lt;Code Language=&amp;quot;CSharp&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;![CDATA[     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; long $startTime$ = Environment.TickCount;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $selected$ $end$     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $DiagnosticsDebug$.WriteLine(String.Format(     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;$message$ took {0} ticks.&amp;quot;, Environment.TickCount - $startTime$));     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ]]&amp;gt;     &lt;br /&gt;&amp;lt;/Code&amp;gt;     &lt;br /&gt;&amp;lt;/Snippet&amp;gt;     &lt;br /&gt;&amp;lt;/CodeSnippet&amp;gt;     &lt;br /&gt;&amp;lt;/CodeSnippets&amp;gt;&lt;/p&gt;  &lt;p&gt;But wait! You might be wondering how you actually add a code snippet for Visual Studio to use after you have created it. You will want to go up to the Tools menu and choose Code Snippets Manager:&lt;/p&gt;  &lt;p&gt;&lt;img alt="Visual Studio Tools Menu" src="http://www.switchonthecode.com/sites/default/files/120/images/snippet6.png" /&gt;&lt;/p&gt;  &lt;p&gt;Once you click on that, you get the Code Snippets Manager dialog:&lt;/p&gt;  &lt;p&gt;&lt;img alt="Visual Studio Code Snippet Manager" src="http://www.switchonthecode.com/sites/default/files/120/images/snippet7.png" /&gt;&lt;/p&gt;  &lt;p&gt;And from here it is pretty self explanatory - you can import snippet files (using the aptly named &amp;quot;Import&amp;quot; button), or you can add a folder's worth (in which case, as you add and remove snippets from that folder, they will appear/disappear from the available snippets).&lt;/p&gt;  &lt;p&gt;I hope you've enjoyed this introduction to Visual Studio snippets. There are a number of resources out there for finding code snippets that other people have written, such as &lt;a href="http://www.gotcodesnippets.net/"&gt;Got Code Snippets&lt;/a&gt;. If you have any questions about writing your own snippets, or cool uses for them, please leave a comment.&lt;/p&gt;  &lt;p&gt;Source:&lt;a title="http://www.switchonthecode.com" href="http://www.switchonthecode.com"&gt;http://www.switchonthecode.com&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-4111520489142206723?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/4111520489142206723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=4111520489142206723' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4111520489142206723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4111520489142206723'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/how-to-make-custom-code-snippet-in.html' title='How to make custom code snippet in Visual Studio'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-6837379928743721687</id><published>2009-09-06T21:04:00.000-07:00</published><updated>2009-09-06T21:06:35.731-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)</title><content type='html'>&lt;h2 class="pageTitle"&gt;        ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)                    &lt;/h2&gt;                           &lt;span style="font-family:arial;font-size:85%;"&gt;   &lt;p&gt;This is the sixth in &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx" target="_blank"&gt;a series of blog posts&lt;/a&gt; I’m doing on the upcoming VS 2010 and .NET 4 release.&lt;/p&gt;    &lt;p&gt;Today’s post covers another useful improvement in VS 2010 – HTML/ASP.NET/JavaScript snippet support.  Snippets allow you to be more productive within source view by allowing you to create chunks of code and markup that you can quickly apply and use in your application with a minimum of character typing.&lt;/p&gt;    &lt;p&gt;Visual Studio has supported the concept of “snippets” for VB and C# in previous releases – but not for HTML, ASP.NET markup and JavaScript.  With VS 2010 we now support snippets for these content types as well.&lt;/p&gt;    &lt;h3&gt;&lt;u&gt;Using ASP.NET Snippets&lt;/u&gt;&lt;/h3&gt;    &lt;p&gt;Let’s walkthrough how we can use snippets to quickly implement a common security scenario.  Specifically, we’ll implement the functionality necessary to display either a “[ Login ]” link or a “[ Welcome &lt;em&gt;UserName &lt;/em&gt;]” message at the the top right of a site depending on whether or not the user is logged in:&lt;/p&gt;    &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/scottgu/step1_1925DA4F.png"&gt;&lt;img style="border-width: 0px; display: inline;" title="step1" alt="step1" src="http://weblogs.asp.net/blogs/scottgu/step1_thumb_10C204F8.png" border="0" width="683" height="414" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;&lt;em&gt;The above functionality is automatically added for you when you create a project using the new &lt;/em&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/08/26/starter-project-templates-vs-2010-and-net-4-0-series.aspx" target="_blank"&gt;&lt;em&gt;ASP.NET Project Starter Template in VS 2010&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.  For the purpose of this walkthrough, though, we’ll assume we are starting with a blank master page and will build it entirely from scratch.&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;We’ll start by adding a standard &lt;div&gt; element to a master page, and then position our cursor within it:&lt;/p&gt;    &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/scottgu/step2_41E13F98.png"&gt;&lt;img style="border-width: 0px; display: inline;" title="step2" alt="step2" src="http://weblogs.asp.net/blogs/scottgu/step2_thumb_0785C9B7.png" border="0" width="718" height="474" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;We are going to use the built-in &lt;asp:loginview&gt; control to help implement our scenario.  The &lt;asp:loginview&gt; control is a templated control (first introduced with ASP.NET 2.0) that allows us to easily switch between “Anonymous” and “LoggedIn” templates that automatically display depending on whether the user is authenticated.  Rather than type the &lt;asp:loginview&gt; markup manually, we’ll instead use the new snippet support in VS 2010.&lt;/p&gt;    &lt;p&gt;Typing in “&lt;log”&gt;    &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/scottgu/step3_74649D0A.png"&gt;&lt;img style="border-width: 0px; display: inline;" title="step3" alt="step3" src="http://weblogs.asp.net/blogs/scottgu/step3_thumb_779684F2.png" border="0" width="590" height="354" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;We’ll select the built-in “loginview” code snippet from the above list and hit the “tab” key to complete it:&lt;/p&gt;&lt;p&gt;Want to read full article, Go to&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/09/04/asp-net-html-javascript-snippet-support-vs-2010-and-net-4-0-series.aspx"&gt; Scott Blog&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Happy Reading&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-6837379928743721687?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/6837379928743721687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=6837379928743721687' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6837379928743721687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6837379928743721687'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/aspnet-html-javascript-snippet-support.html' title='ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-2228732606172021638</id><published>2009-09-06T19:40:00.000-07:00</published><updated>2009-09-06T19:40:00.068-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# Sharp Programming Basics Adding Sound - Part One</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/MespvNOLpbo&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/MespvNOLpbo&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-2228732606172021638?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/2228732606172021638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=2228732606172021638' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/2228732606172021638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/2228732606172021638'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/c-sharp-programming-basics-adding-sound.html' title='C# Sharp Programming Basics Adding Sound - Part One'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-3506748243050094221</id><published>2009-09-05T19:34:00.000-07:00</published><updated>2009-09-05T19:34:00.275-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Making a simple Calculator in C#(C sharp)</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/vVydBHPIzyY&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/vVydBHPIzyY&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-3506748243050094221?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/3506748243050094221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=3506748243050094221' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3506748243050094221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3506748243050094221'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/making-simple-calculator-in-cc-sharp.html' title='Making a simple Calculator in C#(C sharp)'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-8638384515738762908</id><published>2009-09-04T19:33:00.000-07:00</published><updated>2009-09-04T19:33:00.657-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>C# Tutorial: Writing If Statements and Boolean Tests</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/y-ALPuLW0OU&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/y-ALPuLW0OU&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-8638384515738762908?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/8638384515738762908/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=8638384515738762908' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8638384515738762908'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8638384515738762908'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/c-tutorial-writing-if-statements-and.html' title='C# Tutorial: Writing If Statements and Boolean Tests'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-3295048050052846812</id><published>2009-09-03T19:30:00.000-07:00</published><updated>2009-09-03T19:30:00.316-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>An Introduction to Test Driven Development in C#</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/f60aIlNhMoE&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/f60aIlNhMoE&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-3295048050052846812?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/3295048050052846812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=3295048050052846812' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3295048050052846812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3295048050052846812'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/introduction-to-test-driven-development.html' title='An Introduction to Test Driven Development in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-4487456577119917513</id><published>2009-09-02T19:29:00.000-07:00</published><updated>2009-09-02T19:29:00.161-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Inheriting from Forms in Visual Studio using C#</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/SKsI6cFcDY8&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/SKsI6cFcDY8&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-4487456577119917513?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/4487456577119917513/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=4487456577119917513' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4487456577119917513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4487456577119917513'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/inheriting-from-forms-in-visual-studio.html' title='Inheriting from Forms in Visual Studio using C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-6500429172761017469</id><published>2009-09-01T21:31:00.000-07:00</published><updated>2009-09-06T15:34:51.927-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SilverLight'/><title type='text'>What is new .NET RIA CTP2009 July?</title><content type='html'>&lt;p&gt;Here is a list of what is new in the July 2009 Preview:&lt;/p&gt;  &lt;p&gt;  &lt;br /&gt;1. A new and improved model for handling operations on the client – you can more easily specify callback/event for an operation, track its status and cancel it. &lt;br /&gt;&lt;!-- adsense --&gt;   &lt;br /&gt;2. Improved class library support    &lt;br /&gt;3. Extensibility points in generated code    &lt;br /&gt;4. Cleaner user model and better extensibility support for Application services    &lt;br /&gt;5. Better DomainDatasource capability for handling paging and updates.    &lt;br /&gt;6. Cleaner shared code support &lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;!-- adsense --&gt;&lt;/strong&gt;&lt;br /&gt;7. First wave of ADO.NET Data Services alignment (add a DomainService to DataService for writing app logic / expose DomainService as DataService).    &lt;br /&gt;8. Bug fixes and initial performance improvement on the server&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-6500429172761017469?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/6500429172761017469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=6500429172761017469' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6500429172761017469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6500429172761017469'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/what-is-new-net-ria-ctp2009-july.html' title='What is new .NET RIA CTP2009 July?'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-1177853682272234668</id><published>2009-09-01T19:25:00.000-07:00</published><updated>2009-09-01T19:25:00.107-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>How to use C# Events</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/PmZbk4eLr2A&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/PmZbk4eLr2A&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-1177853682272234668?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/1177853682272234668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=1177853682272234668' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1177853682272234668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1177853682272234668'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/how-to-use-c-events.html' title='How to use C# Events'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-4836920009396574275</id><published>2009-09-01T14:29:00.000-07:00</published><updated>2009-09-06T14:57:27.025-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>How to use Visual Inheritance in VS2010 .</title><content type='html'>How to use Visual Inheritance in VS2010?&lt;br /&gt;&lt;br /&gt;First of all i would like to explain a bit about the inheritance, Inheritance is one of the most important property of Object Oriented Programming language ,by which we reuse the code and extend the existing functionality where there is a relation of "IS A" exists in two classes . For example&lt;br /&gt;&lt;br /&gt;Lets take an example in C#&lt;br /&gt;&lt;!-- adsense --&gt;&lt;br /&gt;public class base&lt;br /&gt;{&lt;br /&gt;  public base(){&lt;br /&gt; &lt;br /&gt;  System.out.println("base class Constructor");&lt;br /&gt;}&lt;br /&gt;  public void print ()&lt;br /&gt;  {&lt;br /&gt;     System.out.println("Base Class");&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;public class derived :base&lt;br /&gt;{&lt;br /&gt;  public derived()&lt;br /&gt;  {&lt;br /&gt; &lt;br /&gt;   base.base();&lt;br /&gt;   System.out.println("derived class");&lt;br /&gt; &lt;br /&gt;  }&lt;br /&gt;  public void printEx(){&lt;br /&gt; &lt;br /&gt;   System.out.println("Printinng extended functionality");&lt;br /&gt; &lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This is how we use inheritance in C# but we are lacking this feature in Windows Forms applications where we want to reuse the existing windows forms to extend the functionality.This feature is available now in VS2010 where we can use our existing Win Form as base form to inherit from , thats called&lt;br /&gt;visual inheritance.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Steps to use Visual inheritance in VS2010&lt;br /&gt;&lt;br /&gt;1: Create a Windows Form project in VS2010&lt;br /&gt;2: By default one Win Form will be added with name Form1.cs or vb. whatever language you use for creating Win Apps&lt;br /&gt;3: Design this form&lt;br /&gt;4: Build the project so that DLL is build for this project&lt;br /&gt;5: Now add one more Win Form to project and select Inherited Form as given below in figure.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6LtjWBUswzw/Sp2WjE4SoqI/AAAAAAAAAOI/GzB2vCueomw/s1600-h/VisualInheritance.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 222px;" src="http://2.bp.blogspot.com/_6LtjWBUswzw/Sp2WjE4SoqI/AAAAAAAAAOI/GzB2vCueomw/s320/VisualInheritance.JPG" alt="" id="BLOGGER_PHOTO_ID_5376619059499672226" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;  Note : if you dont compile your Form1.cs than you will not be able to add Form1.cs as base form to inherit from.&lt;br /&gt;6: Now you will see that your Form2.cs will have all the controls of your base Form1.cs on your Form2.cs&lt;br /&gt;&lt;br /&gt;Now question arises, how to access the controls of base class ie Form1.cs.&lt;br /&gt;&lt;br /&gt;1: Best practices say that you should provide public getter and setter on the base class.&lt;br /&gt;or&lt;br /&gt;2: You can change the access modifier of base class(Form1.cs) control to Public or Protected as per your design .&lt;br /&gt;&lt;br /&gt;Now build the application and run it .&lt;br /&gt;&lt;br /&gt;Happy Coding.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-4836920009396574275?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/4836920009396574275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=4836920009396574275' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4836920009396574275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4836920009396574275'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/09/how-to-use-visual-inheritance-in-vs2010.html' title='How to use Visual Inheritance in VS2010 .'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_6LtjWBUswzw/Sp2WjE4SoqI/AAAAAAAAAOI/GzB2vCueomw/s72-c/VisualInheritance.JPG' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-8708107582267600301</id><published>2009-08-30T19:11:00.000-07:00</published><updated>2009-08-30T19:11:00.474-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Null Object Design Pattern in C#</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/hp1Y9bhail8&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/hp1Y9bhail8&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-8708107582267600301?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/8708107582267600301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=8708107582267600301' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8708107582267600301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8708107582267600301'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/null-object-design-pattern-in-c.html' title='Null Object Design Pattern in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-2262163303785994202</id><published>2009-08-29T16:51:00.000-07:00</published><updated>2009-08-29T16:51:00.420-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>How to use System Windows Forms in C#</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/n-STOWyG-z4&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/n-STOWyG-z4&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-2262163303785994202?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/2262163303785994202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=2262163303785994202' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/2262163303785994202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/2262163303785994202'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/how-to-use-system-windows-forms-in-c.html' title='How to use System Windows Forms in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-7953171791125577868</id><published>2009-08-28T16:50:00.000-07:00</published><updated>2009-08-28T16:50:00.369-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>What are Stacks &amp; Queues</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/QB0rJLFKXPg&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/QB0rJLFKXPg&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-7953171791125577868?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/7953171791125577868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=7953171791125577868' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7953171791125577868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7953171791125577868'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/what-are-stacks-queues.html' title='What are Stacks &amp; Queues'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-2956964357151869720</id><published>2009-08-27T16:49:00.000-07:00</published><updated>2009-08-27T16:49:00.811-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>How to use Windows Media in C#</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/WQARc_F34bM&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/WQARc_F34bM&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-2956964357151869720?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/2956964357151869720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=2956964357151869720' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/2956964357151869720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/2956964357151869720'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/how-to-use-windows-media-in-c.html' title='How to use Windows Media in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-3702544826121920365</id><published>2009-08-26T16:48:00.000-07:00</published><updated>2009-08-26T16:48:00.273-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>How to use Flash Objects in C#</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/_mH378IyJH8&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/_mH378IyJH8&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-3702544826121920365?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/3702544826121920365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=3702544826121920365' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3702544826121920365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3702544826121920365'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/how-to-use-flash-objects-in-c.html' title='How to use Flash Objects in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-4220166285413392148</id><published>2009-08-25T21:45:00.001-07:00</published><updated>2009-08-25T21:45:00.532-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SilverLight'/><title type='text'>What Silverlight Class Libraries developer should know ?</title><content type='html'>&lt;p&gt;In order to write practical code, you need to know quite a bit about the classes you have to    &lt;br /&gt;work with. That means acquiring a thorough knowledge of the core class libraries that ship     &lt;br /&gt;with Silverlight.     &lt;br /&gt;Silverlight includes a subset of the classes from the full .NET Framework. Although it     &lt;br /&gt;would be impossible to cram the entire .NET Framework into Silverlight—after all, it’s a 4MB     &lt;br /&gt;download that needs to support a variety of browsers and operating systems—Silverlight     &lt;br /&gt;includes a remarkable amount of functionality.     &lt;br /&gt;The Silverlight version of the .NET Framework is simplified in two ways. First, it doesn’t     &lt;br /&gt;provide the sheer number of types you’ll find in the full .NET Framework. Second, the classes     &lt;br /&gt;that it does include often don’t provide the full complement of constructors, methods, properties,     &lt;br /&gt;and events. Instead, Silverlight keeps only the most practical members of the most     &lt;br /&gt;important classes, which leaves it with enough functionality to create surprisingly compelling     &lt;br /&gt;code.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;• mscorlib.dll. This assembly is the Silverlight equivalent of the mscorlib.dll assembly    &lt;br /&gt;that includes the most fundamental parts of the .NET Framework. The Silverlight version     &lt;br /&gt;includes core data types, exceptions, and interfaces in the System namespace;     &lt;br /&gt;ordinary and generic collections; file management classes; and support for globalization,     &lt;br /&gt;reflection, resources, debugging, and multithreading.     &lt;br /&gt;• System.dll. This assembly contains additional generic collections, classes for dealing     &lt;br /&gt;with URIs, and classes for dealing with regular expressions.     &lt;br /&gt;• System.Core.dll. This assembly contains support for LINQ. The name of the assembly     &lt;br /&gt;matches the full .NET Framework, which implements new .NET 3.5 features in an     &lt;br /&gt;assembly named System.Core.dll.     &lt;br /&gt;• System.Net.dll. This assembly contains classes that support networking, allowing you     &lt;br /&gt;to download web pages and create socket-based connections.     &lt;br /&gt;• System.Windows.dll. This assembly includes many of the classes for building Silverlight     &lt;br /&gt;user interfaces, including basic elements, shapes and brushes, classes that     &lt;br /&gt;support animation and data binding, and a version of the OpenFileDialog that works     &lt;br /&gt;with isolated storage.     &lt;br /&gt;• System.Windows.Browser.dll. This assembly contains classes for interacting with     &lt;br /&gt;HTML elements.     &lt;br /&gt;• System.Xml.dll. This assembly includes the bare minimum classes you need for XML     &lt;br /&gt;processing: XmlReader and XmlWriter.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Thats all you need to know to write a Silver Light apps.&lt;/p&gt;  &lt;p&gt;Happy Coding.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-4220166285413392148?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/4220166285413392148/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=4220166285413392148' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4220166285413392148'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4220166285413392148'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/what-silverlight-class-libraries_25.html' title='What Silverlight Class Libraries developer should know ?'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-9175685592564148051</id><published>2009-08-25T21:45:00.000-07:00</published><updated>2009-08-25T21:45:00.040-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SilverLight'/><title type='text'>What Silverlight Class Libraries developer should know ?</title><content type='html'>&lt;p&gt;In order to write practical code, you need to know quite a bit about the classes you have to    &lt;br /&gt;work with. That means acquiring a thorough knowledge of the core class libraries that ship     &lt;br /&gt;with Silverlight.     &lt;br /&gt;Silverlight includes a subset of the classes from the full .NET Framework. Although it     &lt;br /&gt;would be impossible to cram the entire .NET Framework into Silverlight—after all, it’s a 4MB     &lt;br /&gt;download that needs to support a variety of browsers and operating systems—Silverlight     &lt;br /&gt;includes a remarkable amount of functionality.     &lt;br /&gt;The Silverlight version of the .NET Framework is simplified in two ways. First, it doesn’t     &lt;br /&gt;provide the sheer number of types you’ll find in the full .NET Framework. Second, the classes     &lt;br /&gt;that it does include often don’t provide the full complement of constructors, methods, properties,     &lt;br /&gt;and events. Instead, Silverlight keeps only the most practical members of the most     &lt;br /&gt;important classes, which leaves it with enough functionality to create surprisingly compelling     &lt;br /&gt;code.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;• mscorlib.dll. This assembly is the Silverlight equivalent of the mscorlib.dll assembly    &lt;br /&gt;that includes the most fundamental parts of the .NET Framework. The Silverlight version     &lt;br /&gt;includes core data types, exceptions, and interfaces in the System namespace;     &lt;br /&gt;ordinary and generic collections; file management classes; and support for globalization,     &lt;br /&gt;reflection, resources, debugging, and multithreading.     &lt;br /&gt;• System.dll. This assembly contains additional generic collections, classes for dealing     &lt;br /&gt;with URIs, and classes for dealing with regular expressions.     &lt;br /&gt;• System.Core.dll. This assembly contains support for LINQ. The name of the assembly     &lt;br /&gt;matches the full .NET Framework, which implements new .NET 3.5 features in an     &lt;br /&gt;assembly named System.Core.dll.     &lt;br /&gt;• System.Net.dll. This assembly contains classes that support networking, allowing you     &lt;br /&gt;to download web pages and create socket-based connections.     &lt;br /&gt;• System.Windows.dll. This assembly includes many of the classes for building Silverlight     &lt;br /&gt;user interfaces, including basic elements, shapes and brushes, classes that     &lt;br /&gt;support animation and data binding, and a version of the OpenFileDialog that works     &lt;br /&gt;with isolated storage.     &lt;br /&gt;• System.Windows.Browser.dll. This assembly contains classes for interacting with     &lt;br /&gt;HTML elements.     &lt;br /&gt;• System.Xml.dll. This assembly includes the bare minimum classes you need for XML     &lt;br /&gt;processing: XmlReader and XmlWriter.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Thats all you need to know to write a Silver Light apps.&lt;/p&gt;  &lt;p&gt;Happy Coding.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-9175685592564148051?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/9175685592564148051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=9175685592564148051' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/9175685592564148051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/9175685592564148051'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/what-silverlight-class-libraries.html' title='What Silverlight Class Libraries developer should know ?'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-3755502469263966614</id><published>2009-08-25T16:47:00.000-07:00</published><updated>2009-08-25T16:47:00.147-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>What is Inheritance</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Pon8mKJCH1I&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/Pon8mKJCH1I&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-3755502469263966614?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/3755502469263966614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=3755502469263966614' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3755502469263966614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3755502469263966614'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/what-is-inheritance.html' title='What is Inheritance'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-7446309888827387737</id><published>2009-08-24T21:40:00.000-07:00</published><updated>2009-08-24T21:40:00.156-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SilverLight'/><title type='text'>How to create Stand-Alone Silverlight Project</title><content type='html'>&lt;p&gt;The easiest way to start using Silverlight is to create an ordinary website with HTML pages and    &lt;br /&gt;no server-side code. Here’s how:&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;1. Select File ➤ New ➤ Project in Visual Studio, choose the Visual C# group of project     &lt;br /&gt;types, and select the Silverlight Application template. As usual, you need to pick a project     &lt;br /&gt;name and a location on your hard drive before clicking OK to create the project.     &lt;br /&gt;2. At this point, Visual Studio will prompt you to choose whether you want to create a     &lt;br /&gt;full-fledged ASP.NET website that can run server-side code or an ordinary website with     &lt;br /&gt;HTML pages .For now, choose the second option (“Automatically generates     &lt;br /&gt;a test page”) to create an ordinary website and click OK.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_6LtjWBUswzw/SpDI0OB6AKI/AAAAAAAAANw/XaO6rj0RMHI/s1600-h/SolutionExplorer%5B6%5D.jpg"&gt;&lt;img title="SolutionExplorer" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="283" alt="SolutionExplorer" src="http://lh5.ggpht.com/_6LtjWBUswzw/SpDI0nNiDpI/AAAAAAAAAN0/HlZID5V027I/SolutionExplorer_thumb%5B4%5D.jpg?imgmax=800" width="320" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Every Silverlight project starts with a small set of essential files, as shown in above Figure . All    &lt;br /&gt;the files that end with the extension .xaml use a flexible markup standard called XAML     &lt;br /&gt;. All the files that end with the extension .cs hold the C# source     &lt;br /&gt;code that powers your application.&lt;/p&gt;  &lt;p&gt;Here’s a rundown of the files created in project:    &lt;br /&gt;• App.xaml and App.xaml.cs. These files allow you to configure your Silverlight application.     &lt;br /&gt;They allow you to define resources that will be made available to all the pages in     &lt;br /&gt;your application ,and they allow you react to application events such as     &lt;br /&gt;startup, shutdown, and error conditions .In a newly generated project,     &lt;br /&gt;the startup code in the App.xaml.cs file specifies that your application should begin by     &lt;br /&gt;showing Page.xaml.     &lt;br /&gt;• Page.xaml. This file defines the user interface (the collection of controls, images, and     &lt;br /&gt;text) that will be shown for your first page. Technically, Silverlight pages are user     &lt;br /&gt;controls—custom classes that derive from UserControl. A Silverlight application can     &lt;br /&gt;contain as many pages as you need—to add more, simply choose Project ➤ Add New     &lt;br /&gt;Item, pick the Silverlight User Control template, choose a file name, and click Add.     &lt;br /&gt;• Page.xaml.cs. This file includes the code that underpins your first page, including the     &lt;br /&gt;event handlers that react to user actions.     &lt;br /&gt;Along with these four essential files, there are a few more ingredients that you’ll only find     &lt;br /&gt;if you dig around. Under the Properties node in the Solution Explorer, you’ll find a file named     &lt;br /&gt;AppManifest.xml, which lists the assemblies that your application uses. You’ll also find a file     &lt;br /&gt;named AssemblyInfo.cs, which contains information about your project (such as its name,     &lt;br /&gt;version, and publisher) that’s embedded into your Silverlight assembly when it’s compiled.     &lt;br /&gt;Neither of these files should be edited by hand—instead, they’re modified by Visual Studio     &lt;br /&gt;when you add references or set projects properties.&lt;/p&gt;  &lt;p&gt;Lastly, the gateway to your Silverlight application is an automatically generated but    &lt;br /&gt;hidden HTML file named TestPage.html . To see this file, make sure you’ve     &lt;br /&gt;compiled your application at least once. Then, click the Show All Files button at the top of the     &lt;br /&gt;Solution Explorer, and expand the Bin\Debug folder (which is where your application is compiled)&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Creating a Simple Silverlight Page&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As you’ve already learned, every Silverlight page includes a markup portion that defines the    &lt;br /&gt;visual appearance (the XAML file) and a source code file that contains event handlers. To customize     &lt;br /&gt;your first Silverlight application, you simply need to open the Page.xaml file and begin     &lt;br /&gt;adding markup.     &lt;br /&gt;Visual Studio gives you two ways to look at every XAML file—as a visual preview (known     &lt;br /&gt;as the design surface) or the underlying markup (known as the source view). By default, Visual     &lt;br /&gt;Studio shows both parts, stacked one on the other. Figure&amp;#160; shows this view and points out     &lt;br /&gt;the buttons you can use to change your vantage point.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_6LtjWBUswzw/SpDI1HgR-kI/AAAAAAAAAN4/9lXDXTvP144/s1600-h/HTMLPage%5B6%5D.jpg"&gt;&lt;img title="HTMLPage" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="175" alt="HTMLPage" src="http://lh3.ggpht.com/_6LtjWBUswzw/SpDI1v8cNZI/AAAAAAAAAN8/moMT6LI_tgU/HTMLPage_thumb%5B4%5D.jpg?imgmax=800" width="527" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;As you’ve no doubt guessed, you can start designing your XAML page by dragging controls    &lt;br /&gt;from the Toolbox and dropping them onto the design surface. However, this convenience     &lt;br /&gt;won’t save you from learning the full intricacies of XAML. In order to organize your elements     &lt;br /&gt;into the right layout containers, change their properties, wire up event handlers, and use Silverlight     &lt;br /&gt;features like animation, styles, templates, and data binding, you’ll need to edit the     &lt;br /&gt;XAML markup by hand.     &lt;br /&gt;To get started, you can try creating the page shown here, which defines a block of text and     &lt;br /&gt;a button. The portions in bold have been added to the basic page template that Visual Studio     &lt;br /&gt;generated when you created the project.     &lt;br /&gt;&amp;lt;UserControl x:Class=&amp;quot;SilverlightApplication1.Page&amp;quot;     &lt;br /&gt;xmlns=&amp;quot;&lt;a href="http://schemas.microsoft.com/client/2007&amp;quot;"&gt;http://schemas.microsoft.com/client/2007&amp;quot;&lt;/a&gt;     &lt;br /&gt;xmlns:x=&amp;quot;&lt;a href="http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;"&gt;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/a&gt;     &lt;br /&gt;Width=&amp;quot;400&amp;quot; Height=&amp;quot;100&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;Grid x:Name=&amp;quot;LayoutRoot&amp;quot; Background=&amp;quot;White&amp;quot;&amp;gt;     &lt;br /&gt;&amp;lt;StackPanel&amp;gt;     &lt;br /&gt;&amp;lt;TextBlock x:Name=&amp;quot;lblMessage&amp;quot; Text=&amp;quot;Hello world.&amp;quot;     &lt;br /&gt;Margin=&amp;quot;5&amp;quot;&amp;gt;&amp;lt;/TextBlock&amp;gt;     &lt;br /&gt;&amp;lt;Button x:Name=&amp;quot;cmdClickMe&amp;quot; Content=&amp;quot;Click Me!&amp;quot; Margin=&amp;quot;5&amp;quot;&amp;gt;&amp;lt;/Button&amp;gt;     &lt;br /&gt;&amp;lt;/StackPanel&amp;gt;     &lt;br /&gt;&amp;lt;/Grid&amp;gt;     &lt;br /&gt;&amp;lt;/UserControl&amp;gt;     &lt;br /&gt;This creates a page that has a stacked arrangement of two elements. On the top is a block     &lt;br /&gt;of text with a simple message. Underneath it is a button.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Adding Event Handling Code&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;    &lt;br /&gt;You attach event handlers to the elements in your page using attributes, which is the same     &lt;br /&gt;approach that developers take in WPF, ASP.NET, and JavaScript. For example, the Button element     &lt;br /&gt;exposes an event named Click that fires when the button is triggered with the mouse or     &lt;br /&gt;keyboard. To react to this event, you add the Click attribute to the Button element, and set it to     &lt;br /&gt;the name of a method in your code:     &lt;br /&gt;&amp;lt;Button x:Name=&amp;quot;cmdClickMe&amp;quot; Click=&amp;quot;cmdClickMe_Click&amp;quot; Content=&amp;quot;Click Me!&amp;quot;     &lt;br /&gt;Margin=&amp;quot;5&amp;quot;&amp;gt;&amp;lt;/Button&amp;gt;&lt;/p&gt;  &lt;p&gt;This example assumes that you’ve created an event handling method named cmd-    &lt;br /&gt;ClickMe_Click. Here’s what it looks like in the Page.xaml.cs file:     &lt;br /&gt;private void cmdClickMe_Click(object sender, RoutedEventArgs e)     &lt;br /&gt;{     &lt;br /&gt;lblMessage.Text = &amp;quot;Goodbye, cruel world.&amp;quot;;     &lt;br /&gt;}     &lt;br /&gt;You can’t coax Visual Studio into creating an event handler by double-clicking an element     &lt;br /&gt;or using the Properties window (as you can in other types of projects). However, once you’ve     &lt;br /&gt;added the event handler, you can use IntelliSense to quickly assign it to the right event. Begin     &lt;br /&gt;by typing in the attribute name, followed by the equal sign. At this point, Visual Studio will pop     &lt;br /&gt;up a menu that lists all the methods that have the right syntax to handle this event, and currently     &lt;br /&gt;exist in your code behind class. Simply choose the right event     &lt;br /&gt;handling method.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;You can also connect an event with code. The place to do it is the constructor for your    &lt;br /&gt;page, after the call to InitializeComponent(), which initializes all your controls. Here’s the code     &lt;br /&gt;equivalent of the XAML markup shown previously:     &lt;br /&gt;public Page()     &lt;br /&gt;{     &lt;br /&gt;InitializeComponent();     &lt;br /&gt;cmdClickMe.Click += cmdClickMe_Click;     &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;event handler at some point during the lifetime of your window. By comparison, the events    &lt;br /&gt;you hook up in XAML are always attached when the window object is first instantiated. The     &lt;br /&gt;code approach also allows you to keep your XAML simpler and more streamlined, which is     &lt;br /&gt;perfect if you plan to share it with non-programmers, such as a design artist. The drawback is     &lt;br /&gt;a significant amount of boilerplate code that will clutter up your code files.     &lt;br /&gt;If you want to detach an event handler, code is your only option. You can use the -= operator,     &lt;br /&gt;as shown here:     &lt;br /&gt;cmdClickMe.Click -= cmdClickMe_Click;     &lt;br /&gt;It is technically possible to connect the same event handler to the same event more than     &lt;br /&gt;once. This is almost always the result of a coding mistake. (In this case, the event handler will     &lt;br /&gt;be triggered multiple times.) If you attempt to remove an event handler that’s been connected     &lt;br /&gt;twice, the event will still trigger the event handler, but just once.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Testing a Silverlight Application      &lt;br /&gt;&lt;/strong&gt;You now have enough to test your Silverlight project. When you run a Silverlight application,     &lt;br /&gt;Visual Studio launches your default web browser and navigates to the hidden browser test     &lt;br /&gt;page, named TestPage.html. The test page creates a new Silverlight control and initializes it     &lt;br /&gt;using the markup in Page.xaml.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_6LtjWBUswzw/SpDI2WZY8kI/AAAAAAAAAOA/XKTrFAk4N5g/s1600-h/Output%5B3%5D.jpg"&gt;&lt;img title="Output" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="212" alt="Output" src="http://lh6.ggpht.com/_6LtjWBUswzw/SpDI2l0_6GI/AAAAAAAAAOE/nOvPyEHOwBM/Output_thumb%5B1%5D.jpg?imgmax=800" width="433" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Above Figure&amp;#160; shows the previous example at work. When you click the button, the event handling    &lt;br /&gt;code runs and the text changes. This process happens entirely on the client—there is no     &lt;br /&gt;need to contact the server or post back the page, as there is in a server-side programming     &lt;br /&gt;framework like ASP.NET. All the Silverlight code is executed on the client side by the scaleddown     &lt;br /&gt;version of .NET that’s embedded in the Silverlight plug-in.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-7446309888827387737?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/7446309888827387737/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=7446309888827387737' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7446309888827387737'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7446309888827387737'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/how-to-create-stand-alone-silverlight.html' title='How to create Stand-Alone Silverlight Project'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_6LtjWBUswzw/SpDI0nNiDpI/AAAAAAAAAN0/HlZID5V027I/s72-c/SolutionExplorer_thumb%5B4%5D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-3605247044399414107</id><published>2009-08-24T17:36:00.000-07:00</published><updated>2009-08-24T17:36:00.378-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>Insight into LINQ and its different components in .NET C# 3.5</title><content type='html'>&lt;p&gt;&lt;strong&gt;LINQ Components&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Because LINQ is so powerful, you should expect to see a lot of systems and products become LINQ     &lt;br /&gt;compatible. Virtually any data store would make a good candidate for supporting LINQ queries. This     &lt;br /&gt;includes databases, Microsoft’s Active Directory, the registry, the file system, an Excel file, and so on.     &lt;br /&gt;Following are the components for usage.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;strong&gt;LINQ to Objects&lt;/strong&gt;     &lt;br /&gt;LINQ to Objects is the name given to the IEnumerable&amp;lt;T&amp;gt; API for the Standard Query Operators. It is     &lt;br /&gt;LINQ to Objects that allows you to perform queries against arrays and in-memory data collections.     &lt;br /&gt;Standard Query Operators are the static methods of the static System.Linq.Enumerable class that you     &lt;br /&gt;use to create LINQ to Objects queries.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;strong&gt;LINQ to XML&lt;/strong&gt;     &lt;br /&gt;LINQ to XML is the name given to the LINQ API dedicated to working with XML. This interface was     &lt;br /&gt;previously known as XLinq in older prereleases of LINQ. Not only has Microsoft added the necessary     &lt;br /&gt;XML libraries to work with LINQ, it has addressed other deficiencies in the standard XML DOM, thereby     &lt;br /&gt;making it easier than ever to work with XML. Gone are the days of having to create an XmlDocument     &lt;br /&gt;just to work with a small piece of XML. To take advantage of LINQ to XML, you must have a reference to     &lt;br /&gt;the System.Xml.Linq.dll assembly in your project and have a using directive such as the following:     &lt;br /&gt;using System.Xml.Linq;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;strong&gt;LINQ to DataSet&lt;/strong&gt;     &lt;br /&gt;LINQ to DataSet is the name given to the LINQ API for DataSets. Many developers have a lot of existing     &lt;br /&gt;code relying on DataSets. Those who do will not be left behind, nor will they need to rewrite their     &lt;br /&gt;code to take advantage of the power of LINQ.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;strong&gt;LINQ to SQL&lt;/strong&gt;     &lt;br /&gt;LINQ to SQL is the name given to the IQueryable&amp;lt;T&amp;gt; API that allows LINQ queries to work with     &lt;br /&gt;Microsoft’s SQL Server database. This interface was previously known as DLinq in older prereleases     &lt;br /&gt;of LINQ. To take advantage of LINQ to SQL, you must have a reference to the System.Data.Linq.dll     &lt;br /&gt;assembly in your project and have a using directive such as the following:     &lt;br /&gt;using System.Data.Linq;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;strong&gt;LINQ to Entities&lt;/strong&gt;     &lt;br /&gt;LINQ to Entities is an alternative LINQ API that is used to interface with a database. It decouples the     &lt;br /&gt;entity object model from the physical database by injecting a logical mapping between the two. With&lt;/p&gt;  &lt;p&gt;this decoupling comes increased power and flexibility, as well as complexity. Because LINQ to Entities    &lt;br /&gt;appears to be outside the core LINQ framework, it is not covered in this book. However, if you find     &lt;br /&gt;that you need more flexibility than LINQ to SQL permits, it would be worth considering as an alternative.     &lt;br /&gt;Specifically, if you need looser coupling between your entity object model and database,     &lt;br /&gt;entity objects comprised of data coming from multiple tables, or more flexibility in modeling your     &lt;br /&gt;entity objects, LINQ to Entities may be your answer.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Happy Reading for more in-depth knowledge of LINQ&amp;#160; in future blogs.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-3605247044399414107?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/3605247044399414107/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=3605247044399414107' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3605247044399414107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3605247044399414107'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/insight-into-linq-and-its-different.html' title='Insight into LINQ and its different components in .NET C# 3.5'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-335786773017184346</id><published>2009-08-23T21:22:00.000-07:00</published><updated>2009-09-06T14:56:43.506-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SilverLight'/><title type='text'>What is relation between Silverlight and WPF</title><content type='html'>&lt;p&gt;&lt;strong&gt;Silverlight and WPF&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt; &lt;br /&gt;One of the most interesting aspects of Silverlight is the fact that it borrows the model WPF uses  &lt;br /&gt;for rich, client-side user interfaces.  &lt;br /&gt;WPF is a next-generation technology for creating Windows applications. It was introduced  &lt;br /&gt;in .NET 3.0 as the successor to Windows Forms. WPF is notable because it not only  &lt;br /&gt;simplifies development with a powerful set of high-level features, it also increases performance  &lt;br /&gt;by rendering everything through the DirectX pipeline. To learn about WPF, you can refer  &lt;br /&gt;to Pro WPF in C# 2008 (Apress, 2008).  &lt;br /&gt;Silverlight obviously can’t duplicate the features of WPF, because many of them rely deeply  &lt;br /&gt;on the capabilities of the operating system, including Windows-specific display drivers and  &lt;br /&gt;DirectX technology. However, rather than invent an entirely new set of controls and classes for  &lt;br /&gt;client-side development, Silverlight uses a subset of the WPF model. If you’ve had any experience  &lt;br /&gt;with WPF, you’ll be surprised to see how closely Silverlight resembles its big brother. Here  &lt;br /&gt;are a few common details:  &lt;br /&gt;• To define a Silverlight user interface (the collection of elements that makes up a Silverlight  &lt;br /&gt;content region), you use XAML markup, just as you do with WPF. You can even  &lt;br /&gt;map data to your display using the same data-binding syntax.  &lt;br /&gt;• Silverlight borrows many of the same basic controls from WPF, along with the same  &lt;br /&gt;styling system (for standardizing and reusing formatting), and a similar templating  &lt;br /&gt;mechanism (for changing the appearance of standard controls).  &lt;br /&gt;• To draw 2-D graphics in Silverlight, you use shapes, paths, transforms, geometries, and  &lt;br /&gt;brushes, all of which closely match their WPF equivalents.  &lt;br /&gt;• Silverlight provides a declarative animation model that’s based on storyboards, and  &lt;br /&gt;works in the same way as WPF’s animation system.  &lt;br /&gt;• To show video or play audio files, you use the MediaElement class, as you do in WPF.  &lt;br /&gt;Microsoft has made no secret about its intention to continue to expand the capabilities of  &lt;br /&gt;Silverlight by drawing from the full WPF model. In future Silverlight releases, you’re likely to  &lt;br /&gt;find that Silverlight borrows more and more features from WPF. This trend is already on display  &lt;br /&gt;with the shift from Silverlight 1 to Silverlight 2.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-335786773017184346?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/335786773017184346/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=335786773017184346' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/335786773017184346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/335786773017184346'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/what-is-relation-between-silverlight.html' title='What is relation between Silverlight and WPF'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-1915688511070121161</id><published>2009-08-23T16:46:00.000-07:00</published><updated>2009-08-23T16:46:00.088-07:00</updated><title type='text'>What is Encapsulation</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/uKD2R7TcivM&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/uKD2R7TcivM&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-1915688511070121161?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/1915688511070121161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=1915688511070121161' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1915688511070121161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1915688511070121161'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/what-is-encapsulation.html' title='What is Encapsulation'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-6507777614139808852</id><published>2009-08-23T15:38:00.000-07:00</published><updated>2009-08-23T15:38:00.319-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>How to query a SQL Server Database using LINQ</title><content type='html'>&lt;p&gt;This example queries standard Microsoft Northwind sample database&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;using System;      &lt;br /&gt;using System.Linq;       &lt;br /&gt;using System.Data.Linq;       &lt;br /&gt;using northwindEntity;       &lt;br /&gt;Northwind db = new Northwind(@&amp;quot;Data Source=.\SQLEXPRESS;Initial Catalog=Northwind&amp;quot;);       &lt;br /&gt;var custs =from c in db.Customers       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; where c.City == &amp;quot;Rio de Janeiro&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; select c;       &lt;br /&gt;foreach (var cust in custs)       &lt;br /&gt;Console.WriteLine(&amp;quot;{0}&amp;quot;, cust.CompanyName);&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You may need to change the connection string that is passed to the Northwind constructor in above code for the connection to be properly made. &lt;/p&gt;  &lt;p&gt;In the above given example, we are using System.linq and System.Data.Linq name spaces and our own NorthwindEntity namespace which contains the classes for northwind database.you u can see that I added a using directive for the northwindEntity namespace. For this example to work,you must use the entity framework class, or the Object Relational Designer, to generate entity classes for the targeted database, which in this example is the Microsoft Northwind sample database. . The generated entity classes are created in the northwindEntity namespace, which I specify when generating them. I then add the entity generated source module to my project and add the using directive for the northwindEntity namespace.&amp;#160; Rest of example is self explanatory.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Happy Coding.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-6507777614139808852?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/6507777614139808852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=6507777614139808852' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6507777614139808852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6507777614139808852'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/how-to-query-sql-server-database-using.html' title='How to query a SQL Server Database using LINQ'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-6586848724941007290</id><published>2009-08-22T21:18:00.000-07:00</published><updated>2009-08-22T21:19:26.099-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SilverLight'/><title type='text'>Comparision between Silverlight vs. Flash</title><content type='html'>&lt;p&gt;The most successful browser plug-in is Adobe Flash, which is installed on over 90 percent of    &lt;br /&gt;the world’s web browsers. Flash has a long history that spans more than ten years, beginning     &lt;br /&gt;as a straightforward tool for adding animated graphics and gradually evolving into a platform     &lt;br /&gt;for developing interactive content.     &lt;br /&gt;It’s perfectly reasonable for .NET developers to create websites that use Flash content.     &lt;br /&gt;However, doing so requires a separate design tool, and a completely different programming     &lt;br /&gt;language (ActionScript) and programming environment (Flex). Furthermore, there’s no     &lt;br /&gt;straightforward way to integrate Flash content with server-side .NET code. For example, creating     &lt;br /&gt;Flash applications that call .NET components is awkward at best. Using server-side .NET     &lt;br /&gt;code to render Flash content (for example, a custom ASP.NET control that spits out a Flash     &lt;br /&gt;content region) is far more difficult.&lt;/p&gt;  &lt;p&gt;Silverlight aims to give .NET developers a better option for creating rich web content.    &lt;br /&gt;Silverlight provides a browser plug-in with many similar features to Flash, but one that’s     &lt;br /&gt;designed from the ground up for .NET. Silverlight natively supports the C# language and     &lt;br /&gt;embraces a range of .NET concepts. As a result, developers can write client-side code for Silverlight     &lt;br /&gt;in the same language they use for server-side code (such as C# and VB), and use many     &lt;br /&gt;of the same abstractions (including streams, controls, collections, generics, and LINQ).     &lt;br /&gt;The Silverlight plug-in has an impressive list of features, some of which are shared in     &lt;br /&gt;common with Flash, and a few of which are entirely new and even revolutionary. Here are     &lt;br /&gt;some highlights:     &lt;br /&gt;• &lt;strong&gt;2-D drawing&lt;/strong&gt;. &lt;/p&gt;  &lt;p&gt;Silverlight provides a rich model for 2-D drawing. Best of all, the content    &lt;br /&gt;you draw is defined as shapes and paths, so you can manipulate this content on the     &lt;br /&gt;client side. You can even respond to events (like a mouse click on a portion of a     &lt;br /&gt;graphic), which makes it easy to add interactivity to anything you draw.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;• &lt;strong&gt;Controls&lt;/strong&gt;. &lt;/p&gt;  &lt;p&gt;Developers don’t want to reinvent the wheel, so Silverlight is stocked with a    &lt;br /&gt;few essentials, including buttons, text boxes, lists, and a grid. Best of all, these basic     &lt;br /&gt;building blocks can be restyled with custom visuals if you want all of the functionality     &lt;br /&gt;but none of the stock look.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;• &lt;strong&gt;Animation&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;Silverlight has a time-based animation model that lets you define what    &lt;br /&gt;should happen and how long it should take. The Silverlight plug-in handles the sticky     &lt;br /&gt;details, like interpolating intermediary values and calculating the frame rate.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;• &lt;strong&gt;Media.&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;Silverlight provides playback of Windows Media Audio (WMA), Windows Media    &lt;br /&gt;Video (WMV7–9), MP3 audio, and VC-1 (which supports high definition). You aren’t     &lt;br /&gt;tied to the Windows Media Player ActiveX control or browser plug-in—instead, you     &lt;br /&gt;can create any front-end you want, and you can even show video in full-screen mode.     &lt;br /&gt;Microsoft also provides a free companion hosting service (at &lt;a href="http://silverlight.live"&gt;http://silverlight.live&lt;/a&gt;.     &lt;br /&gt;com) that gives you space to store media files. Currently, it offers a generous 10 GB.&lt;/p&gt;  &lt;p align="justify"&gt;   &lt;br /&gt;• &lt;strong&gt;The common language runtime&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;Most impressively, Silverlight includes a scaled-down    &lt;br /&gt;version of the CLR, complete with an essential set of core classes, a garbage collector, a     &lt;br /&gt;JIT (just-in-time) compiler, support for generics, threading, and so on. In many cases,     &lt;br /&gt;developers can take code written for the full .NET CLR and use it in a Silverlight application     &lt;br /&gt;with only moderate changes.&lt;/p&gt;  &lt;p&gt;• &lt;strong&gt;Networking.&lt;/strong&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Silverlight applications can call old-style ASP.NET web services (.asmx) or    &lt;br /&gt;WCF (Windows Communication Foundation) web services. They can also send manually     &lt;br /&gt;created XML requests over HTTP and even open direct socket connections for fast     &lt;br /&gt;two-way communication. This gives developers a great way to combine rich client-side     &lt;br /&gt;code with secure server-side routines.&lt;/p&gt;  &lt;p align="justify"&gt;   &lt;br /&gt;• &lt;strong&gt;Data binding&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;Although it’s not as capable as its big brother, WPF, Silverlight data binding    &lt;br /&gt;provides a convenient way to display large amounts of data with minimal code. You     &lt;br /&gt;can pull your data from XML or in-memory objects, giving you the ability to call a web     &lt;br /&gt;service, receive a collection of objects, and display their data in a web page—often with     &lt;br /&gt;just a couple of lines of code.     &lt;br /&gt;Of course, it’s just as important to note what Silverlight doesn’t include. Silverlight is a new     &lt;br /&gt;technology that’s evolving rapidly, and it’s full of stumbling blocks for developers who are used     &lt;br /&gt;to relying on .NET’s rich libraries of prebuilt functionality. Prominent gaps include a lack of     &lt;br /&gt;database support (there’s no ADO.NET), no support for 3-D drawing, no printing, no command     &lt;br /&gt;model, and few rich controls like trees and menus (although many developers and     &lt;br /&gt;component companies are building their own). All of these features are available in Windowscentric     &lt;br /&gt;WPF applications, and they may someday migrate to the Silverlight universe—or not.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-6586848724941007290?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/6586848724941007290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=6586848724941007290' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6586848724941007290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6586848724941007290'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/comparision-between-silverlight-vs.html' title='Comparision between Silverlight vs. Flash'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-3012578038976299272</id><published>2009-08-22T16:46:00.000-07:00</published><updated>2009-08-22T16:46:00.141-07:00</updated><title type='text'>What is Polymorphism?</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/3QNL8FAd2bw&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/3QNL8FAd2bw&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-3012578038976299272?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/3012578038976299272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=3012578038976299272' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3012578038976299272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3012578038976299272'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/what-is-polymorphism.html' title='What is Polymorphism?'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-4446645961441234234</id><published>2009-08-22T15:21:00.000-07:00</published><updated>2009-08-22T15:29:07.555-07:00</updated><title type='text'>Query XML using LINQ</title><content type='html'>&lt;p align="justify"&gt;Query XML    &lt;br /&gt;Example below given shows that how easy it is to&amp;#160; displays the ease with which one     &lt;br /&gt;can interact with and query Extensible Markup Language (XML) data utilizing the LINQ to XML API.     &lt;br /&gt;You should pay particular attention to how I construct the XML data into an object named books that     &lt;br /&gt;I can programmatically interact with.&lt;/p&gt;  &lt;p align="justify"&gt;   &lt;br /&gt;A Simple XML Query Using LINQ to XML&lt;/p&gt;  &lt;p align="justify"&gt;   &lt;br /&gt;using System;     &lt;br /&gt;using System.Linq;     &lt;br /&gt;using System.Xml.Linq;&lt;/p&gt;  &lt;p align="justify"&gt;XElement books = XElement.Parse(    &lt;br /&gt;@&amp;quot;&amp;lt;books&amp;gt;     &lt;br /&gt;&amp;lt;book&amp;gt;     &lt;br /&gt;&amp;lt;title&amp;gt;Learn Integrated Query in C#&amp;#160; 2008&amp;lt;/title&amp;gt;     &lt;br /&gt;&amp;lt;author&amp;gt;Kulveer Singh&amp;lt;/author&amp;gt;     &lt;br /&gt;&amp;lt;/book&amp;gt;     &lt;br /&gt;&amp;lt;book&amp;gt;     &lt;br /&gt;&amp;lt;title&amp;gt;Pro WF: Windows Workflow in .NET 3.0&amp;lt;/title&amp;gt;     &lt;br /&gt;&amp;lt;author&amp;gt;Bill Gates&amp;lt;/author&amp;gt;     &lt;br /&gt;&amp;lt;/book&amp;gt;     &lt;br /&gt;&amp;lt;book&amp;gt;     &lt;br /&gt;&amp;lt;title&amp;gt;Learn how to make Money &amp;lt;/title&amp;gt;     &lt;br /&gt;&amp;lt;author&amp;gt;MoneyMaker&amp;lt;/author&amp;gt;     &lt;br /&gt;&amp;lt;/book&amp;gt;     &lt;br /&gt;&amp;lt;/books&amp;gt;&amp;quot;);     &lt;br /&gt;var titles = from book in books.Elements(&amp;quot;book&amp;quot;)     &lt;br /&gt;where (string) book.Element(&amp;quot;author&amp;quot;) == &amp;quot;Joe Rattz&amp;quot;     &lt;br /&gt;select book.Element(&amp;quot;title&amp;quot;);     &lt;br /&gt;foreach(var title in titles)     &lt;br /&gt;Console.WriteLine(title.Value);&lt;/p&gt;  &lt;p align="justify"&gt;Namespace system.linq and system.xml.linq are included to run this example. which is required by linq to run.Did you notice how I parsed the XML data into an object of type XElement? Nowhere did I create an XmlDocument. Among the benefits of LINQ to XML are the extensions made to the XML API. Now instead of being XmlDocument-centric as the W3C Document Object Model (DOM) XML API requires,LINQ to XML allows the developer to interact at the element level using the XElement class.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-4446645961441234234?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/4446645961441234234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=4446645961441234234' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4446645961441234234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4446645961441234234'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/query-xml-using-linq.html' title='Query XML using LINQ'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-5229755554800659623</id><published>2009-08-21T16:45:00.000-07:00</published><updated>2009-08-21T16:45:00.417-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>HashTable in C#</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/_JE10HVCtvU&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/_JE10HVCtvU&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-5229755554800659623?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/5229755554800659623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=5229755554800659623' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/5229755554800659623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/5229755554800659623'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/hashtable-in-c.html' title='HashTable in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-7750721168603406621</id><published>2009-08-20T16:43:00.000-07:00</published><updated>2009-08-20T16:43:00.194-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Base Classes &amp; Base Keyword in C#</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/vWaxirwe8fo&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/vWaxirwe8fo&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-7750721168603406621?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/7750721168603406621/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=7750721168603406621' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7750721168603406621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7750721168603406621'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/base-classes-base-keyword-in-c.html' title='Base Classes &amp; Base Keyword in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-5426236946930778594</id><published>2009-08-19T16:42:00.000-07:00</published><updated>2009-08-19T16:43:12.988-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Interface in C# Part2</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/oSpxItSswZk&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/oSpxItSswZk&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-5426236946930778594?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/5426236946930778594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=5426236946930778594' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/5426236946930778594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/5426236946930778594'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/interface-in-c-part2.html' title='Interface in C# Part2'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-6653628901151227327</id><published>2009-08-19T16:41:00.000-07:00</published><updated>2009-08-19T16:42:05.065-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Interfaces in C#</title><content type='html'>&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/VjZjjw97oiU&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/VjZjjw97oiU&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-6653628901151227327?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/6653628901151227327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=6653628901151227327' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6653628901151227327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6653628901151227327'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/interfaces-in-c.html' title='Interfaces in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-8608305720184173368</id><published>2009-08-11T13:14:00.000-07:00</published><updated>2009-08-11T13:14:00.221-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>How to use Collections in C#</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/YQwEz7h5ubQ&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/YQwEz7h5ubQ&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-8608305720184173368?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/8608305720184173368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=8608305720184173368' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8608305720184173368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8608305720184173368'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/how-to-use-collections-in-c.html' title='How to use Collections in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-6260240799265759412</id><published>2009-08-10T08:20:00.000-07:00</published><updated>2009-08-10T08:20:00.331-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='nHibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>nHibernate ( Part 3)</title><content type='html'>&lt;span id="ctl00_cphContent_repArticle_ctl00_lblBody"&gt;&lt;p align="left"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Introduction: &lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;In the last article we saw that how we can insert the data into the database using only few lines and without stored procedures. In this article we will look at some of the other cool features of NHibernate. &lt;/span&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Retrieving a single record from the database: &lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;You can easily retrieve a single record for a particular person based on the primary key. Just send in the primary key and you will be returned the object of the record. &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber1" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;void&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Button1_Click(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; sender, System.EventArgs e)&lt;/span&gt;  &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;Configuration cfg = &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; Configuration(); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;cfg.AddAssembly("WebApplication1"); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;ISessionFactory factory = cfg.BuildSessionFactory(); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;ISession session = factory.OpenSession(); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;&lt;span style="font-family:Courier New;"&gt;Person person = (Person) session.Load(&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;(Person),1); &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;span style="font-size:78%;"&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;Response.Write(person.Name); &lt;/span&gt;&lt;/p&gt;   &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/span&gt; &lt;p&gt; &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;I have made the important line in bold. We are using session.Load method and sending the object type and the id of the object to pick up. In our database the id '1' belongs to 'Azam' and hence the object returned will contain information about Azam. &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber2" style="border-collapse: collapse;color:#111111;" width="100%" border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;It is important to note that we are sending the 'PersonID' to the session.Load method and hence retrieving the live object. PersonID is also primary key in our database and an identity column. Since its an identity column we do not provide the set accessor in the PersonID property. But session.Load method requires that PersonID must have a set accessor in order to retrieve the record. In real application scenario you should have some other primary key like email or username so that you don't have to assign the identity column. &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="left"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Retrieving collection of objects: &lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;You can also easily retrieve collection of objects. In the code below we are retrieving all the data from the table 'Person' and binding it to the datagrid. &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber3" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;void&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Button2_Click(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; sender, System.EventArgs e)&lt;/span&gt;  &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;Configuration cfg = &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; Configuration(); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;cfg.AddAssembly("WebApplication1"); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;ISessionFactory factory = cfg.BuildSessionFactory(); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;ISession session = factory.OpenSession(); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;IList personList = session.CreateCriteria(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;(Person)).List(); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;DataGrid1.DataSource = personList; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;DataGrid1.DataBind(); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="left"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Retrieving objects based on Expression: &lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;We can also retrieve objects based on Expressions. If we want to retrieve record of a Person whose name is 'Azam' we will just write something like: &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber4" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;IList personList = session.CreateCriteria(&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="font-size:85%;"&gt;(Person)).Add(NHibernate.Expression.Expression.Eq("Name","Azam&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;")).List();&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;In the above line we are simply adding an Expression just like the where clause in T-SQL. 'Eq' means Equal hence we are retrieving all the records where the property 'Name' is 'Azam'. It will return us with one record since there is only one record in the database with the name Azam. &lt;/span&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;You can also change the order of the rows retrieved. The order can be Ascending or Descending. In the code below I am retrieving the whole list and ordering them on the basis of the "Name" property in ascending order: &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber8" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;IList personList = session.CreateCriteria(&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;(Person)).AddOrder(NHibernate.Expression.Order.Asc("Name")).List();&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;If you have been working with T-SQL you should know that the 'IN' operator is one of the most important operators. Luckily we can use the 'IN' operator using NHibernate. The following code will return you the data of all the Person whose name is in the ArrayList. You can use any collection which implements the ICollection interface. I used Arraylist since it inherits the ICollection interface.  &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber9" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;ArrayList myList = &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt; ArrayList(); &lt;/span&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;myList.Add("Azam"); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;myList.Add("Ali"); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;IList personList = session.CreateCriteria(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;(Person)).Add(NHibernate.Expression.Expression.In("Name",myList)).List();&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="left"&gt;    &lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;You can also retrieve the results based on a certain range. Suppose you want all the people who work between two dates than you can use the following line. &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber4" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;IList personList = session.CreateCriteria(&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;(Person)).Add(NHibernate.Expression.Expression.&lt;b&gt;Between&lt;/b&gt;("DateStarted",&lt;/span&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt; DateTime(2005,01,01),&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; DateTime(2005,12,01))).List();&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;As you can see that now we are using the "Between" operator. There are lots of other operators that you can use depending on your need. &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber5" style="border-collapse: collapse;color:#111111;" width="100%" border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Please note that I have included two new properties "DateCreated" and "DateEnded" in Person.cs file which maps to the two new fields "StartDate" and "EndDate" in the database. &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="left"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Searching using NHibernate:  &lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Searching is also very easy using NHibernate. Basically you just need to search in the collection and if the record with a particular search key is found you can take the appropriate action. In the code below we are searching for a Person name "Azam". If the person is found than a message is printed on the screen saying that "Person is found". &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber6" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;IList personList = session.CreateCriteria(&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;(Person)).List(); &lt;/span&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;foreach&lt;/span&gt;&lt;span style="font-size:85%;"&gt;(Person person &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;in&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; personList) &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;if&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;(person.Name.Equals("Azam")) &lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;Response.Write("Azam is in the list");&lt;/span&gt;&lt;/p&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;break&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;else&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;{ Response.Write("Azam is not in the list"); } &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;You can also change the object properties and update it easily. Suppose that you want to change the date of the Person name "Azam" which is contained in the collection. Let's see how we can do this: &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber7" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;IList personList = session.CreateCriteria(&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;typeof&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;(Person)).List(); &lt;/span&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;foreach&lt;/span&gt;&lt;span style="font-size:85%;"&gt;(Person person &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;in&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; personList) &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;if&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;(person.Name.Equals("Azam")) &lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-size:85%;"&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;person.DateStarted = DateTime.Now;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;person.DateEnded = DateTime.Now;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;session.Flush();&lt;/span&gt;&lt;/p&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;break&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;else&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;{ Response.Write("Azam is not in the list"); } &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;As you can see above that we are simply finding the right person using the name property of the object. And than assigning the new Dates to the object and finally to make the changes we flush the session so that the changes appear in the database. &lt;/span&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;95% of all the operations that you can perform using T-SQL can be performed by using NHibernate classes. &lt;/span&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Happy coding ! &lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-6260240799265759412?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/6260240799265759412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=6260240799265759412' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6260240799265759412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6260240799265759412'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/nhibernate-part-3.html' title='nHibernate ( Part 3)'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-1515685096416152457</id><published>2009-08-09T08:19:00.000-07:00</published><updated>2009-08-09T08:19:00.100-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='nHibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>nHibernate (Part2)</title><content type='html'>&lt;span id="ctl00_cphContent_repArticle_ctl00_lblBody"&gt;&lt;p align="left"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Introduction:&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;I know you all must be really anxious to find out that how NHibernate works and how it can make your life easier. In this article we will look at the add feature of the NHibernate. I will go step by step so you understand what is going on. &lt;/span&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Making a Class Library: &lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;The first task is to create a class library which will be mapped using the NHibernate. So, lets make a simple class User. &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber1" style="border-collapse: collapse;color:#111111;" width="100%" border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%" bg style="color:#c0c0c0;"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; User&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt; &lt;/span&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; personID; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; email; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; password; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; status; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; DateTime dateCreated; &lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#008000;"&gt;// Defining properties &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; PersonID &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;get&lt;/span&gt;&lt;span style="font-size:85%;"&gt; { &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; personID; }&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;set&lt;/span&gt;&lt;span style="font-size:85%;"&gt; { personID = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;value&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;; }&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; Email &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;get&lt;/span&gt;&lt;span style="font-size:85%;"&gt; { &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; email; }&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;set&lt;/span&gt;&lt;span style="font-size:85%;"&gt; { email = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;value&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;; }&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; Password &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;get&lt;/span&gt;&lt;span style="font-size:85%;"&gt; { &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; password; } &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;set&lt;/span&gt;&lt;span style="font-size:85%;"&gt; { password = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;value&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;; }&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:78%;"&gt; &lt;p&gt; &lt;/p&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;bool&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; Status &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;get&lt;/span&gt;&lt;span style="font-size:85%;"&gt; { &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; status; } &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;set&lt;/span&gt;&lt;span style="font-size:85%;"&gt; { status = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;value&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;; } &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; DateTime DateCreated &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;get&lt;/span&gt;&lt;span style="font-size:85%;"&gt; { &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; dateCreated; }&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;set&lt;/span&gt;&lt;span style="font-size:85%;"&gt; { dateCreated = &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;value&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;; }&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;As you can see that there is nothing special about the class. It has some private variables which you can access using the properties. All of this has been explained in my articles before. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;NOTE:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt; &lt;table id="AutoNumber2" style="border-collapse: collapse;color:#111111;" width="100%" border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;All these properties will map to the database fields. That's why I have created the database script file for you. Just run the script file using query analyzer and it will create table for you. If it does not work than you can easily create a table based on the properties above.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;    &lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Creating Mapping File:&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Now let's take a look at the mapping file for the User.cs class. This mapping file is called (User.hbm.xml). It's a good idea to name the mapping file based on the class name. &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber3" style="border-collapse: collapse;color:#111111;" width="100%" border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%" bg style="color:#c0c0c0;"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;&lt;?&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#800000;"&gt;xml&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="1.0"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="utf-8"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;?&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt; &lt;/span&gt; &lt;p&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#800000;"&gt;hibernate-mapping&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;="urn:nhibernate-mapping-2.0"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size:85%;color:#800000;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="&lt;b&gt;Glasses.Test.User&lt;/b&gt;, &lt;b&gt;Glasses&lt;/b&gt;"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;table&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;="&lt;b&gt;Person&lt;/b&gt;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size:85%;color:#800000;"&gt;id&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="&lt;b&gt;PersonID&lt;/b&gt;"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;column&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="&lt;b&gt;PersonID&lt;/b&gt;"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="Int32"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;length&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="4"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;unsaved-value&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;b&gt;="0"&lt;/b&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size:85%;color:#800000;"&gt;generator&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;class&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;=&lt;b&gt;"identity"&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size:85%;color:#800000;"&gt;id&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size:85%;color:#800000;"&gt;property&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="Email"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;column&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;=&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;"Email"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="String"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;length&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="50"/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size:85%;color:#800000;"&gt;property&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="Password"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="String"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;length&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="50"/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size:85%;color:#800000;"&gt;property&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="Status"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="Boolean"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;length&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;="1"/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size:85%;color:#800000;"&gt;property&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;="DateCreated"&lt;/span&gt;&lt;span style="font-size:85%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#ff0000;"&gt;type&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;="DateTime"/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size:85%;color:#800000;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;&lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#800000;"&gt;hibernate-mapping&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Let's take a look at the mapping file now. &lt;/span&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Glasses.Test.User is the name of the class that I am using. Glasses is the name of the assembly, Test is the name of the folder and finally user is the class. &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Person is the name of the table&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;identity means that PersonID is the identity (Automatically generated) column in the database and we don't have to supply it.&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;The &lt;property&gt; tags contain name which is the name of the property in the User.cs class. &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;column is the "database" column. &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Note:&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;table id="AutoNumber4" style="border-collapse: collapse;color:#111111;" width="100%" border="2" border cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Make sure that the mapping file is configured as the "Embedded Resource". Right click on the "User.hbm.xml" file and select properties and set build option to "Embedded Resource". &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Add Method Code:&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Now let's see the Add method that adds the user object into the database. In future articles we will implement an interface and inherit from that interface to get the common functionality. But for now let's look at the easy way to add the object. &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber5" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0" height="367"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%" height="367"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;static&lt;/span&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt; Add(User user) &lt;/span&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#008000;"&gt;// make the configuration file &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;Configuration cfg = &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt; Configuration(); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;cfg.AddAssembly("Glasses"); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;ISessionFactory factory = cfg.BuildSessionFactory(); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;ISession session = factory.OpenSession(); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;ITransaction transaction = session.BeginTransaction(); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;session.Save(user); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;transaction.Commit(); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;session.Close(); &lt;/span&gt;&lt;/p&gt;&lt;/span&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;ul&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;First we are making a Configuration object cfg &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;We load the assembly using the AddAssembly method&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;ISessionFactory interface creates a session factory which can be used to create sessions. &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;ISession interface is used to create independent session which is opened by using the factory.OpenSession() method&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Once the session has been open than it means that you can communicate with the database. &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;ITransaction interface which begines the session transactions.&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;session.Save(user) is used to save the session.&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;transaction.Commit() is used to save the data to the database. &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;session.Close() finally closes the session. &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;The Client Code:&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;The Client code is pretty simple and self explanatory. &lt;/span&gt;&lt;/p&gt; &lt;table id="AutoNumber5" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0" height="367"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width="100%" height="367"&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;void&lt;/span&gt;&lt;span style="font-size:85%;"&gt; Button1_Click(&lt;/span&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt; sender, System.EventArgs e) &lt;/span&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;User user = &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt; User(); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;user.Email = "codersource@source.net"; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;user.Password = "mypassword"; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;user.Status = &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#0000ff;"&gt;true&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;user.DateCreated = DateTime.Now; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;Test.User.Add(user); &lt;/span&gt;&lt;/p&gt;&lt;/span&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Don't wait now and check your database. A new entry should be added if you have done everything right. Isn't this the coolest thing ever. In the upcoming articles we will see more features of NHibernate. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;I hope you enjoyed the article. Happy programming !    &lt;/span&gt;&lt;/p&gt;&lt;/span&gt;      &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-1515685096416152457?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/1515685096416152457/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=1515685096416152457' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1515685096416152457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1515685096416152457'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/nhibernate-part2.html' title='nHibernate (Part2)'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-4539452654341506860</id><published>2009-08-08T08:17:00.000-07:00</published><updated>2009-08-08T08:17:00.372-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='nHibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Introduction to Object Relational  Mapping with nHibernate (Part1)</title><content type='html'>&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;span id="ctl00_cphContent_repArticle_ctl00_lblTitle"&gt;This is an article series in which I will talk about using O/R Mapping. O/R Mapping can ease your life since you don't have to write those hefty stored procedures to access database. O/R Mapping will also put an end to using datasets in your applications. In the first part of the article I will just discuss that why we need O/R Mapping and what it is all about. The fun part (coding) and seeing mapping in action will start from the next article. This is Edited ! &lt;/span&gt; &lt;/span&gt; &lt;br /&gt;  &lt;span id="ctl00_cphContent_repArticle_ctl00_lblBody"&gt;		&lt;!--StartFragment --&gt;   &lt;p align="left"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Introduction:&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;We all are familiar with datasets which is a carrier used to carry data from one layer to another. In my previous article I described some of the pitfalls of using datasets. Datasets are most commonly used when we are accessing database. The common pattern of accessing data from the database is given in the following steps: &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;1) Make connection to the database&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;2) Make DataAdapter &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;3) Execute commands using dataadapter or command objects using stored procedures or Ad-hoc queries. &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;4) Fill the dataset using dataadapter &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;5) Bind dataset to the control on the webform. &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;The above procedure does not look that long but consider doing this over and over and over again. What will happen when some database field you misspelled and now its occurring in 200 stored procedures. You need to tell your Boss that you need a week or even more to fix this simple spelling problem. Not only that but migration can also be a big problem. If you have a stored procedure that takes 5 seconds to execute (Although 5 seconds is too long) and some one tweaked the procedure so now it runs in &lt;&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;What if I told you that you can insert, delete, update, edit in other words perform all type of database operations without executing any SQL at all. This seems impossible and kind of a crazy thought but this is what O/R Mapping is all about. O/R Mapping also known as Object Relationship Mapping which allows us to map our data in file(s) and use those mapping files to retrieve or add data to the database. The main idea behind the O/R Mappings is relationships. Consider the following query: &lt;/span&gt;&lt;/p&gt;&lt;table id="AutoNumber1" style="border-collapse: collapse;color:#111111;" width="100%" bg border="2" border cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td width="100%"&gt;&lt;p align="left"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;SELECT Person.Name, Person.Email FROM Person,Customer &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;WHERE Person.PersonID = Customer.CustomerID&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;As you can see that Person table and the Customer table has relationship between them which let's them perform different actions. Just in the same way O/R mapping is also relationships and these relationships can be created in files. &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;There are many O/R Mappers available to download. Some are free and some are pretty expensive. In this article and for the rest of the series we will be looking at the NHibernate O/R Mapper which is a free and open source. You can download the NHibernate O/R Mapper from &lt;a href="http://nhibernate.sourceforge.net/"&gt;http://nhibernate.sourceforge.net/&lt;/a&gt; . &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Here is a list of different O/R Mappers (&lt;a href="http://blog.hundhausen.com/PermaLink.aspx?guid=4c0b610f-46a6-41e4-9635-a582fde8a0fc"&gt;List of O/R Mappers&lt;/a&gt;)  &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;When not to use O/R Mapping:&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;You should not use O/R Mapping when your business logic is dependent on complex stored procedures. Having said so if you have business logic implemented in stored procedures than you have another thing coming :). Almost 95% of all the stored procedures that you write can be represented by O/R Mapping.  &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;u&gt;&lt;b&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Installing NHibernate:&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Installation is pretty simple. I assume you downloaded the Zip file from &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=73818"&gt;http://sourceforge.net/project/showfiles.php?group_id=73818&lt;/a&gt;. Once you done downloading simply extract it on your hard drive. It will have different folders inside the main directory, some of those folders contains the code and some have different type of files. Your concern will be the .dll files in the bin directory.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-4539452654341506860?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/4539452654341506860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=4539452654341506860' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4539452654341506860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4539452654341506860'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/introduction-to-object-relational.html' title='Introduction to Object Relational  Mapping with nHibernate (Part1)'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-8374478654121039084</id><published>2009-08-07T08:09:00.000-07:00</published><updated>2009-08-07T08:09:00.607-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Loading User Control Dynamically in C#</title><content type='html'>&lt;span style=";font-family:Arial;font-size:85%;"  &gt; &lt;b&gt;Abstract:&lt;/b&gt;&lt;br /&gt;&lt;span id="ctl00_cphContent_repArticle_ctl00_lblTitle"&gt;User Controls are great in ASP.NET. They let us divide the page into small sections. You can easily use User Controls on a ASP.NET page by simply dragging and dropping the control from the solution explorer. Sometimes we need to load the User Control dynamically. In this small article we will learn how to load the User Control dynamically.&lt;/span&gt; &lt;/span&gt;&lt;br /&gt; &lt;span id="ctl00_cphContent_repArticle_ctl00_lblBody"&gt; &lt;h2&gt;&lt;u&gt;&lt;span style=";font-family:Arial;font-size:85%;"  &gt;Introduction: &lt;/span&gt;&lt;/u&gt;&lt;/h2&gt;   &lt;p&gt;&lt;span style=";font-family:Arial;font-size:85%;"  &gt;User Controls are great in ASP.NET. They let us  divide the page into small sections. You can easily use User Controls on a  ASP.NET page by simply dragging and dropping the control from the solution  explorer. Sometimes we need to load the User Control dynamically. In this small  article we will learn how to load the User Control dynamically. &lt;/span&gt;&lt;/p&gt;   &lt;p&gt;&lt;u&gt;&lt;b&gt;&lt;span style=";font-family:Arial;font-size:85%;"  &gt;Loading User Control Dynamically: &lt;/span&gt; &lt;/b&gt;&lt;/u&gt;&lt;/p&gt;   &lt;p&gt;&lt;span style=";font-family:Arial;font-size:85%;"  &gt;There are no tricks involve in loading User  Control dynamically and its simple as anything else. All you have to do is to  make an instance of the User Control and add it to the Page Controls collection.  Let's look at a small example. &lt;/span&gt;&lt;/p&gt;   &lt;table style="border-collapse: collapse; color: rgb(17, 17, 17);" id="AutoNumber1" bg="" width="100%" border="2" cellpadding="0" cellspacing="0"&gt;    &lt;tbody&gt;&lt;tr&gt;     &lt;td width="100%"&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;&lt;span style="font-family:Courier New;"&gt;     private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;      LoadMyUserControl() &lt;/span&gt;     &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;span style="font-size:85%;"&gt;    &lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 128, 0);font-family:Courier New;font-size:85%;"  &gt;// Load the User      Controls Dynamically &lt;/span&gt;&lt;/p&gt; &lt;span style="color: rgb(0, 128, 0);font-family:Courier New;font-size:85%;"  &gt;    &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;MyUserControl myControl = (MyUserControl)      Page.LoadControl("MyUserControl.ascx"); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;span style="font-size:85%;"&gt;    &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;Page.Controls.Add(myControl);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style=";font-family:Courier New;font-size:85%;"  &gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;   &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt;   &lt;p&gt;&lt;span style=";font-family:Arial;font-size:85%;"  &gt;All we are doing is we make an instance of the  User Control and simply add the control to the Page Controls collection. Just  one thing to note that since you are making it dynamically you need to load it  each time the &lt;b&gt;Page_Loads&lt;/b&gt;. You can simply put a call to the &lt;b&gt; LoadMyUserControl &lt;/b&gt;method inside the &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt; InitializeComponent() &lt;/b&gt;&lt;span style="font-family:Arial;"&gt;method.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p&gt;&lt;span style=";font-family:Arial;font-size:85%;"  &gt;You can also load the User Control in the the  panel control. &lt;/span&gt;&lt;/p&gt;   &lt;table style="border-collapse: collapse; color: rgb(17, 17, 17);" id="AutoNumber2" bg="" width="100%" border="2" cellpadding="0" cellspacing="0"&gt;    &lt;tbody&gt;&lt;tr&gt;     &lt;td width="100%"&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;&lt;span style="font-family:Courier New;"&gt;     private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;      LoadMyUserControl() &lt;/span&gt;     &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;span style="font-size:85%;"&gt;    &lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 128, 0);font-family:Courier New;font-size:85%;"  &gt;// Load the User      Controls Dynamically &lt;/span&gt;&lt;/p&gt; &lt;span style="color: rgb(0, 128, 0);font-family:Courier New;font-size:85%;"  &gt;    &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Courier New;"&gt;MyUserControl myControl = (MyUserControl)      Page.LoadControl("MyUserControl.ascx"); &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;span style="font-size:85%;"&gt;    &lt;/span&gt; &lt;span style="font-size:85%;"&gt;    &lt;/span&gt;&lt;p&gt;&lt;span style=";font-family:Courier New;font-size:85%;"  &gt;Panel1.Controls.Add(myControl);     &lt;/span&gt;&lt;/p&gt; &lt;span style=";font-family:Courier New;font-size:85%;"  &gt;    &lt;/span&gt;&lt;span style="font-size:85%;"&gt;     &lt;/span&gt;&lt;p&gt;&lt;span style=";font-family:Courier New;font-size:85%;"  &gt;Panel1.DataBind();&lt;/span&gt;&lt;/p&gt; &lt;span style=";font-family:Courier New;font-size:85%;"  &gt;    &lt;/span&gt;&lt;p&gt;&lt;span style=";font-family:Courier New;font-size:85%;"  &gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;   &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt;   &lt;p&gt;&lt;span style=";font-family:Arial;font-size:85%;"  &gt;I hope you liked the article, happy coding! &lt;/span&gt;&lt;/p&gt;  &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-8374478654121039084?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/8374478654121039084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=8374478654121039084' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8374478654121039084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8374478654121039084'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/loading-user-control-dynamically-in-c.html' title='Loading User Control Dynamically in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-2786201031276578381</id><published>2009-08-06T08:06:00.000-07:00</published><updated>2009-08-06T08:06:00.484-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>CAPTCHA Functionality using C#</title><content type='html'>&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;span id="ctl00_cphContent_repArticle_ctl00_lblTitle"&gt;According to wikipedia, CAPTCHA ("Completely Automated Public Turing test to tell Computers and Humans Apart") is a challenge response test which is used to check that if the user is human or not. CAPTCHA is used exclusively in applications where the user input is required. These applications include Blogs, Forums and Portals. In this article I will demonstrate how to create a simple webpage that uses CAPTCHA functionality.&lt;/span&gt; &lt;/span&gt; &lt;br /&gt;  &lt;span id="ctl00_cphContent_repArticle_ctl00_lblBody"&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;strong&gt;Introduction&lt;/strong&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;According to &lt;a href="http://en.wikipedia.org/wiki/CAPTCHA"&gt;wikipedia&lt;/a&gt;, &lt;strong&gt;CAPTCHA&lt;/strong&gt; (&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;"Completely Automated Public &lt;a title="Turing test" href="http://en.wikipedia.org/wiki/Turing_test"&gt;Turing test&lt;/a&gt; to tell Computers and Humans Apart")&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt; is a challenge response test which is used to check that if the user is human or not. CAPTCHA is used exclusively in applications where the user input is required. These applications include Blogs, Forums and Portals. In this article I will demonstrate how to create a simple webpage that uses CAPTCHA functionality.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;strong&gt;The CreateImage Method&lt;/strong&gt;: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;The first task is to create an image and put it on the screen. For that I have created an ASP.NET page named &lt;span style="font-family:Courier New;"&gt;CaptchaControl.aspx&lt;/span&gt;. The &lt;span style="font-family:Courier New;"&gt;CaptchaControl.aspx&lt;/span&gt; page will be responsible for displaying the image to the user. Let’s take a look at the following code which generates the image. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; CreateImage()&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; code = GetRandomText(); &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008080;"&gt;Bitmap&lt;/span&gt; bitmap = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;Bitmap&lt;/span&gt;(200,150,System.Drawing.Imaging.&lt;span style="color:#008080;"&gt;PixelFormat&lt;/span&gt;.Format32bppArgb); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008080;"&gt;Graphics&lt;/span&gt; g = &lt;span style="color:#008080;"&gt;Graphics&lt;/span&gt;.FromImage(bitmap); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008080;"&gt;Pen&lt;/span&gt; pen = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;Pen&lt;/span&gt;(&lt;span style="color:#008080;"&gt;Color&lt;/span&gt;.Yellow); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008080;"&gt;Rectangle&lt;/span&gt; rect = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;Rectangle&lt;/span&gt;(0,0,200,150);&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008080;"&gt;SolidBrush&lt;/span&gt; b = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;SolidBrush&lt;/span&gt;(&lt;span style="color:#008080;"&gt;Color&lt;/span&gt;.DarkKhaki); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008080;"&gt;SolidBrush&lt;/span&gt; blue = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;SolidBrush&lt;/span&gt;(&lt;span style="color:#008080;"&gt;Color&lt;/span&gt;.Blue);&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; counter = 0; &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;g.DrawRectangle(pen, rect);&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;g.FillRectangle(b, rect);&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 0; i &lt;&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;g.DrawString(code[i].ToString(), &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;Font&lt;/span&gt;(&lt;span style="color:#800000;"&gt;"Verdena"&lt;/span&gt;, 10 + rand.Next(14, 18)), blue, &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;PointF&lt;/span&gt;(10 + counter, 10));&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;counter += 20;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;DrawRandomLines(g); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;Response.ContentType = "image/gif";&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;bitmap.Save(Response.OutputStream,&lt;span style="color:#008080;"&gt;ImageFormat&lt;/span&gt;.Gif);&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;g.Dispose();&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;bitmap.Dispose();&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;There is a bunch of stuff going on inside the &lt;strong&gt;CreateImage&lt;/strong&gt; method. The &lt;strong&gt;GetRandomText&lt;/strong&gt; method generates the random text and returns to the caller. If you are unfamiliar with creating random strings then I would suggest that you check out my article &lt;a href="http://gridviewguy.com/ArticleDetails.aspx?articleID=73"&gt;Creating Random Password&lt;/a&gt;. After I created the Rectangle where the text would appear I resized the text to give it a strange look. Finally, I called the &lt;strong&gt;DrawRandomLines&lt;/strong&gt; method which protects the image from OCR softwares.   &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;strong&gt;The GetRandomText Method&lt;/strong&gt;: &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;The purpose of the &lt;strong&gt;GetRandomText&lt;/strong&gt; method is to generate a random text every time a user gets the old text wrong. Take a look at the simple method which returns the random text. &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/p&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; GetRandomText()&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008080;"&gt;StringBuilder&lt;/span&gt; randomText = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;StringBuilder&lt;/span&gt;();&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (Session[&lt;span style="color:#800000;"&gt;"Code"&lt;/span&gt;] == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; alphabets = &lt;span style="color:#800000;"&gt;"abcdefghijklmnopqrstuvwxyz0123456789"&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008080;"&gt;Random&lt;/span&gt; r = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;Random&lt;/span&gt;();&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; j = 0; j &lt;= 5; j++)&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;randomText.Append(alphabets[r.Next(alphabets.Length)]);&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;Session[&lt;span style="color:#800000;"&gt;"Code"&lt;/span&gt;] = randomText.ToString(); &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; Session[&lt;span style="color:#800000;"&gt;"Code"&lt;/span&gt;] &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#008080;"&gt;String&lt;/span&gt;; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;The DrawRandomLines Method&lt;/strong&gt;: &lt;/p&gt; &lt;p&gt;The &lt;strong&gt;DrawRandomLines&lt;/strong&gt; method puts the lines on the text which, are displayed on an image. The purpose of these lines is to make it difficult for the bots to read the text. This way the text can only be read by humans. &lt;/p&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; DrawRandomLines(&lt;span style="color:#008080;"&gt;Graphics&lt;/span&gt; g)&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008080;"&gt;SolidBrush&lt;/span&gt; green = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;SolidBrush&lt;/span&gt;(&lt;span style="color:#008080;"&gt;Color&lt;/span&gt;.Green);&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 0; i &lt;&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;g.DrawLines(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;Pen&lt;/span&gt;(green, 2), GetRandomPoints());&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;} &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/p&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt; &lt;span style="color:#008080;"&gt;Point&lt;/span&gt;[] GetRandomPoints()&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008080;"&gt;Point&lt;/span&gt;[] points = { &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;Point&lt;/span&gt;(rand.Next(10, 150), rand.Next(10, 150)), &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#008080;"&gt;Point&lt;/span&gt;(rand.Next(10, 100), rand.Next(10, 100)) };&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; points; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Using the CAPTCHA Page&lt;/strong&gt;: &lt;/p&gt; &lt;p&gt;We have created the CAPTCHA feature but the question is how do we use it. In order to use the CAPTCHA feature you will need to create a page which consumes the &lt;span style="font-family:Courier New;"&gt;CaptchaControl.aspx&lt;/span&gt; page. I have created the &lt;span style="font-family:Courier New;"&gt;Default.aspx&lt;/span&gt; page which uses the &lt;span style="font-family:Courier New;"&gt;CaptchaControl.aspx&lt;/span&gt; as the ImageUrl to the ASP.NET image control. Check out the complete HTML code of the &lt;span style="font-family:Courier New;"&gt;Default.aspx&lt;/span&gt; page. &lt;/p&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-family:Courier New;"&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#800000;"&gt;form&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="form1"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;strong&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#800000;"&gt;Image&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="myImage"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ImageUrl&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="~/CaptchaControl.aspx"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;br&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;br&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;Enter code: &lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#800000;"&gt;TextBox&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&gt;&lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#800000;"&gt;TextBox&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#800000;"&gt;Button&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button1"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Validate"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;OnClick&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Button1_Click"&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;br&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;br&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#800000;"&gt;Label&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ID&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="lblError"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Font-Bold&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="True"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;Font-Size&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="X-Large"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;ForeColor&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Red"&gt;&lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;asp&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#800000;"&gt;Label&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;&lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;form&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;The important thing to note is the ASP.NET image control which, requests the &lt;span style="font-family:Courier New;"&gt;CaptchaControl.aspx&lt;/span&gt; page and generates the image. The code for the validation of the user text against the CAPTCHA text is pretty simple and you can view it in the downloaded files. &lt;/p&gt; &lt;p&gt;Below is an image of how the application looks like:&lt;/p&gt; &lt;p&gt;&lt;img src="http://www.gridviewguy.com/ArticleImages/CaptchaControlImage1.gif" /&gt;&lt;/p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;: &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;In this article I demonstrated how easy it is to create a CAPTCHA feature. This feature can play a very important role in the security of the application. &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-2786201031276578381?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/2786201031276578381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=2786201031276578381' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/2786201031276578381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/2786201031276578381'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/captcha-functionality-using-c.html' title='CAPTCHA Functionality using C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-1914459454867446926</id><published>2009-08-05T08:00:00.000-07:00</published><updated>2009-08-05T08:00:02.516-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Fade In Fade Out Effect Using JQuery</title><content type='html'>&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;span id="ctl00_cphContent_repArticle_ctl00_lblTitle"&gt;n this article we are going to use JQuery to create a fade in fade out effect. The fade in fade out effect can be used to notify the user that some operation has happened. The fade in will capture the user's attention and the fade out will make sure that the space is not occupied by the stale message.&lt;/span&gt; &lt;/span&gt; &lt;br /&gt;  &lt;span id="ctl00_cphContent_repArticle_ctl00_lblBody"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;u&gt;&lt;b&gt;Recommend Reading:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;If you are new to JQuery then we suggest that you check out the JQuery documentation about using the effects.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://docs.jquery.com/Effects"&gt;http://docs.jquery.com/Effects&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Implementing Fade In Fade Out Effect: &lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;JQuery has many effects already defined in its strong belt of tricks. This includes fadeIn, fadeOut, slideUp, slideDown etc. Unfortunately, the FadeInFadeOut effect is not included in the library. But that is OK! because we can easily add this effect to the jQuery functions and reuse the effect at our own pleasure.  &lt;br /&gt;&lt;br /&gt;Here is the one way to create the effect:&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt;$("#divMessage").html("Item has been saved").fadeIn(2000, function()&lt;br /&gt;{&lt;br /&gt;    $(this).fadeOut(2000);        &lt;br /&gt;});&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;First, the fadeIn is fired and after 2 seconds the callback function is fired which in turn fires the fadeOut function. This will work as expected but writing this amount of code everytime we need a fadeInFadeOut effect is just too much. Let's see how we can reduce some code.&lt;br /&gt;&lt;br /&gt;In the code below we have extended the fn (function) of jQuery base library by attaching our own personal function called fadeInFadeOut.&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt;jQuery.fn.fadeInFadeOut = function(speed) {&lt;br /&gt;&lt;br /&gt;        return $(this).fadeIn(speed,&lt;br /&gt;&lt;br /&gt;        function() {&lt;br /&gt;&lt;br /&gt;            return $(this).fadeOut(speed);&lt;br /&gt;&lt;br /&gt;         });&lt;br /&gt;    }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now we can use the above function like this:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt; $("#divMessage").html("Item has been saved").fadeInFadeOut(2000);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;And here is the effect:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.gridviewguy.com/articleimages/FadeInFadeOutAnimation.gif" /&gt;&lt;br /&gt;&lt;br /&gt;There is another way to produce the same effect. Check out the following code:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt;$("#divMessage").html("Item has been saved").fadeIn(2000).fadeOut(2000);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In the above code the message will fadeIn at the rate of 2 seconds and then fade out after 2 seconds.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Conclusion: &lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;JQuery provides many build-in effects to ease the developer pain. JQuery also provides the animate function which is used to create custom animations. You can also extend the JQuery functions by attaching your own functions.&lt;br /&gt;&lt;br /&gt;I hope you like this article, now go and get high! &lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-1914459454867446926?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/1914459454867446926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=1914459454867446926' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1914459454867446926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1914459454867446926'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/fade-in-fade-out-effect-using-jquery.html' title='Fade In Fade Out Effect Using JQuery'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-8588472677676391650</id><published>2009-08-04T08:01:00.000-07:00</published><updated>2009-08-04T08:01:00.398-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>GridView Confirmation Box Using JQuery BlockUI</title><content type='html'>&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;span id="ctl00_cphContent_repArticle_ctl00_lblTitle"&gt;JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task. &lt;/span&gt; &lt;/span&gt; &lt;br /&gt;  &lt;span id="ctl00_cphContent_repArticle_ctl00_lblBody"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;u&gt;&lt;b&gt;What Does Blocking Mean? &lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;There are number of different words to define the behavior of blockUI library. It can be called blocking or freezing the page. The main purpose to block the page is to get the user's focus on a small portion of the page or to perform the action on the background. The blocking aspect will keep the user from clicking any other control on the page.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Downloading the BlockUI Library:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;You can download the BlockUI library using the following URL:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://malsup.com/jquery/block/"&gt;BlockUI Plugin&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Creating a Simple Block Screen: &lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;First, make sure that you have added a script reference to the JQuery library and the BlockUI library as shown below:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt;&lt;script src="jquery-1.3.2.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;&lt;script src="jqueryblockui.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;For our simply demo we will use a button control to block the screen and display a small message on the center of the screen. Here is the DIV control that will be displayed as a message when the screen is blocked.&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt;&lt;div id="divHelp" style="display:none"&gt;&lt;br /&gt;    Help will be displayed here!&lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The above DIV will be displayed when the following button is clicked.&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt;&lt;input type="button" value="Open Help" onclick="openHelp()"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-family:Courier New;"&gt;openHelp &lt;/span&gt;function is responsible for blocking the UI and displaying the DIV on the page.&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt;  function openHelp() {&lt;br /&gt;&lt;br /&gt;        $.blockUI({ message : $('#divHelp')});&lt;br /&gt;   &lt;br /&gt;    }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;When you run the page and click on the button you will see the following result:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.highoncoding.com/articleimages/blockui_jquery_001.PNG" /&gt;&lt;br /&gt;&lt;br /&gt;As, you can see in the above image the whole screen is blocked and only a small portion (DIV) is available to the user to interact. Now, let's take a look at how we can use BlockUI to replace boring confirmation messages.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Deleting Items Using GridView with BlockUI Confirmations: &lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;We are going to populate the GridView control with data from the Northwind database "Categories" table. Take a look at the following code which uses LINQ to SQL as a data layer to populate the GridView control.&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt; private void BindData()&lt;br /&gt;        {&lt;br /&gt;            using (var northwind = new NorthwindDataContext())&lt;br /&gt;            {&lt;br /&gt;                gvCategories.DataSource = northwind.Categories;&lt;br /&gt;                gvCategories.DataBind();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;And here is the ASPX GridView code:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt;&lt;asp:gridview id="gvCategories" runat="server" autogeneratecolumns="false"&gt;&lt;br /&gt;   &lt;br /&gt;    &lt;columns&gt;&lt;br /&gt;   &lt;br /&gt;    &lt;asp:templatefield headertext="Category Name"&gt;&lt;br /&gt;   &lt;br /&gt;    &lt;itemtemplate&gt;&lt;br /&gt;    &lt;asp:label id="lblCategoryName" runat="server" text="'&lt;%#"&gt;' /&gt;&lt;br /&gt;    &lt;/itemtemplate&gt;&lt;br /&gt;    &lt;/asp:TemplateField&gt;&lt;br /&gt;   &lt;br /&gt;     &lt;asp:templatefield&gt;&lt;br /&gt;   &lt;br /&gt;    &lt;itemtemplate&gt;&lt;br /&gt;    &lt;input type="button" value="Delete" onclick="showDeleteConfirmation('&lt;%# Eval("&gt;')" /&gt;&lt;br /&gt;    &lt;/itemtemplate&gt;&lt;br /&gt;    &lt;/asp:TemplateField&gt;&lt;br /&gt;   &lt;br /&gt;    &lt;/columns&gt;&lt;br /&gt;   &lt;br /&gt;    &lt;/asp:GridView&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;When you run the above code you will see the following page:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.highoncoding.com/articleimages/blockui_jquery_002.PNG" /&gt;&lt;br /&gt;&lt;br /&gt;The divConfirmBox is used to display a custom confirmation box to the user. Here is the code for the DIV.&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt; &lt;div id="divConfirmBox" style="display:none"&gt;&lt;br /&gt;    Are you sure you want to delete this record?&lt;br /&gt;   &lt;br /&gt;    &lt;asp:button id="btn_DeleteRecord" onclientclick="deleteRecord()" onclick="Btn_DeleteRecord" usesubmitbehavior="false" runat="server" text="Yes"&gt;&lt;br /&gt;    &lt;input type="button" value="No" onclick="$.unblockUI()"&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;asp:hiddenfield id="hfCategoryId" runat="server"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;There are couple of things to note here. First, the divConfirmBox is not inside the GridView control. If it was inside the GridView ItemTemplate then it would have been rendered with each row. This would have caused a lot of extra code to be rendered with the GridView control thus making the page slower and killing performance.&lt;br /&gt;&lt;br /&gt;We have placed the popup DIV outside the GridView control and used a HiddenField to hold the selected row Id which in this case is CategoryID. The button inside the DIV uses &lt;span style="font-family:Courier New;"&gt;UseSubmitBehavior = false&lt;/span&gt; which will allow the button to perform a postback.&lt;br /&gt;&lt;br /&gt;Each row contains a delete button which is used to block the user's page and shows a confirmation box to the user when clicked. The &lt;span style="font-family:Courier New;"&gt;showDeleteConfirmation &lt;/span&gt;function is also responsible for transferring the selected categoryID into a categoryId global variable.  Check out the screen shot below:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.highoncoding.com/articleimages/blockui_jquery_003.PNG" /&gt;&lt;br /&gt;&lt;br /&gt;Here is the &lt;span style="font-family:Courier New;"&gt;showDeleteConfirmation &lt;/span&gt;function:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt; var categoryId; // global variable&lt;br /&gt;&lt;br /&gt;    function showDeleteConfirmation(cId) {&lt;br /&gt;&lt;br /&gt;        categoryId = cId&lt;br /&gt;        $.blockUI({ message : $('#divConfirmBox') });&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As, you can see in the screen shot above when the user clicks the delete button a custom confirmation box is shown to alarm the user that the selected record will be deleted. If the user press the "NO" button then the UI is unblocked and the normal processing resumes. If the user clicks the "OK" button then we fire the OnClick event handler of the button. Before the server side event of the button is fired the OnClientClick is triggered. The OnClientClick fires the &lt;span style="font-family:Courier New;"&gt;deleteRecord &lt;/span&gt;function which moves the categoryId into a hidden field as shown below:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt; function deleteRecord() {&lt;br /&gt;&lt;br /&gt;        $("#hfCategoryId").val(categoryId);&lt;br /&gt;        $.unblockUI();    &lt;br /&gt;    }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Finally, here is the Btn_DeleteRecord event which is handled on the server side:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 5px; font-family: courier new; background-color: rgb(204, 204, 204); color: black; padding-left: 2em; padding-bottom: 2em; padding-top: 2em; font-weight: bold;"&gt;&lt;br /&gt; protected void Btn_DeleteRecord(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            var categoryId = Int32.Parse(hfCategoryId.Value);&lt;br /&gt;&lt;br /&gt;            using(var northwind = new NorthwindDataContext())&lt;br /&gt;            {&lt;br /&gt;                var category = (from c in northwind.Categories&lt;br /&gt;                               where c.CategoryID == categoryId&lt;br /&gt;                               select c).SingleOrDefault();&lt;br /&gt;&lt;br /&gt;                northwind.Categories.DeleteOnSubmit(category);&lt;br /&gt;                northwind.SubmitChanges();&lt;br /&gt;&lt;br /&gt;                BindData();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Conclusion: &lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;In this article we learned how to use the JQuery BlockUI plug in to create block pages. We also learned how we can easily replace the boring JavaScript confirmation box with more attractive blockUI message box. In the next article we are going to see some cool blockUI library features with the JQuery Ajax framework. &lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-8588472677676391650?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/8588472677676391650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=8588472677676391650' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8588472677676391650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8588472677676391650'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/gridview-confirmation-box-using-jquery.html' title='GridView Confirmation Box Using JQuery BlockUI'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-8965427836090037366</id><published>2009-08-03T17:45:00.000-07:00</published><updated>2009-08-03T17:45:00.779-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Singleton Pattern</title><content type='html'>&lt;h1&gt;Implementing the Singleton Pattern in C#&lt;/h1&gt;     &lt;p&gt;       The singleton pattern is one of the best-known patterns in software engineering.       Essentially, a singleton is a class which only allows a single instance of itself       to be created, and usually gives simple access to that instance. Most commonly,       singletons don't allow any parameters to be specified when creating the instance -       as otherwise a second request for an instance but with a different parameter could       be problematic! (If the same instance should be accessed for all requests with the       same parameter, the factory pattern is more appropriate.) This article deals only with       the situation where no parameters are required. Typically a requirement of singletons       is that they are created lazily - i.e. that the instance isn't created until it is       first needed.     &lt;/p&gt;     &lt;p&gt;       There are various different ways of implementing the singleton pattern in C#. I shall       present them here in reverse order of elegance, starting with the most commonly seen,       which is not thread-safe, and working up to a fully lazily-loaded, thread-safe, simple       and highly performant version. Note that in the code here, I omit the &lt;code&gt;private&lt;/code&gt;        modifier, as it is the default for class members. In many other languages such as Java, there       is a different default, and &lt;code&gt;private&lt;/code&gt; should be used.     &lt;/p&gt;     &lt;p&gt;       All these implementations share four common characteristics, however:     &lt;/p&gt;     &lt;ul&gt;&lt;li&gt;     A single constructor, which is private and parameterless.      This prevents other classes from instantiating it (which would be a violation of the pattern).     Note that it also prevents subclassing - if a singleton can be subclassed once, it can be     subclassed twice, and if each of those subclasses can create an instance, the pattern is     violated. The factory pattern can be used if you need a single instance of a base type,     but the exact type isn't known until runtime.    &lt;/li&gt;&lt;li&gt;       The class is sealed. This is unnecessary, strictly speaking, due to the above point,       but may help the JIT to optimise things more.      &lt;/li&gt;&lt;li&gt;     A static variable which holds a reference to the single created instance, if any.    &lt;/li&gt;&lt;li&gt;     A public static means of getting the reference to the single created instance, creating     one if necessary.    &lt;/li&gt;&lt;/ul&gt;     &lt;p&gt;       Note that all of these implementations also use a public static property &lt;code&gt;Instance&lt;/code&gt;       as the means of accessing the instance. In all cases, the property could easily be converted       to a method, with no impact on thread-safety or performance.     &lt;/p&gt;     &lt;h2&gt;First version - not thread-safe&lt;/h2&gt; &lt;table class="code"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&lt;span class="Attention"&gt;// Bad code! Do not use!&lt;/span&gt;&lt;br /&gt;&lt;span class="Modifier"&gt;public&lt;/span&gt; &lt;span class="Modifier"&gt;sealed&lt;/span&gt; &lt;span class="ReferenceType"&gt;class&lt;/span&gt; Singleton&lt;br /&gt;{&lt;br /&gt;   &lt;span class="Modifier"&gt;static&lt;/span&gt; Singleton instance=&lt;span class="Keyword"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;   Singleton()&lt;br /&gt;   {&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   &lt;span class="Modifier"&gt;public&lt;/span&gt; &lt;span class="Modifier"&gt;static&lt;/span&gt; Singleton Instance&lt;br /&gt;   {&lt;br /&gt;       get&lt;br /&gt;       {&lt;br /&gt;           &lt;span class="Statement"&gt;if&lt;/span&gt; (instance==&lt;span class="Keyword"&gt;null&lt;/span&gt;)&lt;br /&gt;           {&lt;br /&gt;               instance = &lt;span class="Keyword"&gt;new&lt;/span&gt; Singleton();&lt;br /&gt;           }&lt;br /&gt;           &lt;span class="Statement"&gt;return&lt;/span&gt; instance;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;     &lt;p&gt;       As hinted at before, the above is not thread-safe. Two different threads could both       have evaluated the test &lt;code&gt;if (instance==null)&lt;/code&gt; and found it to be true,       then both create instances, which violates the singleton pattern. Note that in fact       the instance may already have been created before the expression is evaluated, but       the memory model doesn't guarantee that the new value of instance will be seen by       other threads unless suitable memory barriers have been passed.     &lt;/p&gt;     &lt;h2&gt;Second version - simple thread-safety&lt;/h2&gt; &lt;table class="code"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&lt;span class="Modifier"&gt;public&lt;/span&gt; &lt;span class="Modifier"&gt;sealed&lt;/span&gt; &lt;span class="ReferenceType"&gt;class&lt;/span&gt; Singleton&lt;br /&gt;{&lt;br /&gt;   &lt;span class="Modifier"&gt;static&lt;/span&gt; Singleton instance=&lt;span class="Keyword"&gt;null&lt;/span&gt;;&lt;br /&gt;   &lt;span class="Modifier"&gt;static&lt;/span&gt; &lt;span class="Modifier"&gt;readonly&lt;/span&gt; &lt;span class="ReferenceType"&gt;object&lt;/span&gt; padlock = &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ReferenceType"&gt;object&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;   Singleton()&lt;br /&gt;   {&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   &lt;span class="Modifier"&gt;public&lt;/span&gt; &lt;span class="Modifier"&gt;static&lt;/span&gt; Singleton Instance&lt;br /&gt;   {&lt;br /&gt;       get&lt;br /&gt;       {&lt;br /&gt;           &lt;span class="Statement"&gt;lock&lt;/span&gt; (padlock)&lt;br /&gt;           {&lt;br /&gt;               &lt;span class="Statement"&gt;if&lt;/span&gt; (instance==&lt;span class="Keyword"&gt;null&lt;/span&gt;)&lt;br /&gt;               {&lt;br /&gt;                   instance = &lt;span class="Keyword"&gt;new&lt;/span&gt; Singleton();&lt;br /&gt;               }&lt;br /&gt;               &lt;span class="Statement"&gt;return&lt;/span&gt; instance;&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;     &lt;p&gt;       This implementation is thread-safe. The thread takes out a lock on a shared       object, and then checks whether or not the instance has been created before creating the instance.       This takes care of the memory barrier issue (as locking makes sure that       all reads occur logically after the lock acquire, and unlocking makes sure that all writes occur       logically before the lock release) and ensures that only one thread will create an instance        (as only one thread can be in that part of the code at a time - by the time the second thread        enters it,the first thread will have created the instance, so the expression will evaluate to false).       Unfortunately, performance suffers as a lock is acquired every time the instance is requested.           &lt;/p&gt;     &lt;p&gt;       Note that instead of locking on &lt;code&gt;typeof(Singleton)&lt;/code&gt; as some versions of this        implementation do, I lock on the value of a static variable which is private to the class.       Locking on objects which other classes can access and lock on (such as the type) risks       performance issues and even deadlocks. This is a general style preference of mine - wherever       possible, only lock on objects specifically created for the purpose of locking, or which       document that they are to be locked on for specific purposes (e.g. for waiting/pulsing a queue).       Usually such objects should be private to the class they are used in. This helps to make       writing thread-safe applications significantly easier.     &lt;/p&gt;     &lt;h2&gt;Third version - attempted thread-safety using double-check locking&lt;/h2&gt; &lt;table class="code"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&lt;span class="Attention"&gt;// Bad code! Do not use!&lt;/span&gt;&lt;br /&gt;&lt;span class="Modifier"&gt;public&lt;/span&gt; &lt;span class="Modifier"&gt;sealed&lt;/span&gt; &lt;span class="ReferenceType"&gt;class&lt;/span&gt; Singleton&lt;br /&gt;{&lt;br /&gt;   &lt;span class="Modifier"&gt;static&lt;/span&gt; Singleton instance=&lt;span class="Keyword"&gt;null&lt;/span&gt;;&lt;br /&gt;   &lt;span class="Modifier"&gt;static&lt;/span&gt; &lt;span class="Modifier"&gt;readonly&lt;/span&gt; &lt;span class="ReferenceType"&gt;object&lt;/span&gt; padlock = &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ReferenceType"&gt;object&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;   Singleton()&lt;br /&gt;   {&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   &lt;span class="Modifier"&gt;public&lt;/span&gt; &lt;span class="Modifier"&gt;static&lt;/span&gt; Singleton Instance&lt;br /&gt;   {&lt;br /&gt;       get&lt;br /&gt;       {&lt;br /&gt;           &lt;span class="Statement"&gt;if&lt;/span&gt; (instance==&lt;span class="Keyword"&gt;null&lt;/span&gt;)&lt;br /&gt;           {&lt;br /&gt;               &lt;span class="Statement"&gt;lock&lt;/span&gt; (padlock)&lt;br /&gt;               {&lt;br /&gt;                   &lt;span class="Statement"&gt;if&lt;/span&gt; (instance==&lt;span class="Keyword"&gt;null&lt;/span&gt;)&lt;br /&gt;                   {&lt;br /&gt;                       instance = &lt;span class="Keyword"&gt;new&lt;/span&gt; Singleton();&lt;br /&gt;                   }&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;           &lt;span class="Statement"&gt;return&lt;/span&gt; instance;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;     &lt;p&gt;       This implementation attempts to be thread-safe without the necessity of taking out a lock every time.        Unfortunately, there are four downsides to the pattern:     &lt;/p&gt;     &lt;ul&gt;&lt;li&gt;     It doesn't work in Java. This may seem an odd thing to comment on, but it's worth knowing     if you ever need the singleton pattern in Java, and C# programmers may well also be Java     programmers. The Java memory model doesn't ensure that the constructor completes before     the reference to the new object is assigned to instance. The Java memory model underwent     a reworking for version 1.5, but double-check locking is still broken after this without a volatile     variable (as in C#).    &lt;/li&gt;&lt;li&gt;         Without any memory barriers, it's broken in the ECMA CLI specification too. It's possible that under the .NET 2.0         memory model (which is stronger than the ECMA spec) it's safe, but I'd rather not rely on those stronger         semantics, especially if there's any doubt as to the safety.          Making the &lt;code&gt;instance&lt;/code&gt; variable volatile can make it work, as would explicit memory barrier calls, although in the latter case even experts can't agree exactly which barriers are required. I tend to try to avoid situations where experts don't agree what's right and what's wrong! &lt;/li&gt;&lt;li&gt;     It's easy to get wrong. The pattern needs to be pretty much exactly as above - any     significant changes are likely to impact either performance or correctness.    &lt;/li&gt;&lt;li&gt;     It still doesn't perform as well as the later implementations.    &lt;/li&gt;&lt;/ul&gt;     &lt;h2&gt;Fourth version - not quite as lazy, but thread-safe without using locks&lt;/h2&gt; &lt;table class="code"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&lt;span class="Modifier"&gt;public&lt;/span&gt; &lt;span class="Modifier"&gt;sealed&lt;/span&gt; &lt;span class="ReferenceType"&gt;class&lt;/span&gt; Singleton&lt;br /&gt;{&lt;br /&gt;   &lt;span class="Modifier"&gt;static&lt;/span&gt; &lt;span class="Modifier"&gt;readonly&lt;/span&gt; Singleton instance=&lt;span class="Keyword"&gt;new&lt;/span&gt; Singleton();&lt;br /&gt;&lt;br /&gt;   &lt;span class="InlineComment"&gt;// Explicit static constructor to tell C# compiler&lt;/span&gt;&lt;br /&gt;   &lt;span class="InlineComment"&gt;// not to mark type as beforefieldinit&lt;/span&gt;&lt;br /&gt;   &lt;span class="Modifier"&gt;static&lt;/span&gt; Singleton()&lt;br /&gt;   {&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   Singleton()&lt;br /&gt;   {&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   &lt;span class="Modifier"&gt;public&lt;/span&gt; &lt;span class="Modifier"&gt;static&lt;/span&gt; Singleton Instance&lt;br /&gt;   {&lt;br /&gt;       get&lt;br /&gt;       {&lt;br /&gt;           &lt;span class="Statement"&gt;return&lt;/span&gt; instance;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;     &lt;p&gt;       As you can see, this is really is extremely simple - but why is it thread-safe and how lazy is it?       Well, static constructors in C# are specified to execute only when an instance of the class is       created or a static member is referenced, and to execute only once per AppDomain. Given that       this check for the type being newly constructed needs to be executed whatever else happens, it       will be faster than adding extra checking as in the previous examples. There are a couple of        wrinkles, however:       &lt;/p&gt;&lt;ul&gt;&lt;li&gt;           It's not as lazy as the other implementations. In particular, if you have static members           other than &lt;code&gt;Instance&lt;/code&gt;, the first reference to those members will involve           creating the instance. This is corrected in the next implementation.         &lt;/li&gt;&lt;li&gt;           There are complications if one static constructor invokes another which invokes the           first again. Look in the .NET specifications (currently section 9.5.3 of partition II)            for more details about the exact nature  of type initializers - they're unlikely to bite you,            but it's worth being aware of the consequences of static constructors which refer to each            other in a cycle.         &lt;/li&gt;&lt;li&gt;           The laziness of type initializers is only guaranteed by .NET when the type isn't           marked with a special flag called &lt;code&gt;beforefieldinit&lt;/code&gt;. Unfortunately,           the C# compiler (as provided in the .NET 1.1 runtime, at least) marks all types           which don't have a static constructor (i.e. a block which looks           like a constructor but is marked static) as &lt;code&gt;beforefieldinit&lt;/code&gt;. I now           have a &lt;a href="http://www.yoda.arachsys.com/csharp/beforefieldinit.html"&gt;discussion page&lt;/a&gt; with more details about           this issue. Also note that it affects performance, as discussed near the bottom           of this article.         &lt;/li&gt;&lt;/ul&gt;          &lt;p&gt;       One shortcut you can take with this implementation (and only this one) is to just make        &lt;code&gt;instance&lt;/code&gt; a public static readonly variable, and get rid of the property entirely.       This makes the basic skeleton code absolutely tiny! Many people, however, prefer to have a       property in case further action is needed in future, and JIT inlining is likely to make       the performance identical. (Note that the static constructor itself is still required       if you require laziness.)     &lt;/p&gt;     &lt;h2&gt;Fifth version - fully lazy instantiation&lt;/h2&gt; &lt;table class="code"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&lt;span class="Modifier"&gt;public&lt;/span&gt; &lt;span class="Modifier"&gt;sealed&lt;/span&gt; &lt;span class="ReferenceType"&gt;class&lt;/span&gt; Singleton&lt;br /&gt;{&lt;br /&gt;   Singleton()&lt;br /&gt;   {&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   &lt;span class="Modifier"&gt;public&lt;/span&gt; &lt;span class="Modifier"&gt;static&lt;/span&gt; Singleton Instance&lt;br /&gt;   {&lt;br /&gt;       get&lt;br /&gt;       {&lt;br /&gt;           &lt;span class="Statement"&gt;return&lt;/span&gt; Nested.instance;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   &lt;span class="ReferenceType"&gt;class&lt;/span&gt; Nested&lt;br /&gt;   {&lt;br /&gt;       &lt;span class="InlineComment"&gt;// Explicit static constructor to tell C# compiler&lt;/span&gt;&lt;br /&gt;       &lt;span class="InlineComment"&gt;// not to mark type as beforefieldinit&lt;/span&gt;&lt;br /&gt;       &lt;span class="Modifier"&gt;static&lt;/span&gt; Nested()&lt;br /&gt;       {&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       &lt;span class="Modifier"&gt;internal&lt;/span&gt; &lt;span class="Modifier"&gt;static&lt;/span&gt; &lt;span class="Modifier"&gt;readonly&lt;/span&gt; Singleton instance = &lt;span class="Keyword"&gt;new&lt;/span&gt; Singleton();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;     &lt;p&gt;       Here, instantiation is triggered by the first reference to the static member of the nested       class, which only occurs in &lt;code&gt;Instance&lt;/code&gt;. This means the implementation is fully       lazy, but has all the performance benefits of the previous ones. Note that although nested       classes have access to the enclosing class's private members, the reverse is not true, hence       the need for &lt;code&gt;instance&lt;/code&gt; to be internal here. That doesn't raise any other problems,       though, as the class itself is private. The code is a bit more complicated in order to make       the instantiation lazy, however.     &lt;/p&gt;     &lt;h2&gt;Performance vs laziness&lt;/h2&gt;     &lt;p&gt;      In many cases, you won't actually require full laziness - unless your class initialization       does something particularly time-consuming, or has some side-effect elsewhere, it's probably      fine to leave out the explicit static constructor shown above. This can increase performance      as it allows the JIT compiler to make a single check (for instance at the start of a method)      to ensure that the type has been initialized, and then assume it from then on. If your      singleton instance is referenced within a relatively tight loop, this can make a (relatively)       significant performance difference. You should decide whether or not fully lazy instantiation        is required, and document this decision appropriately within the class. (See below for more on       performance, however.)     &lt;/p&gt;     &lt;h2&gt;Exceptions&lt;/h2&gt;     &lt;p&gt;       Sometimes, you need to do work in a singleton constructor which may throw an exception, but        might not be fatal to the whole application. Potentially, your application may be able to       fix the problem and want to try again. Using type initializers to construct the singleton       becomes problematic at this stage. Different runtimes handle this case differently,       but I don't know of any which do the desired thing (running the type initializer again), and       even if one did, your code would be broken on other runtimes. To avoid these problems, I'd        suggest using the second pattern listed on the page - just use a simple lock, and go through        the check each time, building the instance in the method/property if it hasn't already been       successfully built.     &lt;/p&gt;     &lt;p&gt;       Thanks to Andriy Tereshchenko for raising this issue.     &lt;/p&gt;     &lt;h2&gt;A word on performance&lt;/h2&gt;     &lt;p&gt;       A lot of the reason for this page stemmed from people trying to be clever, and thus coming       up with the double-checked locking algorithm. There is an attitude of locking being expensive       which is common and misguided. I've written a very quick &lt;a href="http://www.yoda.arachsys.com/csharp/SingletonBenchmark.cs"&gt;benchmark&lt;/a&gt;       which just acquires singleton instances in a loop a billion ways, trying different variants.       It's not terribly scientific, because in real life you may want to know how fast it is if each       iteration actually involved a call into a method fetching the singleton, etc. However, it does       show an important point. On my laptop, the slowest solution (by a factor of about 5) is the locking       one (solution 2). Is that important? Probably not, when you bear in mind that it still managed to       acquire the singleton a &lt;i&gt;billion&lt;/i&gt; times in under 40 seconds. That means that if you're "only"       acquiring the singleton four hundred thousand times per second, the cost of the acquisition       is going to be 1% of the performance - so improving it isn't going to do a lot. Now, if you &lt;i&gt;are&lt;/i&gt;       acquiring the singleton that often - isn't it likely you're using it within a loop? If you care       that much about improving the performance a little bit, why not declare a local variable outside the loop,       acquire the singleton once and &lt;i&gt;then&lt;/i&gt; loop. Bingo, even the slowest implementation becomes easily       adequate.     &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-8965427836090037366?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/8965427836090037366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=8965427836090037366' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8965427836090037366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8965427836090037366'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/singleton-pattern.html' title='Singleton Pattern'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-7014617312584074246</id><published>2009-08-02T17:43:00.000-07:00</published><updated>2009-08-02T17:43:00.560-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Factory Pattern</title><content type='html'>What is a Factory Pattern :Factory Pattern creates an instance of several derived classes.&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;namespace FactoryPattern&lt;br /&gt;{&lt;br /&gt;   interface IBase&lt;br /&gt;   {&lt;br /&gt;       void DoIt();&lt;br /&gt;   }&lt;br /&gt;   class Derived1:IBase&lt;br /&gt;   {&lt;br /&gt;       public void DoIt()&lt;br /&gt;       {&lt;br /&gt;           Console.WriteLine("Derived1 Method is called");&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;   class Derived2:IBase&lt;br /&gt;   {&lt;br /&gt;       public void DoIt()&lt;br /&gt;       {&lt;br /&gt;           Console.WriteLine("Derived2 Method is called");&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;   class Factory&lt;br /&gt;   {&lt;br /&gt;       public IBase getObject(int type)&lt;br /&gt;       {&lt;br /&gt;           IBase objIBase = null;&lt;br /&gt;           switch (type)&lt;br /&gt;           {&lt;br /&gt;               case 1:&lt;br /&gt;                   objIBase = new Derived1();&lt;br /&gt;                   break;&lt;br /&gt;               case 2:&lt;br /&gt;                   objIBase = new Derived2();&lt;br /&gt;                   break;&lt;br /&gt;           }&lt;br /&gt;           return objIBase;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;class Program&lt;br /&gt;   {&lt;br /&gt;       static void Main(string[] args)&lt;br /&gt;       {&lt;br /&gt;           Factory objFactory = new Factory();&lt;br /&gt;           IBase objIbase = objFactory.getObject(1);&lt;br /&gt;           objIbase.DoIt();&lt;br /&gt;           Console.ReadLine();&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Output:&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_1EZkGmmHBwc/SkeHK_f7WmI/AAAAAAAAA3c/AYSv4Rbp-_8/s1600-h/1.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 321px; height: 106px;" src="http://4.bp.blogspot.com/_1EZkGmmHBwc/SkeHK_f7WmI/AAAAAAAAA3c/AYSv4Rbp-_8/s400/1.JPG" alt="" id="BLOGGER_PHOTO_ID_5352395305066912354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Diagram/Description&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_1EZkGmmHBwc/SkeIFFzfpPI/AAAAAAAAA3k/l9c1EwSBGv0/s1600-h/1.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 92px;" src="http://1.bp.blogspot.com/_1EZkGmmHBwc/SkeIFFzfpPI/AAAAAAAAA3k/l9c1EwSBGv0/s400/1.JPG" alt="" id="BLOGGER_PHOTO_ID_5352396303192007922" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-7014617312584074246?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/7014617312584074246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=7014617312584074246' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7014617312584074246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7014617312584074246'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/factory-pattern.html' title='Factory Pattern'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1EZkGmmHBwc/SkeHK_f7WmI/AAAAAAAAA3c/AYSv4Rbp-_8/s72-c/1.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-187455514827129924</id><published>2009-08-01T14:42:00.001-07:00</published><updated>2009-08-01T18:20:15.864-07:00</updated><title type='text'>How to embed GoogleWave on blog(blogger)</title><content type='html'>&lt;p&gt;Steps to Embed GoogleWave on Blogger &lt;br /&gt;1: Signup for Google wave account .  &lt;br /&gt;2: Create your own Wave  &lt;br /&gt;3: Grab Wave ID&lt;br /&gt;&lt;div id="lw_context_ads"&gt;&lt;/p&gt;&lt;p&gt;&lt;/div&gt;&lt;br /&gt; &lt;/p&gt;&lt;blockquote&gt;&amp;lt;script src="http://wave-api.appspot.com/public/embed.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt; &lt;br /&gt;   &amp;lt;script type="text/javascript"&amp;gt;  &lt;br /&gt;   function initialize() {  &lt;br /&gt;     var wavePanel = new WavePanel("http://wave.google.com/a/wavesandbox.com/");  &lt;br /&gt;     wavePanel.loadWave("wavesandbox.com!w+WAVEID&amp;lt;/span&amp;gt;");  &lt;br /&gt;     wavePanel.init(document.getElementById("waveframe"));  &lt;br /&gt;   }  &lt;br /&gt;&amp;lt;/script&amp;gt;  &lt;/blockquote&gt;  &lt;p&gt; &lt;br /&gt;4 Replace WaveID in above java script with your own waveid.  &lt;br /&gt;5 Find &amp;lt;body&amp;gt; .tag in blog template and replace it with &amp;lt;body onload="initialize()"&amp;gt;&lt;/p&gt;  &lt;p&gt;Note: This will add googlewave to all your blogs on blogger.&lt;/p&gt;  &lt;p&gt; &lt;br /&gt;6 Add a new Page Element in your blog (HMTL/Javascript type) and paste this code  &lt;br /&gt;&amp;lt;div id="waveframe" style="width: 500px; height: 100%"&amp;gt;&amp;lt;/div&amp;gt;  &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;set size . &lt;br /&gt;7: Thats all .&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-187455514827129924?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/187455514827129924/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=187455514827129924' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/187455514827129924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/187455514827129924'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/how-to-embed-googlewave-on-blogblogger.html' title='How to embed GoogleWave on blog(blogger)'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-7575904699137575209</id><published>2009-08-01T14:32:00.000-07:00</published><updated>2009-08-01T14:32:00.499-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Static Constructor</title><content type='html'>What is Static Constructor:&lt;br /&gt;C# supports two types of Constructor&lt;br /&gt;1.Class Constructor or Static Constructor-used to initialize static data members as soon as the class is referenced first time&lt;br /&gt;2.Instance Constructor or non-Static Constructor-used to create an instance of that class with new keyword.&lt;br /&gt;Static Data Member can be initialized at the time of their declaration(clsWithoutStaticConstructor in the following example) but there are times when value of one static member (clsWithStaticConstructor in the following example)may depend upon the value of another static member.&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;namespace StaticConstructor&lt;br /&gt;{&lt;br /&gt;   class clsWithoutStaticConstructor&lt;br /&gt;   {&lt;br /&gt;       private static int numStatData = 8;&lt;br /&gt;       public static int StatData&lt;br /&gt;       {&lt;br /&gt;           get { return numStatData; }&lt;br /&gt;       }&lt;br /&gt;       public static void print()&lt;br /&gt;       {&lt;br /&gt;           Console.WriteLine("Static Data :" + StatData);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;   class clsWithStaticConstructor&lt;br /&gt;   {&lt;br /&gt;     &lt;br /&gt;       private static int numStatData2;&lt;br /&gt;       static clsWithStaticConstructor()&lt;br /&gt;       {&lt;br /&gt;          &lt;br /&gt;           if (clsWithoutStaticConstructor.StatData &lt; 10)&lt;br /&gt;           {&lt;br /&gt;               numStatData2 = 10;&lt;br /&gt;           }&lt;br /&gt;           else&lt;br /&gt;           {&lt;br /&gt;               numStatData2 = 100;&lt;br /&gt;           }&lt;br /&gt;           Console.WriteLine("Static Constructor is called...");&lt;br /&gt;       }&lt;br /&gt;       public static void print2()&lt;br /&gt;       {&lt;br /&gt;           Console.WriteLine("Static Data :" + numStatData2);&lt;br /&gt;           Console.ReadLine();&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;   class Program&lt;br /&gt;   {&lt;br /&gt;      &lt;br /&gt;       static void Main(string[] args)&lt;br /&gt;       {&lt;br /&gt;           clsWithoutStaticConstructor.print();&lt;br /&gt;           clsWithStaticConstructor.print2();&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Output :&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_1EZkGmmHBwc/Skdt7iO3j9I/AAAAAAAAA3U/8JrMtWlcNj8/s1600-h/1.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 336px; height: 139px;" src="http://3.bp.blogspot.com/_1EZkGmmHBwc/Skdt7iO3j9I/AAAAAAAAA3U/8JrMtWlcNj8/s400/1.JPG" alt="" id="BLOGGER_PHOTO_ID_5352367551722000338" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In the above example "numStatData2" in "clsWithStaticConstructor" is initialized based on the value of clsWithoutStaticConstructor.StatData .since StatData in the clsWithoutStaticConstructor is initilized to 8 so the value of numStatData2 is set to 10.&lt;br /&gt;&lt;br /&gt;Static Constructor executes:&lt;br /&gt;-before any instance of the class is created.&lt;br /&gt;-before any of the static members for the class are referenced.&lt;br /&gt;-after the static field initializers(if any) for the class.&lt;br /&gt;-atmost one time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-7575904699137575209?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/7575904699137575209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=7575904699137575209' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7575904699137575209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7575904699137575209'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/08/static-constructor.html' title='Static Constructor'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_1EZkGmmHBwc/Skdt7iO3j9I/AAAAAAAAA3U/8JrMtWlcNj8/s72-c/1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-7344336293062793603</id><published>2009-07-30T17:39:00.000-07:00</published><updated>2009-07-30T17:39:00.595-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Design Patterns in C#</title><content type='html'>Design patterns are recurring solutions to software design problems you find again and again in real-world application development. Patterns are about design and interaction of objects, as well as providing a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges.&lt;br /&gt;&lt;br /&gt; &lt;strong&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Creational Patterns&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;  &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternAbstract.aspx"&gt;Abstract Factory&lt;/a&gt;&lt;br /&gt; Creates an instance of several families of classes&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternBuilder.aspx"&gt;Builder&lt;/a&gt;&lt;br /&gt; Separates object construction from its representation&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternFactory.aspx"&gt;Factory Method&lt;/a&gt;&lt;br /&gt; Creates an instance of several derived classes&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternPrototype.aspx"&gt;Prototype&lt;/a&gt;&lt;br /&gt; A fully initialized instance to be copied or cloned&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternSingleton.aspx"&gt;Singleton&lt;/a&gt;&lt;br /&gt; A class of which only a single instance can exist&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color: rgb(255, 0, 0);"&gt; Structural Patterns&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;  &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternAdapter.aspx"&gt;Adapter&lt;/a&gt;&lt;br /&gt; Match interfaces of different classes&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternBridge.aspx"&gt;Bridge&lt;/a&gt;&lt;br /&gt; Separates an object’s interface from its implementation&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternComposite.aspx"&gt;Composite&lt;/a&gt;&lt;br /&gt; A tree structure of simple and composite objects&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternDecorator.aspx"&gt;Decorator&lt;/a&gt;&lt;br /&gt; Add responsibilities to objects dynamically&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternFacade.aspx"&gt;Facade&lt;/a&gt;&lt;br /&gt; A single class that represents an entire subsystem&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternFlyweight.aspx"&gt;Flyweight&lt;/a&gt;&lt;br /&gt; A fine-grained instance used for efficient sharing&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternProxy.aspx"&gt;Proxy&lt;/a&gt;&lt;br /&gt; An object representing another object&lt;br /&gt;&lt;br /&gt; &lt;strong&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Behavioral Patterns&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternChain.aspx"&gt;Chain of Resp.&lt;/a&gt;&lt;br /&gt; A way of passing a request between a chain of objects&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternCommand.aspx"&gt;Command&lt;/a&gt;&lt;br /&gt; Encapsulate a command request as an object&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternInterpreter.aspx"&gt;Interpreter&lt;/a&gt;&lt;br /&gt; A way to include language elements in a program&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternIterator.aspx"&gt;Iterator&lt;/a&gt;&lt;br /&gt; Sequentially access the elements of a collection&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternMediator.aspx"&gt;Mediator&lt;/a&gt;&lt;br /&gt; Defines simplified communication between classes&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternMemento.aspx"&gt;Memento&lt;/a&gt;&lt;br /&gt; Capture and restore an object's internal state&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternObserver.aspx"&gt;Observer&lt;/a&gt;&lt;br /&gt; A way of notifying change to a number of classes&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternState.aspx"&gt;State&lt;/a&gt;&lt;br /&gt; Alter an object's behavior when its state changes&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternStrategy.aspx"&gt;Strategy&lt;/a&gt;&lt;br /&gt; Encapsulates an algorithm inside a class&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternTemplate.aspx"&gt;Template Method&lt;/a&gt;&lt;br /&gt; Defer the exact steps of an algorithm to a subclass&lt;br /&gt; &lt;a class="alwayson" href="http://www.dofactory.com/Patterns/PatternVisitor.aspx"&gt;Visitor&lt;/a&gt;&lt;br /&gt; Defines a new operation to a class without change&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-7344336293062793603?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/7344336293062793603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=7344336293062793603' title='27 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7344336293062793603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7344336293062793603'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/design-patterns-in-c.html' title='Design Patterns in C#'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>27</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-1358382075080797420</id><published>2009-07-29T17:06:00.003-07:00</published><updated>2009-07-29T17:06:52.747-07:00</updated><title type='text'>Whats New In Entity Framework 4</title><content type='html'>Check out this SlideShare Presentation: &lt;div style="width:425px;text-align:left" id="__ss_1546902"&gt;&lt;a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/KulveerSingh/whats-new-in-entity-framework-4" title="Whats New In Entity Framework 4"&gt;Whats New In Entity Framework 4&lt;/a&gt;&lt;object style="margin:0px" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=whatsnewinentityframework4-124443868938-phpapp02&amp;stripped_title=whats-new-in-entity-framework-4" /&gt;&lt;param name="allowFullScreen" value="true"/&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=whatsnewinentityframework4-124443868938-phpapp02&amp;stripped_title=whats-new-in-entity-framework-4" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"&gt;View more &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/KulveerSingh"&gt;KulveerSingh&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-1358382075080797420?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/1358382075080797420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=1358382075080797420' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1358382075080797420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1358382075080797420'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/whats-new-in-entity-framework-4.html' title='Whats New In Entity Framework 4'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-6594802536706052209</id><published>2009-07-29T17:06:00.001-07:00</published><updated>2009-07-29T17:06:30.107-07:00</updated><title type='text'>Whats New In Adonet Data Services 1.5</title><content type='html'>Check out this SlideShare Presentation: &lt;div style="width:425px;text-align:left" id="__ss_1546905"&gt;&lt;a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/KulveerSingh/whats-new-in-adonet-data-services-15" title="Whats New In Adonet Data Services 1.5"&gt;Whats New In Adonet Data Services 1.5&lt;/a&gt;&lt;object style="margin:0px" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=whatsnewinadonetdataservices15-124443882757-phpapp02&amp;stripped_title=whats-new-in-adonet-data-services-15" /&gt;&lt;param name="allowFullScreen" value="true"/&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=whatsnewinadonetdataservices15-124443882757-phpapp02&amp;stripped_title=whats-new-in-adonet-data-services-15" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"&gt;View more &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/KulveerSingh"&gt;KulveerSingh&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-6594802536706052209?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/6594802536706052209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=6594802536706052209' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6594802536706052209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/6594802536706052209'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/whats-new-in-adonet-data-services-15.html' title='Whats New In Adonet Data Services 1.5'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-3313541774590838797</id><published>2009-07-29T17:05:00.003-07:00</published><updated>2009-07-29T17:05:54.411-07:00</updated><title type='text'>ASP.NET 4 and AJAX</title><content type='html'>Check out this SlideShare Presentation: &lt;div style="width:425px;text-align:left" id="__ss_1566686"&gt;&lt;a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/KulveerSingh/ajax4" title="ASP.NET 4 and AJAX"&gt;ASP.NET 4 and AJAX&lt;/a&gt;&lt;object style="margin:0px" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=ajax4-1244710005-phpapp02&amp;stripped_title=ajax4" /&gt;&lt;param name="allowFullScreen" value="true"/&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=ajax4-1244710005-phpapp02&amp;stripped_title=ajax4" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"&gt;View more &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/KulveerSingh"&gt;KulveerSingh&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-3313541774590838797?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/3313541774590838797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=3313541774590838797' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3313541774590838797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3313541774590838797'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/aspnet-4-and-ajax.html' title='ASP.NET 4 and AJAX'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-1044269822433102390</id><published>2009-07-29T17:05:00.001-07:00</published><updated>2009-07-29T17:05:18.135-07:00</updated><title type='text'>Whats New In C Sharp 4 And Vb 10</title><content type='html'>Check out this SlideShare Presentation: &lt;div style="width:425px;text-align:left" id="__ss_1546899"&gt;&lt;a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/KulveerSingh/whats-new-in-csharp-4-and-vb-10" title="Whats New In C Sharp 4 And Vb 10"&gt;Whats New In C Sharp 4 And Vb 10&lt;/a&gt;&lt;object style="margin:0px" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=whatsnewincsharp4andvb10-124443853219-phpapp02&amp;stripped_title=whats-new-in-csharp-4-and-vb-10" /&gt;&lt;param name="allowFullScreen" value="true"/&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=whatsnewincsharp4andvb10-124443853219-phpapp02&amp;stripped_title=whats-new-in-csharp-4-and-vb-10" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"&gt;View more &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/KulveerSingh"&gt;KulveerSingh&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-1044269822433102390?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/1044269822433102390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=1044269822433102390' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1044269822433102390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/1044269822433102390'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/whats-new-in-c-sharp-4-and-vb-10.html' title='Whats New In C Sharp 4 And Vb 10'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-353182675663439164</id><published>2009-07-28T13:24:00.000-07:00</published><updated>2009-07-28T13:24:48.983-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Interfaces in C# part2</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/oSpxItSswZk&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/oSpxItSswZk&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-353182675663439164?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/353182675663439164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=353182675663439164' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/353182675663439164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/353182675663439164'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/interfaces-in-c-part2.html' title='Interfaces in C# part2'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-4994337688303865513</id><published>2009-07-28T13:20:00.000-07:00</published><updated>2009-07-28T13:26:36.718-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Interfaces in C# Part1</title><content type='html'>&lt;object width="640" height="505"&gt;&lt;param name="movie" value="http://www.youtube.com/v/VjZjjw97oiU&amp;hl=en&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/VjZjjw97oiU&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-4994337688303865513?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/4994337688303865513/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=4994337688303865513' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4994337688303865513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/4994337688303865513'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/interfaces-in-c-part1.html' title='Interfaces in C# Part1'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-8150166336410145107</id><published>2009-07-28T07:54:00.000-07:00</published><updated>2009-07-28T07:54:00.503-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET Interview Questions'/><title type='text'>SharePoint Server Interview Questions(Part3)</title><content type='html'>&lt;p&gt;&lt;b&gt;SharePoint Server Interview Questions (Part3)&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;30) When would you use an event receiver?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Since event receivers respond to events, you could use a receiver for something as simple as canceling an action, such as deleting a document library by using the Cancel property. This would essentially prevent users from deleting any documents if you wanted to maintain retention of stored data.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;31) What base class do event receivers inherit from?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Event receivers either inherit from the SPListEventReciever base class or the SPItemEventReciever base class, both which derive from the abstract base class SPEventReceiverBase.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;32) If I wanted to not allow people to delete documents from a document library, how would I go about it?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You would on the ItemDeleting event set: properties.Cancel= true.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;33) What is the difference between an asynchronous and synchronous event receivers?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;An asynchronous event occurs after an action has taken place, and a synchronous event occurs before an action has take place. For example, an asynchronous event is ItemAdded, and its sister synchronous event is ItemAdding.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;34) How could you append a string to the title of a site when it is provisioned?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In the OnActivated event:&lt;/p&gt;  &lt;p class="MsoNormal" style="background:#D6D3CE"&gt;&lt;span style="font-family:Courier;"&gt;&lt;a href="http://www.sharepointsecurity.com/blog/sharepoint/sharepoint-2007-development/sharepoint-developer-interview-questions-answers/##"&gt;Select For Unformatted Code&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="background:#FEFEFE"&gt;&lt;b&gt;&lt;span style=" ;font-size:7.0pt;color:black;"&gt;C#:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:7.0pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1;tab-stops:list .5in; background:#FEFEFE"&gt;&lt;span style=" font-family:&amp;quot;Courier New&amp;quot;;mso-fareast-Courier New&amp;quot;;font-family:&amp;quot;;font-size:7.0pt;color:#368F02;"&gt;&lt;span style="mso-list:Ignore"&gt;1.&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="Courier New&amp;quot;; font-family:&amp;quot;;font-size:7.0pt;color:#368F02;"&gt;SPWeb site = siteCollection.&lt;/span&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:7.0pt;color:blue;"&gt;RootWeb&lt;/span&gt;&lt;span style="Courier New&amp;quot;;font-family:&amp;quot;;font-size:7.0pt;color:#368F02;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1;tab-stops:list .5in; background:#FEFEFE"&gt;&lt;span style=" font-family:&amp;quot;Courier New&amp;quot;;mso-fareast-Courier New&amp;quot;;font-family:&amp;quot;;font-size:7.0pt;color:#368F02;"&gt;&lt;span style="mso-list:Ignore"&gt;2.&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="Courier New&amp;quot;; font-family:&amp;quot;;font-size:7.0pt;color:#368F02;"&gt;site.&lt;/span&gt;&lt;span style="Courier New&amp;quot;; font-family:&amp;quot;;font-size:7.0pt;color:blue;"&gt;Title&lt;/span&gt;&lt;span style="Courier New&amp;quot;; font-family:&amp;quot;;font-size:7.0pt;color:#368F02;"&gt; += &lt;/span&gt;&lt;span style="Courier New&amp;quot;; font-family:&amp;quot;;font-size:7.0pt;color:gray;"&gt;"interview"&lt;/span&gt;&lt;span style=" Courier New&amp;quot;;font-family:&amp;quot;;font-size:7.0pt;color:#368F02;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; margin-left:.5in;text-indent:-.25in;mso-list:l0 level1 lfo1;tab-stops:list .5in; background:#FEFEFE"&gt;&lt;span style=" font-family:&amp;quot;Courier New&amp;quot;;mso-fareast-Courier New&amp;quot;;font-family:&amp;quot;;font-size:7.0pt;color:#368F02;"&gt;&lt;span style="mso-list:Ignore"&gt;3.&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="Courier New&amp;quot;; font-family:&amp;quot;;font-size:7.0pt;color:#368F02;"&gt;site.&lt;/span&gt;&lt;span style="Courier New&amp;quot;; font-family:&amp;quot;;font-size:7.0pt;color:blue;"&gt;Update&lt;/span&gt;&lt;span style="Courier New&amp;quot;; font-family:&amp;quot;;font-size:7.0pt;color:black;"&gt;()&lt;/span&gt;&lt;span style="Courier New&amp;quot;; font-family:&amp;quot;;font-size:7.0pt;color:#368F02;"&gt;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;35) Can an event receiver be deployed through a SharePoint feature?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Yes.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;36) What is a content type?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;A content type is an information blueprint basically that can be re-used throughout a SharePoint environment for defining things like metadata and associated behaviors. It is basically an extension of a SharePoint list, however makes it portable for use throughout an instance regardless of where the instantiation occurs, ergo has location independence. Multiple content types can exist in one document library assuming that the appropriate document library settings are enabled. The content type will contain things like the metadata, listform pages, workflows, templates (if a document content type), and associated custom written functionality.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;37) Can a content type have receivers associated with it?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Yes, a content type can have an event receiver associated with it, either inheriting from the SPListEventReciever base class for list level events, or inheriting from the SPItemEventReciever base class. Whenever the content type is instantiated, it will be subject to the event receivers that are associated with it.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;38) What two files are typically (this is kept generally) included when developing a content type, and what is the purpose of each?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;There is generally the main content type file that holds things like the content type ID, name, group, description, and version. There is also the ContentType.Fields file which contains the fields to include in the content type that has the ID, Type, Name, DisplayName, StaticName, Hidden, Required, and Sealed elements. They are related by the FieldRefs element in the main content type file.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;39) What is an ancestral type and what does it have to do with content types?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;An ancestral type is the base type that the content type is deriving from, such as Document (0x0101). The ancestral type will define the metadata fields that are included with the custom content type.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;40) Can a list definition be derived from a custom content type?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Yes, a list definition can derive from a content type which can be seen in the schema.XML of the list definition in the element.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;41) When creating a list definition, how can you create an instance of the list?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can create a new instance of a list by creating an instance.XML file.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;42) What is a Field Control?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Field controls are simple ASP.NET 2.0 server controls that provide the basic field functionality of SharePoint. They provide basic general functionality such as displaying or editing list data as it appears on SharePoint list pages.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;43) What base class do custom Field Controls inherit from?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This varies. Generally, custom field controls inherit from the Microsoft.SharePoint.WebControls.BaseFieldControl namespace, but you can inherit from the default field controls.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;44) What is a SharePoint site definition? What is ghosted (uncustomized) and unghosted (customized)?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;SharePoint site definitions are the core set of functionality from which SharePoint site are built from, building from the SiteTemplates directory in the SharePoint 12 hive. Site definitions allow several sites to inherit from a core set of files on the file system, although appear to have unique pages, thereby increasing performance and allowing changes that happen to a site propagate to all sites that inherit from a site definition. Ghosted means that when SharePoint creates a new site it will reference the files in the related site definition upon site provisioning. Unghosted means that the site has been edited with an external editor, and therefore the customizations are instead stored in the database, breaking the inheritance of those files from the file system.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;45) How does one deploy new SharePoint site definitions so that they are made aware to the SharePoint system?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The best way to deploy site definitions in the SharePoint 2007 framework is to use a SharePoint solution file, so that the new site definition is automatically populated to all WFE’s in the SharePoint farm. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-8150166336410145107?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/8150166336410145107/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=8150166336410145107' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8150166336410145107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/8150166336410145107'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/sharepoint-server-interview_28.html' title='SharePoint Server Interview Questions(Part3)'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-7720063853306101569</id><published>2009-07-27T21:26:00.000-07:00</published><updated>2009-07-27T21:26:01.062-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET Interview Questions'/><title type='text'>WebServices And Windows Services Questions</title><content type='html'>Can you give an example of when it would be appropriate to use a web service as opposed to non-serviced .NET component&lt;br /&gt;Web service is one of main component in Service Oriented Architecture. You could use web services when your clients and servers are running on different networks and also different platforms. This provides a loosely coupled system. And also if the client is behind the firewall it would be easy to use web service since it runs on port 80 (by default) instead of having some thing else in Service Oriented Architecture applications.&lt;br /&gt;What is the standard you use to wrap up a call to a Web service&lt;br /&gt;"SOAP.&lt;br /&gt;"&lt;br /&gt;What is the transport protocol you use to call a Web service SOAP&lt;br /&gt;HTTP with SOAP&lt;br /&gt;&lt;br /&gt;What does WSDL stand for?&lt;br /&gt;"WSDL stands for Web Services Dsescription Langauge. There is WSDL.exe that creates a .wsdl Files which defines how an XML Web service behaves and instructs clients as to how to interact with the service.&lt;br /&gt;eg: wsdl http://LocalHost/WebServiceName.asmx"&lt;br /&gt;&lt;br /&gt;Where on the Internet would you look for Web Services?&lt;br /&gt;www.uddi.org&lt;br /&gt;&lt;br /&gt;What does WSDL stand for?&lt;br /&gt;Web Services Description Language&lt;br /&gt;&lt;br /&gt;True or False: To test a Web service you must create a windows application or Web application to consume this service?&lt;br /&gt;False.&lt;br /&gt;&lt;br /&gt;What are the various ways of accessing a web service ?&lt;br /&gt;1.Asynchronous Call&lt;br /&gt;  Application can make a call to the Webservice and then continue todo watever oit  wants to do.When the service is ready it will notify the application.Application  can use BEGIN and END method to make asynchronous call to the webmethod.We can use  either a WaitHandle or a Delegate object when making asynchronous call.&lt;br /&gt;The WaitHandle class share resources between several objects. It provides several  methods which will wait for the resources to become available&lt;br /&gt;The easiest and most powerful way to to implement an asynchronous call is using a  delegate object. A delegate object wraps up a callback function. The idea is to  pass a method in the invocation of the web method. When the webmethod has finished  it will call this callback function to process the result&lt;br /&gt;&lt;br /&gt;2.Synchronous Call&lt;br /&gt;Application has to wait until execution has completed.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What are VSDISCO files?&lt;br /&gt;VSDISCO files are DISCO files that support dynamic discovery of Web services. If you place the following VSDISCO file in a directory on your Web server, for example, it returns   references to all ASMX and DISCO files in the host directory and any subdirectories not noted in &lt;exclude&gt;elements:&lt;br /&gt;&lt;br /&gt;            &lt;br /&gt;                &lt;DYNAMICDISCOVERY&lt;br /&gt;                  xmlns="urn:schemas-dynamicdiscovery:disco.2000-03-17"&gt;&lt;br /&gt;                  &lt;exclude path="_vti_cnf"&gt;&lt;br /&gt;                  &lt;exclude path="_vti_pvt"&gt;&lt;br /&gt;                  &lt;exclude path="_vti_log"&gt;&lt;br /&gt;                  &lt;exclude path="_vti_script"&gt;&lt;br /&gt;                  &lt;exclude path="_vti_txt"&gt;&lt;br /&gt;                &lt;/dynamicdiscovery&gt;  &lt;br /&gt;&lt;br /&gt;How does dynamic discovery work?&lt;br /&gt;ASP.NET maps the file name extension VSDISCO to an HTTP handler that scans the host  directory and subdirectories for ASMX and DISCO files and returns a dynamically generated DISCO document. A client who requests a VSDISCO file gets back what appears to be a static DISCO document.&lt;br /&gt;&lt;br /&gt;Note that VSDISCO files are disabled in the release version of ASP.NET. You can reenable them by uncommenting the line   in the &lt;httphandlers&gt;section of Machine.config that maps *.vsdisco to System.Web.Services.Discovery.DiscoveryRequestHandler and granting the ASPNET  user account permission to read the IIS metabase. However, Microsoft is actively discouraging the use of VSDISCO files because they could represent a threat to Web server security.&lt;br /&gt;&lt;br /&gt;Is it possible to prevent a browser from caching an ASPX page?&lt;br /&gt;Just call SetNoStore on the HttpCachePolicy object exposed through the Response object's Cache property, as demonstrated here:&lt;br /&gt;&lt;br /&gt;        &lt;%@ Page Language="C#" %&gt;&lt;br /&gt;       &lt;br /&gt;         &lt;br /&gt;            &lt;%&lt;br /&gt;              Response.Cache.SetNoStore ();&lt;br /&gt;              Response.Write (DateTime.Now.ToLongTimeString ());&lt;br /&gt;            %&gt;&lt;br /&gt;         &lt;br /&gt;         &lt;br /&gt;&lt;br /&gt;SetNoStore works by returning a Cache-Control: private, no-store header in the HTTP response. In this example, it prevents caching of a Web page that shows the current time.&lt;br /&gt;&lt;br /&gt;What does AspCompat="true" mean and when should I use it?&lt;br /&gt;AspCompat is an aid in migrating ASP pages to ASPX pages. It defaults to false but should be set to true in any ASPX file that creates apartment-threaded COM objects--that is, COM objects registered ThreadingModel=Apartment. That includes all COM objects written with  Visual Basic 6.0. AspCompat should also be set to true (regardless of threading  model)  if the page creates COM objects that access intrinsic ASP objects such as Request and Response. The following directive sets AspCompat to true:&lt;br /&gt;         &lt;%@ Page AspCompat="true" %&gt; &lt;br /&gt;Setting AspCompat to true does two things. First, it makes intrinsic ASP objects available      to the COM components by placing unmanaged wrappers around the equivalent ASP.NET objects. Second, it improves the performance of calls that the page places to apartment- threaded COM objects by ensuring that the page (actually, the thread that processes the  request for the page) and the COM objects it creates share an apartment. AspCompat="true" forces ASP.NET request threads into single-threaded apartments (STAs). If those threads create COM objects marked ThreadingModel=Apartment, then the objects are created in the same STAs as the threads that created them. Without AspCompat="true," request threads run in a multithreaded apartment (MTA) and each call to an STA-based COM object incurs a performance hit when it's  marshaled across apartment boundaries.&lt;br /&gt;Do not set AspCompat to true if your page uses no COM objects or if it uses COM objects that don't access ASP intrinsic objects and that are registered ThreadingModel=Free or  ThreadingModel=Both.&lt;br /&gt;&lt;br /&gt;Can two different programming languages be mixed in a single ASMX file?&lt;br /&gt;No. &lt;br /&gt;&lt;br /&gt;What namespaces are imported by default in ASMX files?&lt;br /&gt;The following namespaces are imported by default. Other namespaces must be imported manually.• System, System.Collections,System.ComponentModel,System.Data, System.Diagnostics,System.Web,System.Web.Services &lt;br /&gt;How do I provide information to the Web Service when the information is required as a SOAP Header?&lt;br /&gt;The key here is the Web Service proxy you created using wsdl.exe or through Visual Studio .NET's Add Web Reference menu option. If you happen to download a WSDL file for a Web Service that requires a SOAP header, .NET will create a SoapHeader class in the proxy source file. Using the previous example:    &lt;br /&gt;      public class Service1 : System.Web.Services.Protocols.SoapHttpClientProtocol&lt;br /&gt;        {   &lt;br /&gt;            public AuthToken AuthTokenValue;       &lt;br /&gt;       &lt;br /&gt;        [System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/", IsNullable=false)]       &lt;br /&gt;            public class AuthToken : SoapHeader {        public string Token;    }}  &lt;br /&gt;    &lt;br /&gt;In this case, when you create an instance of the proxy in your main application file, you'll also create an instance of the AuthToken class and assign the string:    &lt;br /&gt;     Service1 objSvc = new Service1();&lt;br /&gt;     processingobjSvc.AuthTokenValue = new AuthToken();&lt;br /&gt;     objSvc.AuthTokenValue.Token = &lt;actual&gt;;&lt;br /&gt;     Web Servicestring strResult = objSvc.MyBillableWebMethod();  &lt;br /&gt;&lt;br /&gt;What is WSDL?&lt;br /&gt;WSDL is the Web Service Description Language, and it is implemented as a specific XML vocabulary. While it's very much more complex than what can be described here, there are two important aspects to WSDL with which you should be aware. First, WSDL provides instructions to consumers of Web Services to describe the layout and contents of the SOAP packets  the Web Service intends to issue. It's an interface description document, of sorts. And second, it isn't intended that you  read and interpret the WSDL. Rather, WSDL should be processed by machine, typically to generate proxy source code (.NET) or create dynamic proxies on the fly (the SOAP Toolkit or Web Service Behavior). &lt;br /&gt;&lt;br /&gt;What is a Windows Service and how does its lifecycle differ from a "standard" EXE?&lt;br /&gt;Windows service is a application that runs in the background. It is equivalent to a NT service.&lt;br /&gt;The executable created is not a Windows application, and hence you can't just click and run it . it needs to be installed as a service, VB.Net has a facility where we can add an installer to our program and then use a utility to install the service. Where as this is not the case with standard exe&lt;br /&gt;&lt;br /&gt;How can a win service developed in .NET be installed or used in Win98?&lt;br /&gt;Windows service cannot be installed on Win9x machines even though the .NET framework runs on machine.&lt;br /&gt;Can you debug a Windows Service? How ?&lt;br /&gt;Yes we can debug a Windows Service.&lt;br /&gt;Attach the WinDbg debugger to a service after the service starts  &lt;br /&gt;This method is similar to the method that you can use to attach a debugger to a process and then debug a process.  &lt;br /&gt;Use the process ID of the process that hosts the service that you want to debug  &lt;br /&gt;1 To determine the process ID (PID) of the process that hosts the service that you want to debug, use one of the following methods. &lt;br /&gt; • Method 1: Use the Task Manager&lt;br /&gt;  a. Right-click the taskbar, and then click Task Manager. The Windows Task Manager dialog box appears.&lt;br /&gt;  b. Click the Processes tab of the Windows Task Manager dialog box.&lt;br /&gt;  c. Under Image Name, click the image name of the process that hosts the service that you want to debug. Note the process ID of this process as specified by the value of the corresponding PID field.&lt;br /&gt; • Method 2: Use the Task List Utility (tlist.exe)&lt;br /&gt;  a. Click Start, and then click Run. The Run dialog box appears.&lt;br /&gt;  b. In the Open box, type cmd, and then click OK.&lt;br /&gt;  c. At the command prompt, change the directory path to reflect the location of the tlist.exe file on your computer.&lt;br /&gt;  &lt;br /&gt;   Note The tlist.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows&lt;br /&gt;  d. At the command prompt, type tlist to list the image names and the process IDs of all processes that are currently running on your computer.&lt;br /&gt;  &lt;br /&gt;   Note Make a note of the process ID of the process that hosts the service that you want to debug.&lt;br /&gt;2 At a command prompt, change the directory path to reflect the location of the windbg.exe file on your computer. &lt;br /&gt;  &lt;br /&gt; Note If a command prompt is not open, follow steps a and b of Method 1. The windbg.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows. &lt;br /&gt;3 At the command prompt, type windbg –p ProcessID to attach the WinDbg debugger to the process that hosts the service that you want to debug. &lt;br /&gt;  &lt;br /&gt; Note ProcessID is a placeholder for the process ID of the process that hosts the service that you want to debug. &lt;br /&gt; &lt;br /&gt;Use the image name of the process that hosts the service that you want to debug&lt;br /&gt;  &lt;br /&gt;You can use this method only if there is exactly one running instance of the process that hosts the service that you want to run. To do this, follow these steps:  &lt;br /&gt;1 Click Start, and then click Run. The Run dialog box appears. &lt;br /&gt;2 In the Open box, type cmd, and then click OK to open a command prompt. &lt;br /&gt;3 At the command prompt, change the directory path to reflect the location of the windbg.exe file on your computer. &lt;br /&gt;  &lt;br /&gt; Note The windbg.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows. &lt;br /&gt;4 At the command prompt, type windbg –pn ImageName to attach the WinDbg debugger to the process that hosts the service that you want to debug. &lt;br /&gt;  &lt;br /&gt; NoteImageName is a placeholder for the image name of the process that hosts the service that you want to debug. The "-pn" command-line option specifies that the ImageName command-line argument is the image name of a process. &lt;br /&gt;back to the top  &lt;br /&gt;Start the WinDbg debugger and attach to the process that hosts the service that you want to debug&lt;br /&gt;  &lt;br /&gt;1 Start Windows Explorer. &lt;br /&gt;2 Locate the windbg.exe file on your computer. &lt;br /&gt;  &lt;br /&gt; Note The windbg.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows &lt;br /&gt;3 Run the windbg.exe file to start the WinDbg debugger. &lt;br /&gt;4 On the File menu, click Attach to a Process to display the Attach to Process dialog box. &lt;br /&gt;5 Click to select the node that corresponds to the process that hosts the service that you want to debug, and then click OK. &lt;br /&gt;6 In the dialog box that appears, click Yes to save base workspace information. Notice that you can now debug the disassembled code of your service. &lt;br /&gt;Configure a service to start with the WinDbg debugger attached  &lt;br /&gt;You can use this method to debug services if you want to troubleshoot service-startup-related problems.  &lt;br /&gt;1 Configure the "Image File Execution" options. To do this, use one of the following methods: &lt;br /&gt; • Method 1: Use the Global Flags Editor (gflags.exe)&lt;br /&gt;  a. Start Windows Explorer.&lt;br /&gt;  b. Locate the gflags.exe file on your computer.&lt;br /&gt;  &lt;br /&gt;   Note The gflags.exe file is typically located in the following directory: C:\Program Files\Debugging Tools for Windows.&lt;br /&gt;  c. Run the gflags.exe file to start the Global Flags Editor.&lt;br /&gt;  d. In the Image File Name text box, type the image name of the process that hosts the service that you want to debug. For example, if you want to debug a service that is hosted by a process that has MyService.exe as the image name, type MyService.exe.&lt;br /&gt;  e. Under Destination, click to select the Image File Options option.&lt;br /&gt;  f. Under Image Debugger Options, click to select the Debugger check box.&lt;br /&gt;  g. In the Debugger text box, type the full path of the debugger that you want to use. For example, if you want to use the WinDbg debugger to debug a service, you can type a full path that is similar to the following: C:\Program Files\Debugging Tools for Windows\windbg.exe&lt;br /&gt;  h. Click Apply, and then click OK to quit the Global Flags Editor.&lt;br /&gt; • Method 2: Use Registry Editor&lt;br /&gt;  a. Click Start, and then click Run. The Run dialog box appears.&lt;br /&gt;  b. In the Open box, type regedit, and then click OK to start Registry Editor.&lt;br /&gt;  c. Warning If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.&lt;br /&gt;  &lt;br /&gt;   In Registry Editor, locate, and then right-click the following registry subkey:&lt;br /&gt;   HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options&lt;br /&gt;  d. Point to New, and then click Key. In the left pane of Registry Editor, notice that New Key #1 (the name of a new registry subkey) is selected for editing.&lt;br /&gt;  e. Type ImageName to replace New Key #1, and then press ENTER.&lt;br /&gt;  &lt;br /&gt;   Note ImageName is a placeholder for the image name of the process that hosts the service that you want to debug. For example, if you want to debug a service that is hosted by a process that has MyService.exe as the image name, type MyService.exe.&lt;br /&gt;  f. Right-click the registry subkey that you created in step e.&lt;br /&gt;  g. Point to New, and then click String Value. In the right pane of Registry Editor, notice that New Value #1, the name of a new registry entry, is selected for editing.&lt;br /&gt;  h. Replace New Value #1 with Debugger, and then press ENTER.&lt;br /&gt;  i. Right-click the Debugger registry entry that you created in step h, and then click Modify. The Edit String dialog box appears.&lt;br /&gt;  j. In the Value data text box, type DebuggerPath, and then click OK.&lt;br /&gt;  &lt;br /&gt;   Note DebuggerPath is a placeholder for the full path of the debugger that you want to use. For example, if you want to use the WinDbg debugger to debug a service, you can type a full path that is similar to the following: C:\Program Files\Debugging Tools for Windows\windbg.exe&lt;br /&gt;2 For the debugger window to appear on your desktop, and to interact with the debugger, make your service interactive. If you do not make your service interactive, the debugger will start but you cannot see it and you cannot issue commands. To make your service interactive, use one of the following methods: &lt;br /&gt; • Method 1: Use the Services console&lt;br /&gt;  a. Click Start, and then point to Programs.&lt;br /&gt;  b. On the Programs menu, point to Administrative Tools, and then click Services. The Services console appears.&lt;br /&gt;  c. In the right pane of the Services console, right-click ServiceName, and then click Properties.&lt;br /&gt;  &lt;br /&gt;   Note ServiceName is a placeholder for the name of the service that you want to debug.&lt;br /&gt;  d. On the Log On tab, click to select the Allow service to interact with desktop check box under Local System account, and then click OK.&lt;br /&gt; • Method 2: Use Registry Editor&lt;br /&gt;  a. In Registry Editor, locate, and then click the following registry subkey:&lt;br /&gt;   HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName&lt;br /&gt;   Note Replace ServiceName with the name of the service that you want to debug. For example, if you want to debug a service named MyService, locate and then click the following registry key:&lt;br /&gt;   HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService&lt;br /&gt;  b. Under the Name field in the right pane of Registry Editor, right-click Type, and then click Modify. The Edit DWORD Value dialog box appears.&lt;br /&gt;  c. Change the text in the Value data text box to the result of the binary OR operation with the binary value of the current text and the binary value, 0x00000100, as the two operands. The binary value, 0x00000100, corresponds to the SERVICE_INTERACTIVE_PROCESS constant that is defined in the WinNT.h header file on your computer. This constant specifies that a service is interactive in nature.&lt;br /&gt;3 When a service starts, the service communicates to the Service Control Manager how long the service must have to start (the time-out period for the service). If the Service Control Manager does not receive a "service started" notice from the service within this time-out period, the Service Control Manager terminates the process that hosts the service. This time-out period is typically less than 30 seconds. If you do not adjust this time-out period, the Service Control Manager ends the process and the attached debugger while you are trying to debug. To adjust this time-out period, follow these steps: &lt;br /&gt; a. In Registry Editor, locate, and then right-click the following registry subkey:&lt;br /&gt;  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control&lt;br /&gt; b. Point to New, and then click DWORD Value. In the right pane of Registry Editor, notice that New Value #1 (the name of a new registry entry) is selected for editing.&lt;br /&gt; c. Type ServicesPipeTimeout to replace New Value #1, and then press ENTER.&lt;br /&gt; d. Right-click the ServicesPipeTimeout registry entry that you created in step c, and then click Modify. The Edit DWORD Value dialog box appears.&lt;br /&gt; e. In the Value data text box, type TimeoutPeriod, and then click OK&lt;br /&gt;  &lt;br /&gt;  Note TimeoutPeriod is a placeholder for the value of the time-out period (in milliseconds) that you want to set for the service. For example, if you want to set the time-out period to 24 hours (86400000 milliseconds), type 86400000.&lt;br /&gt; f. Restart the computer. You must restart the computer for Service Control Manager to apply this change.&lt;br /&gt;4 Start your Windows service. To do this, follow these steps: &lt;br /&gt; a. Click Start, and then point to Programs.&lt;br /&gt; b. On the Programs menu, point to Administrative Tools, and then click Services. The Services console appears.&lt;br /&gt; c. In the right pane of the Services console, right-click ServiceName, and then click Start.&lt;br /&gt;  &lt;br /&gt;  Note ServiceName is a placeholder for the name of the service that you want to debug.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-7720063853306101569?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/7720063853306101569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=7720063853306101569' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7720063853306101569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/7720063853306101569'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/webservices-and-windows-services.html' title='WebServices And Windows Services Questions'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-3525637809530041538</id><published>2009-07-26T07:53:00.000-07:00</published><updated>2009-07-26T07:53:00.303-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET Interview Questions'/><title type='text'>SharePoint Server Interview Questions(Part2)</title><content type='html'>&lt;p&gt;&lt;b&gt;SharePoint Server Interview Questions (Part2)&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;19) What is the IDesignTimeHtmlProvider interface, and when can you use it in WebParts?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The IDesignTimeHtmlProvider interface uses the function GetDesignTimeHtml() which can contain your relevant render methods. It was helpful to use in 2003 since it allowed your WebPart to have a preview while a page was edited in FrontPage with the Webpart on it, because the GetDesignTimeHtml() method contains the HTML for the designer to render.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;20) What are WebPart properties, and what are some of the attributes you see when declaring WebPart properties in code?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;WebPart properties are just like ASP.NET control properties, they are used to interact with and specify attributes that should be applied to a WebPart by a user. Some of the attributes you see with ASP.NET 2.0 properties are WebDescription, WebDisplayName, Category, Personalizable, and WebBrowsable. Although most of these properties come from the System.Web.UI.WebControls.WebParts class, ones like Category come out of System.ComponentModel namespace.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;21) Why are properties important in WebPart development, and how have you exploited them in past development projects? What must each custom property have?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Properties are important because WebParts allow levels of personalization for each user. WebPart properties make it possible for a user to interact, adjust, and increase overall experience value with the programmatic assets that you develop without having the need to use an external editor or right any code. A very simple example of exploiting a property would be something like allowing the user to change the text on the WebPart design interface so that they can display whatever string of text they desire.&lt;/p&gt;  &lt;p&gt;Each custom property that you have must have the appropriate get and set accessor methods.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;22) What are ClassResources? How do you reference and deploy resources with an ASP.NET 2.0 WebPart?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;ClassResources are used when inheriting from the SharePoint.WebPart.WebPartPages.WebPart base class, and are defined in the SharePoint solution file as things that should be stored in the wpresources directory on the server. It is a helpful directory to use in order to deploy custom images. In ASP.NET 2.0, typically things such as images are referenced by embedding them as resources within an assembly. The good part about ClassResources is they can help to eliminate recompiles to change small interface adjustments or alterations to external JavaScript files.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;23) What is a SharePoint Solution File? How does it differ from WebPart .cab files in legacy development? What does it contain?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;A SharePoint solution file is essentially a .cabinet file with all a developers ustom componets suffixed with a .wsp extension that aids in deployment. The big difference with SharePoint solution files is is that a solution:&lt;/p&gt;  &lt;p&gt;allows deployment to all WFE’s in a farm&lt;/p&gt;  &lt;p&gt;is highly manageable from the interface allowing deployment, retraction, and versioning&lt;/p&gt;  &lt;p&gt;Can package all types of assets like site definitions, feature definitions (and associated components), Webparts, etc.&lt;/p&gt;  &lt;p&gt;Can provide Code Access Security provisioning to avoid GAC deployments&lt;/p&gt;  &lt;p&gt;Just to name a few things…&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;24) What is a .ddf file and what does it have to do with SharePoint Solution creation?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;A .ddf file is a data directive file and is used when building the SharePoint solution bundle specifying the source files and their destination locations. The important thing for someone to understand is that the .ddf file will be passed as a parameter to the MAKECAB utility to orchestrate construction of the SharePoint solution fiel.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;25) What file does a SharePoint solution package use to orchestrate (describe) its packaged contents?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The solution Manifest.XML file.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;26) What deployment mechanism can you use to instigate Code Access Security attributes for your WebParts?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;SharePoint solution files can add in order to handle code access security deployment issues. This is done in the element in the SharePoint solution manifest.XML, which makes it easier to get assemblies the appropriate permissions in order to operate in the bin directory of the web application.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;27) What is a SharePoint Feature? What files are used to define a feature?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;A SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances, such as at the farm, site collection, web, etc. Features have their own receiver architecture, which allow you to trap events such as when a feature is installing, uninstalling, activated, or deactivated. They are helpful because they allow ease of upgrades and versioning.&lt;/p&gt;  &lt;p&gt;The two files that are used to define a feature are the feature.xml and manifest file. The feature XML file defines the actual feature and will make SharePoint aware of the installed feature. The manifest file contains details about the feature such as functionality.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Side Question:&lt;/strong&gt; I got asked how the introduction of features has changed the concept of site definitions. SharePoint features are important when understanding the architecture of site definitions, since the ONET.XML file has been vastly truncated since it has several feature stapled on it.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;28) What types of SharePoint assets can be deployed with a SharePoint feature?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Features can do a lot. For example, you could deploy&lt;/p&gt;  &lt;p&gt;Simple site customizations&lt;/p&gt;  &lt;p&gt;Custom site navigation&lt;/p&gt;  &lt;p&gt;WebParts&lt;/p&gt;  &lt;p&gt;pages&lt;/p&gt;  &lt;p&gt;list types&lt;/p&gt;  &lt;p&gt;list instances&lt;/p&gt;  &lt;p&gt;event handlers&lt;/p&gt;  &lt;p&gt;workflows&lt;/p&gt;  &lt;p&gt;custom actions&lt;/p&gt;  &lt;p&gt;just to name a few….&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;29) What are event receivers?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Event receivers are classes that inherit from the SpItemEventReciever or SPListEventReciever base class (both of which derive out of the abstract base class SPEventRecieverBase), and provide the option of responding to events as they occur within SharePoint, such as adding an item or deleting an item.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-3525637809530041538?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/3525637809530041538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=3525637809530041538' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3525637809530041538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3525637809530041538'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/sharepoint-server-interview.html' title='SharePoint Server Interview Questions(Part2)'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-3263518977980995363</id><published>2009-07-25T21:23:00.000-07:00</published><updated>2009-07-25T21:23:00.417-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET Interview Questions'/><category scheme='http://www.blogger.com/atom/ns#' term='.NETFramework'/><title type='text'>Framework Support</title><content type='html'>Framework Support&lt;br /&gt;The .NET platform includes such an eCommerce framework called Commerce Server. At this point, there is no equivalent vendor-neutral framework in the J2EE space. With J2EE, you should assume that you will be building your new eCommerce solution from scratch&lt;br /&gt;Moreover, no matter what [J2EE] vendor you choose, if you expect a component framework that will allow you to quickly field complete e-business applications, you are in for a frustrating experience&lt;br /&gt;Language&lt;br /&gt;In the language arena, the choice is about as simple as it gets. J2EE supports Java, and only Java. It will not support any other language in the foreseeable future. The .NET platform supports every language except Java (although it does support a language that is syntactically and functionally equivalent to Java, C#). In fact, given the importance of the .NET platform as a language independent vehicle, it is likely that any language that comes out in the near future will include support for the .NET platform.&lt;br /&gt;Some companies are under the impression that J2EE supports other languages. Although both IBM's WebSphere and BEA's WebLogic support other languages, neither does it through their J2EE technology. There are only two official ways in the J2EE platform to access other languages, one through the Java Native Interface and the other through CORBA interoperability. Sun recommends the later approach. As Sun's Distinguished Scientist and Java Architect Rick Cattell said in a recent interview.&lt;br /&gt;Portability&lt;br /&gt;The reason that operating system portability is a possibility with J2EE is not so much because of any inherent portability of J2EE, as it is that most of the J2EE vendors support multiple operating systems. Therefore as long as one sticks with a given J2EE vendor and a given database vendor, moving from one operating system to another should be possible. This is probably the single most important benefit in favor of J2EE over the .NET platform, which is limited to the Windows operating system. It is worth noting, however, that Microsoft has submitted the specifications for C# and a subset of the .NET Framework (called the common language infrastructure) to ECMA, the group that standardizes JavaScript.&lt;br /&gt;J2EE offers an acceptable solution to ISVs when the product must be marketed to non-Windows customers, particularly when the J2EE platform itself can be bundled with the ISV's product as an integrated offering.&lt;br /&gt;If the primary customer base for the ISV is Windows customers, then  the .NET platform should be chosen.  It will provide much better performance at a much lower cost.&lt;br /&gt;&lt;br /&gt;Client device independence&lt;br /&gt;The major difference being that with Java, it is the presentation tier programmer that determines the ultimate HTML that will be delivered to the client, and with .NET, it is a Visual Studio.NET control.&lt;br /&gt;This Java approach has three problems. First, it requires a lot of code on the presentation tier, since every possible thin client system requires a different code path. Second, it is very difficult to test the code with every possible thin client system. Third, it is very difficult to add new thin clients to an existing application, since to do so involves searching through, and modifying a tremendous amount of presentation tier logic.&lt;br /&gt;The .NET Framework approach is to write device independent code that interacts with visual controls. It is the control, not the programmer, that is responsible for determining what HTML to deliver, based on the capabilities of the client device.. In the .NET Framework model, one can forget that such a thing as HTML even exists! Contd ....&lt;br /&gt;Conclusion&lt;br /&gt;Sun's J2EE vision is based on a family of specifications that can be implemented by many vendors. It is open in the sense that any company can license and implement the technology, but closed in the sense that it is controlled by a single vendor, and a self contained architectural island with very limited ability to interact outside of itself. One of J2EE's major disadvantages is that the choice of the platform dictates the use of a single programming language, and a programming language that is not well suited for most businesses. One of J2EE's major advantages is that most of the J2EE vendors do offer operating system portability.&lt;br /&gt;Microsoft's .NET platform vision is a family of products rather than specifications, with specifications used primarily to define points of interoperability. The major disadvantage of this approach is that if is limited to the Windows platform, so applications written for the .NET platform can only be run on .NET platforms. Their are several important advantages to the .NET platform:&lt;br /&gt;* The cost of developing applications is much lower, since standard business languages can be used and device independent presentation tier logic can be written.&lt;br /&gt;* The cost of running applications is much lower, since commodity hardware platforms (at 1/5 the cost of their Unix counterparts) can be used.&lt;br /&gt;* The ability to scale up is much greater, with the proved ability to support at least ten times the number of clients any J2EE platform has shown itself able to support.&lt;br /&gt;* Interoperability is much stronger, with industry standard eCollaboration built into the platform.&lt;br /&gt;What are the Main Features of .NET platform?&lt;br /&gt;Features of .NET Platform are :-&lt;br /&gt;Common Language Runtime&lt;br /&gt;Explains the features and benefits of the common language runtime, a run-time environment that manages the execution of code and provides services that simplify the development process.&lt;br /&gt;Assemblies&lt;br /&gt;Defines the concept of assemblies, which are collections of types and resources that form logical units of functionality. Assemblies are the fundamental units of deployment, version control, reuse, activation scoping, and security permissions.&lt;br /&gt;Application Domains&lt;br /&gt;Explains how to use application domains to provide isolation between applications.&lt;br /&gt;Runtime Hosts&lt;br /&gt;Describes the runtime hosts supported by the .NET Framework, including ASP.NET, Internet Explorer, and shell executables.&lt;br /&gt;Common Type System&lt;br /&gt;Identifies the types supported by the common language runtime.&lt;br /&gt;Metadata and Self-Describing Components&lt;br /&gt;Explains how the .NET Framework simplifies component interoperation by allowing compilers to emit additional declarative information, or metadata, into all modules and assemblies.&lt;br /&gt;Cross-Language Interoperability&lt;br /&gt;Explains how managed objects created in different programming languages can interact with one another.&lt;br /&gt;.NET Framework Security&lt;br /&gt;Describes mechanisms for protecting resources and code from unauthorized code and unauthorized users.&lt;br /&gt;.NET Framework Class Library&lt;br /&gt;Introduces the library of types provided by the .NET Framework, which expedites and optimizes the development process and gives you access to system functionality.&lt;br /&gt;What is the use of JIT ?&lt;br /&gt;JIT (Just - In - Time) is a compiler which converts MSIL code to Native Code (ie.. CPU-specific code that runs on the same computer architecture).&lt;br /&gt;Because the common language runtime supplies a JIT compiler for each supported CPU architecture, developers can write a set of MSIL that can be JIT-compiled and run on computers with different architectures. However, your managed code will run only on a specific operating system if it calls platform-specific native APIs, or a platform-specific class library.&lt;br /&gt;JIT compilation takes into account the fact that some code might never get called during execution. Rather than using time and memory to convert all the MSIL in a portable executable (PE) file to native code, it converts the MSIL as needed during execution and stores the resulting native code so that it is accessible for subsequent calls. The loader creates and attaches a stub to each of a type's methods when the type is loaded. On the initial call to the method, the stub passes control to the JIT compiler, which converts the MSIL for that method into native code and modifies the stub to direct execution to the location of the native code. Subsequent calls of the JIT-compiled method proceed directly to the native code that was previously generated, reducing the time it takes to JIT-compile and run the code.&lt;br /&gt;What meant of assembly &amp;amp; global assembly cache (gac) &amp;amp; Meta data.&lt;br /&gt;Assembly :-- An assembly is the primary building block of a .NET based application. It is a collection of functionality that is built, versioned, and deployed as a single implementation unit (as one or more files). All managed types and resources are marked either as accessible only within their implementation unit, or as accessible by code outside that unit. It overcomes the problem of 'dll Hell'.The .NET Framework uses assemblies as the fundamental unit for several purposes:&lt;br /&gt;•     Security &lt;br /&gt;•     Type Identity &lt;br /&gt;•     Reference Scope &lt;br /&gt;•    Versioning &lt;br /&gt;•     Deployment&lt;br /&gt;Global Assembly Cache :-- Assemblies can be shared among multiple applications on the machine by registering them in global Assembly cache(GAC). GAC is a machine wide a local cache of assemblies maintained by the .NET Framework. We can register the assembly to global assembly cache by using gacutil command.&lt;br /&gt;We can Navigate to the GAC directory, C:\winnt\Assembly in explore. In the tools menu select the cache properties; in the windows displayed you can set the memory limit in MB used by the GAC&lt;br /&gt;MetaData :--Assemblies have Manifests. This Manifest contains Metadata information of the Module/Assembly as well as it contains detailed Metadata of other assemblies/modules references (exported). It's the Assembly Manifest which differentiates between an Assembly and a Module.&lt;br /&gt;What are the mobile devices supported by .net platform&lt;br /&gt;The Microsoft .NET Compact Framework is designed to run on mobile devices such as mobile phones, Personal Digital Assistants (PDAs), and embedded devices. The easiest way to develop and test a Smart Device Application is to use an emulator.&lt;br /&gt;These devices are divided into two main divisions:&lt;br /&gt;1) Those that are directly supported by .NET (Pocket PCs, i-Mode phones, and WAP devices)&lt;br /&gt;2) Those that are not (Palm OS and J2ME-powered devices).&lt;br /&gt;What is GUID , why we use it and where?&lt;br /&gt;GUID :-- GUID is Short form of Globally Unique Identifier, a unique 128-bit number that is produced by the Windows OS or by some Windows applications to identify a particular component, application, file, database entry, and/or user. For instance, a Web site may generate a GUID and assign it to a user's browser to record and track the session. A GUID is also used in a Windows registry to identify COM DLLs. Knowing where to look in the registry and having the correct GUID yields a lot information about a COM object (i.e., information in the type library, its physical location, etc.). Windows also identifies user accounts by a username (computer/domain and username) and assigns it a GUID. Some database administrators even will use GUIDs as primary key values in databases.&lt;br /&gt;GUIDs can be created in a number of ways, but usually they are a combination of a few unique settings based on specific point in time (e.g., an IP address, network MAC address, clock date/time, etc.).&lt;br /&gt;Describe the difference between inline and code behind - which is best in a loosely coupled solution&lt;br /&gt;ASP.NET supports two modes of page development: Page logic code that is written inside runat="server"&gt; blocks within an .aspx file and dynamically compiled the first time the page is requested on the server. Page logic code that is written within an external class that is compiled prior to deployment on a server and linked ""behind"" the .aspx file at run time.&lt;br /&gt;Whats MSIL, and why should my developers need an appreciation of it if at all?&lt;br /&gt;When compiling the source code to managed code, the compiler translates the source into Microsoft intermediate language (MSIL). This is a CPU-independent set of instructions that can efficiently be converted to native code. Microsoft intermediate language (MSIL) is a translation used as the output of a number of compilers. It is the input to a just-in-time (JIT) compiler. The Common Language Runtime includes a JIT compiler for the conversion of MSIL to native code.&lt;br /&gt;Before Microsoft Intermediate Language (MSIL) can be executed it, must be converted by the .NET Framework just-in-time (JIT) compiler to native code. This is CPU-specific code that runs on the same computer architecture as the JIT compiler. Rather than using time and memory to convert all of the MSIL in a portable executable (PE) file to native code. It converts the MSIL as needed whilst executing, then caches the resulting native code so its accessible for any subsequent calls.&lt;br /&gt;How many .NET languages can a single .NET DLL contain?&lt;br /&gt;One&lt;br /&gt;What type of code (server or client) is found in a Code-Behind class?&lt;br /&gt;Server&lt;br /&gt;Whats an assembly?&lt;br /&gt;Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly.&lt;br /&gt;How many classes can a single .NET DLL contain?&lt;br /&gt;Unlimited.&lt;br /&gt;What is the difference between string and String ?&lt;br /&gt;No difference&lt;br /&gt;What is manifest?&lt;br /&gt;It is the metadata that describes the assemblies.&lt;br /&gt;What is metadata?&lt;br /&gt;Metadata is machine-readable information about a resource, or ""data about data."" Such information might include details on content, format, size, or other characteristics of a data&lt;br /&gt;source. In .NET, metadata includes type definitions, version information, external assembly references, and other standardized information.&lt;br /&gt;What are the types of assemblies?&lt;br /&gt;There are four types of assemblies in .NET:&lt;br /&gt;Static assemblies&lt;br /&gt;These are the .NET PE files that you create at compile time.&lt;br /&gt;Dynamic assemblies&lt;br /&gt;These are PE-formatted, in-memory assemblies that you dynamically create at runtime using the classes in the System.Reflection.Emit namespace.&lt;br /&gt;Private assemblies&lt;br /&gt;These are static assemblies used by a specific application.&lt;br /&gt;Public or shared assemblies&lt;br /&gt;These are static assemblies that must have a unique shared name and can be used by any application.&lt;br /&gt;An application uses a private assembly by referring to the assembly using a static path or through an XML-based application configuration file. While the CLR doesn't enforce versioning policies-checking whether the correct version is used-for private assemblies, it ensures that an&lt;br /&gt;application uses the correct shared assemblies with which the application was built. Thus, an application uses a specific shared assembly by referring to the specific shared assembly, and the CLR ensures that the correct version is loaded at runtime.&lt;br /&gt;In .NET, an assembly is the smallest unit to which you can associate a version number;&lt;br /&gt;What are delegates?where are they used ?&lt;br /&gt;A delegate defines a reference type that can be used to encapsulate a method with a specific signature. A delegate instance encapsulates a static or an instance method. Delegates are roughly similar to function pointers in C++; however, delegates are type-safe and secure.&lt;br /&gt;When do you use virutal keyword?.&lt;br /&gt;When we need to override a method of the base class in the sub class, then we give the virtual keyword in the base class method. This makes the method in the base class to be overridable. Methods, properties, and indexers can be virtual, which means that their implementation can be overridden in derived classes.&lt;br /&gt;What are class access modifiers ?&lt;br /&gt;Access modifiers are keywords used to specify the declared accessibility of a member or a type. This section introduces the four access modifiers:&lt;br /&gt;• Public  - Access is not restricted.&lt;br /&gt;• Protected  - Access is limited to the containing class or types derived from the containing class.&lt;br /&gt;• Internal - Access is limited to the current assembly.&lt;br /&gt;• Protected inertnal - Access is limited to the current assembly or types derived • from the containing class.&lt;br /&gt;• Private - Access is limited to the containing type.&lt;br /&gt;What Is Boxing And Unboxing?&lt;br /&gt;Boxing :- Boxing is an implicit conversion of a value type to the type object type&lt;br /&gt;Eg:-&lt;br /&gt;Consider the following declaration of a value-type variable:&lt;br /&gt;int i = 123;&lt;br /&gt;object o = (object) i;&lt;br /&gt;Boxing Conversion&lt;br /&gt;UnBoxing :- Unboxing is an explicit conversion from the type object to a value type&lt;br /&gt;Eg:&lt;br /&gt;int i = 123;          // A value type&lt;br /&gt;object box = i;       // Boxing&lt;br /&gt;int j = (int)box;     // Unboxing&lt;br /&gt;What is Value type and refernce type in .Net?.&lt;br /&gt;Value Type : A variable of a value type always contains a value of that type. The assignment to a variable of a value type creates a copy of the assigned value, while the assignment to a variable of a reference type creates a copy of the reference but not of the referenced object.&lt;br /&gt;The value types consist of two main categories:&lt;br /&gt;* Stuct Type&lt;br /&gt;* Enumeration Type&lt;br /&gt;Reference Type :Variables of reference types, referred to as objects, store references to the actual data. This section introduces the following keywords used to declare reference types:&lt;br /&gt;* Class&lt;br /&gt;* Interface&lt;br /&gt;* Delegate&lt;br /&gt;This section also introduces the following built-in reference types:&lt;br /&gt;* object&lt;br /&gt;* string&lt;br /&gt;What is the difference between structures and enumeration?.&lt;br /&gt;Unlike classes, structs are value types and do not require heap allocation. A variable of a struct type directly contains the data of the struct, whereas a variable of a class type contains a reference to the data. They are derived from System.ValueType class.&lt;br /&gt;Enum-&gt;An enum type is a distinct type that declares a set of named constants.They  are strongly typed constants. They are unique types that allow to declare symbolic names to integral values. Enums are value types, which means they contain their own value, can't inherit or be inherited from and assignment copies the value of one enum to another.&lt;br /&gt;public enum Grade&lt;br /&gt;{&lt;br /&gt;   A,&lt;br /&gt;   B,&lt;br /&gt;   C&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;What is namespaces?.&lt;br /&gt;Namespace is a logical naming scheme for group related types.Some class types that logically belong together they can be put into a common namespace. They prevent namespace collisions and they provide scoping. They are imported as "using" in C# or "Imports" in Visual Basic. It seems as if these directives specify a particular assembly, but they don't. A namespace can span multiple assemblies, and an assembly can define multiple namespaces. When the compiler needs the definition for a class type, it tracks  through each of the different imported namespaces to the type name and searches each referenced assembly until it is found.&lt;br /&gt;Namespaces can be nested. This is very similar to packages in Java as far as scoping is concerned.&lt;br /&gt;&lt;br /&gt;How do you create shared assemblies?.&lt;br /&gt;Just look through the definition of Assemblies..&lt;br /&gt;   *  An Assembly is a  logical unit of code&lt;br /&gt;   * Assembly physically exist as DLLs or EXEs&lt;br /&gt;   * One assembly can contain one or more files&lt;br /&gt;   * The constituent files can include any file types like image files, text files etc. along with DLLs or EXEs&lt;br /&gt;   * When you compile your source code by default the exe/dll generated is actually an assembly&lt;br /&gt;   * Unless your code is bundled as assembly it can not be used in any other application&lt;br /&gt;   * When you talk about version of a component you are actually talking about version of the assembly to which the component belongs.&lt;br /&gt;   * Every assembly file contains information about itself. This information is called as Assembly Manifest.&lt;br /&gt;Following steps are involved in creating shared assemblies :&lt;br /&gt;   * Create your DLL/EXE source code&lt;br /&gt;   * Generate unique assembly name using SN utility&lt;br /&gt;   * Sign your DLL/EXE with the private key by modifying AssemblyInfo file&lt;br /&gt;   * Compile your DLL/EXE&lt;br /&gt;   * Place the resultant DLL/EXE in global assembly cache using AL utility&lt;br /&gt;  &lt;br /&gt;What is global assembly cache?&lt;br /&gt;Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.&lt;br /&gt; There are several ways to deploy an assembly into the global assembly cache:&lt;br /&gt;• Use an installer designed to work with the global assembly cache. This is the preferred option for installing assemblies into the global assembly cache.&lt;br /&gt;• Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK.&lt;br /&gt;• Use Windows Explorer to drag assemblies into the cache.  &lt;br /&gt;What is MSIL?.&lt;br /&gt;When compiling to managed code, the compiler translates your source code into Microsoft intermediate language (MSIL), which is a CPU-independent set of instructions that can be efficiently converted to native code. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations. Before code can be run, MSIL must be converted to CPU-specific code, usually by a just-in-time (JIT) compiler. Because the common language runtime supplies one or more JIT compilers for each computer architecture it supports, the same set of MSIL can be JIT-compiled and run on any supported architecture.&lt;br /&gt;When a compiler produces MSIL, it also produces metadata. Metadata describes the types in your code, including the definition of each type, the signatures of each type's members, the members that your code references, and other data that the runtime uses at execution time. The MSIL and metadata are contained in a portable executable (PE) file that is based on and extends the published Microsoft PE and common object file format (COFF) used historically for executable content. This file format, which accommodates MSIL or native code as well as metadata, enables the operating system to recognize common language runtime images. The presence of metadata in the file along with the MSIL enables your code to describe itself, which means that there is no need for type libraries or Interface Definition Language (IDL). The runtime locates and extracts the metadata from the file as needed during execution.&lt;br /&gt;What is Jit compilers?.how many are available in clr?&lt;br /&gt;Just-In-Time compiler- it converts the language that you write in .Net into machine language that a computer can understand. there are tqo types of JITs one  is memory optimized &amp;amp; other  is performace optimized.&lt;br /&gt;What is tracing?Where it used.Explain few methods available&lt;br /&gt;Tracing refers to collecting information about the application while it is running. You use tracing  information to troubleshoot an application.&lt;br /&gt;Tracing allows us to observe and correct programming errors. Tracing enables you to record information in various log files about the errors that might occur at run time. You can analyze these log files to find the cause of the errors.&lt;br /&gt;In .NET we have objects called Trace Listeners. A listener is an object that receives the trace output and outputs it somewhere; that somewhere could be a window in your development environment, a file on your hard drive, a Windows Event log, a SQL Server or Oracle database, or any other customized data store.&lt;br /&gt;The System.Diagnostics namespace provides the interfaces, classes, enumerations and structures that are used for tracing The System.Diagnostics namespace provides two classes named Trace and Debug that are used for writing errors and application execution information in logs.&lt;br /&gt;All Trace Listeners have the following functions. Functionality of these functions is same except that the target media for the tracing output is determined by the Trace Listener.&lt;br /&gt;Method Name&lt;br /&gt;Result Fail   Outputs the specified text with the Call Stack.&lt;br /&gt;Write   Outputs the specified text.&lt;br /&gt;WriteLine    Outputs the specified text and a carriage return.&lt;br /&gt;Flush   Flushes the output buffer to the target media.&lt;br /&gt;Close   Closes the output stream in order to not receive the tracing/debugging output.&lt;br /&gt;How to set the debug mode?&lt;br /&gt;Debug Mode for ASP.NET applications - To set ASP.NET appplication in debugging mode, edit the application's web.config and assign the "debug" attribute in &lt;&gt; section to "true" as show below:&lt;br /&gt;&lt;&gt;&lt;br /&gt;  &lt;&gt;&lt;br /&gt;    &lt; defaultlanguage="vb" debug="true"&gt;&lt;br /&gt;....&lt;br /&gt;...&lt;br /&gt;..&lt;br /&gt;&lt; / configuration &gt;&lt;br /&gt;This case-sensitive attribute 'debug tells ASP.NET to generate symbols for dynamically generated files and enables the&lt;br /&gt;debugger to attach to the ASP.NET application. ASP.NET will detect this change automatically, without the need to restart the server. Debug Mode for ASP.NET Webservices - Debugging an XML Web service created with ASP.NET is similar to the debugging an ASP.NET Web application.&lt;br /&gt;What is the property available to check if the page posted or not?&lt;br /&gt;The Page_Load event handler in the page checks for IsPostBack property value, to ascertain whether the page is posted. The Page.IsPostBack gets a value indicating whether the page is being loaded in response to the client postback, or it is for the first time. The value of Page.IsPostBack is True, if the page is being loaded in response to the client postback; while its value is False, when the page is loaded for the first time. The Page.IsPostBack property facilitates execution of certain routine in Page_Load, only once (for e.g. in Page load, we need to set default value in controls, when page is loaded for the first time. On post back, we check for true value for IsPostback value and then invoke server-side code to&lt;br /&gt;update data).&lt;br /&gt;Which are the abstract classes available under system.xml namespace?&lt;br /&gt;The System.XML namespace provides XML related processing ability in .NET framework. XmlReader and XMLWriter are the two abstract classes at the core of .NET Framework XML classes:&lt;br /&gt;1. XmlReader provides a fast, forward-only, read-only cursor for processing an XML document stream.&lt;br /&gt;2. XmlWriter provides an interface for producing XML document streams that conform to the W3C's XML standards.&lt;br /&gt;Both XmlReader and XmlWriter are abstract base classes, which define the functionality that all derived classes must support.&lt;br /&gt;Is it possible to use multipe inheritance in .net?&lt;br /&gt;Multiple Inheritance is an ability to inherit from more than one base class i.e.  ability of a class to have more than one superclass, by inheriting from different sources and thus combine separately-defined behaviors in a single class. There are two types of multiple inheritance: multiple type/interface inheritance and multiple implementation inheritance. C# &amp;amp; VB.NET supports only multiple type/interface inheritance, i.e.&lt;br /&gt;you can derive an class/interface from multiple interfaces. There is no support for multiple implementation inheritance in .NET. That means a class can only derived from one class.&lt;br /&gt;What are the derived classes from xmlReader and xmlWriter?&lt;br /&gt;Both XmlReader and XmlWriter are abstract base classes, which define the functionality that all derived classes must support.&lt;br /&gt;There are three concrete implementations of XmlReader:&lt;br /&gt;       1.XmlTextReader&lt;br /&gt;       2.XmlNodeReader&lt;br /&gt;       3.XmlValidatingReader&lt;br /&gt;There are two concrete implementations of XmlWriter:&lt;br /&gt;       1.XmlTextWriter&lt;br /&gt;       2.XmlNodeWriter&lt;br /&gt;XmlTextReader and XmlTextWriter support reading data to/from text-based stream, while XmlNodeReader and XmlNodeWriter are designed for working with in-memory DOM tree structure. The custom readers and writers can also be developed to extend the built-in functionality of XmlReader and XmlWriter.&lt;br /&gt;What is managed and unmanaged code?&lt;br /&gt;The .NET framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. i.e., code executing under the control of the CLR is called managed code. For example, any code written in C# or Visual Basic .NET is managed code.&lt;br /&gt;Code that runs outside the CLR is referred to as "unmanaged code." COM components, ActiveX components, and Win32 API functions are examples of unmanaged code.&lt;br /&gt;How you deploy .NET assemblies?&lt;br /&gt;One way is simply use xcopy. others are use and the setup projects in .net. and one more way is use of nontuch deployment.&lt;br /&gt;What is Globalizationa and Localization ?&lt;br /&gt;Globalization is the process of creating an application that meets the needs of users from multiple cultures. It includes using the correct&lt;br /&gt;currency, date and time format, calendar, writing direction, sorting rules, and other issues. Accommodating these cultural differences in an application is called localization.Using classes of System.Globalization namespace, you can set application's current culture.&lt;br /&gt;This can be achieved by using any of the following 3 approaches.&lt;br /&gt;      1.      Detect and redirect&lt;br /&gt;      2.      Run-time adjustment&lt;br /&gt;      3.      Using Satellite assemblies.&lt;br /&gt;     &lt;br /&gt;Whate are Resource Files ? How are they used in .NET?&lt;br /&gt;Resource files are the files containing data that is logically deployed with an application.These files can contain data in a number of formats including strings, images and persisted objects. It has the main advantage of If we store data in these files then we don't need to compile these if the data get changed. In .NET we basically require them storing culture specific informations by localizing application's resources. You can deploy your resources using satellite assemblies.&lt;br /&gt;Difference between Dispose and Finallize method?&lt;br /&gt;Finalize method is used to free the memory used by some unmanaged resources like window handles (HWND). It's similar to the destructor syntax in C#. The GC calls this method when it founds no more references to the object. But, In some cases we may need release the memory used by the resources explicitely.To release the memory explicitly we need to implement the Dispose method of IDisposable interface.&lt;br /&gt;What is encapsulation ?&lt;br /&gt;Encapsulation is the ability to hide the internal workings of an object's behavior and its data. For instance, let's say you have a object named Bike and this object has a method named start(). When you create an instance of a Bike object and call its start() method you are not worried about what happens to accomplish this, you just want to make sure the state of the bike is changed to 'running' afterwards. This kind of behavior hiding is encapsulation and it makes programming much easier.&lt;br /&gt;How can you prevent your class to be inherated further?&lt;br /&gt;By setting Sealed - Key word&lt;br /&gt; public sealed class Planet&lt;br /&gt; {&lt;br /&gt;             //code goes here&lt;br /&gt; }&lt;br /&gt;class Moon:Planet&lt;br /&gt; {&lt;br /&gt;     //Not allowed as base class is sealed&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;     &lt;br /&gt;What is GUID and why we need to use it and in what condition? How this is created.&lt;br /&gt;A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever  a unique identifier is required. Such an identifier has a very low probability of being duplicated. Visual Studio .NET IDE has a utility under the tools menu to generate GUIDs.&lt;br /&gt;Why do you need to serialize.?&lt;br /&gt;We need to serialize the object,if you want to pass object from one  computer/application domain to another.Process of converting complex objects into stream of bytes that can be persisted or  transported.Namespace for serialization is System.Runtime.Serialization.The  ISerializable interface allows you to make any class Serializable..NET framework features 2 serializing method.&lt;br /&gt;1.Binary Serialization 2.XML Serialization&lt;br /&gt;What is inline schema, how does it works?&lt;br /&gt;Schemas can be included inside of XML file is called Inline Schemas.This is useful  when it is inconvenient to physically seprate the schema and the XML document.A  schema is an XML document that defines the structure, constraints, data types, and  relationships of the elements that constitute the data contained inside the XML  document or in another XML document.Schema can be an external file which uses the  XSD or XDR extension called external schema. Inline schema can take place even when validation is turned off.&lt;br /&gt;Describe the advantages of writing a managed code application instead of unmanaged one. What's involved in certain piece of code being managed?&lt;br /&gt;"Advantage includes automatic garbage collection,memory management,security,type checking,versioning&lt;br /&gt;Managed code is compiled for the .NET run-time environment. It runs in the Common Language Runtime (CLR), which is the heart of the .NET Framework. The CLR provides services such as security,&lt;br /&gt;memory management, and cross-language integration. Managed applications written to take advantage of the features of the CLR perform more efficiently and safely, and take better advantage of developers existing expertise in languages that support the .NET Framework.&lt;br /&gt;Unmanaged code includes all code written before the .NET Framework was introduced—this includes code written to use COM, native Win32, and Visual Basic 6. Because it does not run inside the .NET environment, unmanaged code cannot make use of any .NET managed facilities."&lt;br /&gt;What are multicast delegates ? give me an example ?&lt;br /&gt;Delegate that can have more than one element in its invocation List.&lt;br /&gt;using System;&lt;br /&gt;namespace SampleMultiCastDelegate&lt;br /&gt;{&lt;br /&gt;  class MultiCast&lt;br /&gt;  {&lt;br /&gt;    public delegate string strMultiCast(string s);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;MainClass defines the static methods having same signature as delegate.&lt;br /&gt;using System;&lt;br /&gt;namespace SampleMultiCastDelegate&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  public class MainClass&lt;br /&gt;  {&lt;br /&gt;    public MainClass()&lt;br /&gt;    {&lt;br /&gt;    }&lt;br /&gt;    public static string Jump(string s)&lt;br /&gt;    {&lt;br /&gt;      Console.WriteLine("Jump");&lt;br /&gt;      return String.Empty;&lt;br /&gt;    }&lt;br /&gt;    public static string Run(string s)&lt;br /&gt;    {&lt;br /&gt;      Console.WriteLine("Run");&lt;br /&gt;      return String.Empty;&lt;br /&gt;    }&lt;br /&gt;    public static string Walk(string s)&lt;br /&gt;    {&lt;br /&gt;      Console.WriteLine("Walk");&lt;br /&gt;      return String.Empty;     &lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The Main class:&lt;br /&gt;using System;&lt;br /&gt;using System.Threading;&lt;br /&gt;namespace SampleMultiCastDelegate&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  public class MainMultiCastDelegate&lt;br /&gt;  {&lt;br /&gt;    public static void Main()&lt;br /&gt;    {&lt;br /&gt;      MultiCast.strMultiCast  Run,Walk,Jump;&lt;br /&gt;      MultiCast.strMultiCast    myDelegate;&lt;br /&gt;       ///here mydelegate used the Combine method of System.MulticastDelegate&lt;br /&gt;      ///and the delegates combine &lt;br /&gt;      myDelegate=(MultiCast.strMultiCast)System.Delegate.Combine(Run,Walk);&lt;br /&gt;              &lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;Can a nested object be used in Serialization ?&lt;br /&gt;Yes. If a class that is to be serialized contains references to objects of other classes, and if those classes have been marked as serializable, then their objects are serialized too.&lt;br /&gt;Difference between int and int32 ?&lt;br /&gt;Both are same. System.Int32 is a .NET class. Int is an alias name for System.Int32.&lt;br /&gt;Describe the difference between a Thread and a Process?&lt;br /&gt;A Process is an instance of an running application. And a thread is the Execution stream of the Process. A process can have multiple Thread.&lt;br /&gt;When a process starts a specific memory area is allocated to it. When there is multiple thread in a process, each thread gets a memory for storing the variables in it and plus they can access to the global variables which is common for all the thread. Eg.A Microsoft Word is a Application. When you open a word file,an instance of the Word starts and a process is allocated to this instance which has one thread.&lt;br /&gt;What is the difference between an EXE and a DLL?&lt;br /&gt;You can create an objects of Dll but not of the EXE.&lt;br /&gt;Dll is an In-Process Component whereas EXE is an OUt-Process Component.&lt;br /&gt;Exe is for single use whereas you can use Dll for multiple use.&lt;br /&gt;Exe can be started as standalone where dll cannot be.&lt;br /&gt;What is strong-typing versus weak-typing? Which is preferred? Why?&lt;br /&gt;Strong typing implies that the types of variables involved in operations are associated to the variable, checked at compile-time, and require explicit conversion; weak typing implies that they are associated to the value, checked at run-time, and are implicitly converted as required. (Which is preferred is a disputable point, but I personally prefer strong typing because I like my errors to be found as soon as possible.)&lt;br /&gt;What is a PID? How is it useful when troubleshooting a system?&lt;br /&gt;PID is the process Id of the application in Windows. Whenever a process starts running in the Windows environment, it is associated with an individual process Id or PID.&lt;br /&gt;The PID (Process ID) a unique number for each item on the Process Tab, Image Name list. How do you get the PID to appear? In Task Manger, select the View menu, then select columns and check PID (Process Identifier).&lt;br /&gt;In Linux, PID is used to debug a process explicitly. However we cannot do this in a windows environment.&lt;br /&gt;Microsoft has launched a SDK called as Microsoft Operations Management (MOM). This uses the PID to find out which dll’s have been loaded by a process in the memory. This is essentially helpful in situations where the Process which has a memory leak is to be traced to a erring dll. Personally I have never used a PID, our Windows debugger does the things required to find out.&lt;br /&gt;What is the GAC? What problem does it solve?&lt;br /&gt;Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies that are to be shared by several applications on the computer. This area is typically the folder under windows or winnt in the machine.&lt;br /&gt;All the assemblies that need to be shared across applications need to be done through the Global assembly Cache only. However it is not necessary to install assemblies into the global assembly cache to make them accessible to COM interop or unmanaged code.&lt;br /&gt;There are several ways to deploy an assembly into the global assembly cache:&lt;br /&gt;• Use an installer designed to work with the global assembly cache. This is the preferred option for installing assemblies into the global assembly cache.&lt;br /&gt;• Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK.&lt;br /&gt;• Use Windows Explorer to drag assemblies into the cache.&lt;br /&gt;GAC solves the problem of DLL Hell and DLL versioning. Unlike earlier situations, GAC can hold two assemblies of the same name but different version. This ensures that the applications which access a particular assembly continue to access the same assembly even if another version of that assembly is installed on that machine.&lt;br /&gt;Describe what an Interface is and how it’s different from a Class.&lt;br /&gt;An interface is a structure of code which is similar to a class. An interface is a prototype for a class and is useful from a logical design perspective. Interfaces provide a means to define the protocols for a class without worrying about the implementation details. The syntax for creating interfaces follows:&lt;br /&gt;interface Identifier {&lt;br /&gt;  InterfaceBody&lt;br /&gt;}&lt;br /&gt;Identifier is the name of the interface and InterfaceBody refers to the abstract methods and static final variables that make up the interface. Because it is assumed that all the methods in an interface are abstract, it isn't necessary to use the abstract keyword&lt;br /&gt;An interface is a description of some of the members available from a class. In practice, the syntax typically looks similar to a class definition, except that there's no code defined for the methods — just their name, the arguments passed and the type of the value returned.&lt;br /&gt;So what good is it? None by itself. But you create an interface so that classes will implement it.&lt;br /&gt;But what does it mean to implement an interface. The interface acts as a contract or promise. If a class implements an interface, then it must have the properties and methods of the interface defined in the class. This is enforced by the compiler.&lt;br /&gt;Broadly the differentiators between classes and interfaces is as follows&lt;br /&gt;• Interface should not have any implementation.&lt;br /&gt;• Interface can not create any instance.&lt;br /&gt;• Interface should provide high level abstraction from the implementation.&lt;br /&gt;• Interface can have multiple inheritances.&lt;br /&gt;• Default access level of the interface is public.&lt;br /&gt;What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?&lt;br /&gt;ASP.NET Web services and .NET Remoting provide a full suite of design options for cross-process and cross-plaform communication in distributed applications. In general, ASP.NET Web services provide the highest levels of interoperability with full support for WSDL and SOAP over HTTP, while .NET Remoting is designed for common language runtime type-system fidelity and supports additional data format and communication channels. Hence if we looking cross-platform communication than web services is the choice coz for .NET remoting .Net framework is requried which may or may not present for the other platform.&lt;br /&gt;Serialization and Metadata&lt;br /&gt;ASP.NET Web services rely on the System.Xml.Serialization.XmlSerializer class to marshal data to and from SOAP messages at runtime. For metadata, they generate WSDL and XSD definitions that describe what their messages contain. The reliance on pure WSDL and XSD makes ASP.NET Web services metadata portable; it expresses data structures in a way that other Web service toolkits on different platforms and with different programming models can understand. In some cases, this imposes constraints on the types you can expose from a Web service—XmlSerializer will only marshal things that can be expressed in XSD. Specifically, XmlSerializer will not marshal object graphs and it has limited support for container types.&lt;br /&gt;.NET Remoting relies on the pluggable implementations of the IFormatter interface used by the System.Runtime.Serialization engine to marshal data to and from messages. There are two standard formatters, System.Runtime.Serialization.Formatters.Binary.BinaryFormatter and System.Runtime.Serialization.Formatters.Soap.SoapFormatter. The BinaryFormatter and SoapFormatter, as the names suggest, marshal types in binary and SOAP format respectively. For metadata, .NET Remoting relies on the common language runtime assemblies, which contain all the relevant information about the data types they implement, and expose it via reflection. The reliance on the assemblies for metadata makes it easy to preserve the full runtime type-system fidelity. As a result, when the .NET Remoting plumbing marshals data, it includes all of a class's public and private members; handles object graphs correctly; and supports all container types (e.g., System.Collections.Hashtable). However, the reliance on runtime metadata also limits the reach of a .NET Remoting system—a client has to understand .NET constructs in order to communicate with a .NET Remoting endpoint. In addition to pluggable formatters, the .NET Remoting layer supports pluggable channels, which abstract away the details of how messages are sent. There are two standard channels, one for raw TCP and one for HTTP. Messages can be sent over either channel independent of format.&lt;br /&gt;Distributed Application Design: ASP.NET Web Services vs. .NET Remoting&lt;br /&gt;ASP.NET Web services favor the XML Schema type system, and provide a simple programming model with broad cross-platform reach. .NET Remoting favors the runtime type system, and provides a more complex programming model with much more limited reach. This essential difference is the primary factor in determining which technology to use. However, there are a wide range of other design factors, including transport protocols, host processes, security, performance, state management, and support for transactions to consider as well.&lt;br /&gt;Security&lt;br /&gt;Since ASP.NET Web services rely on HTTP, they integrate with the standard Internet security infrastructure. ASP.NET leverages the security features available with IIS to provide strong support for standard HTTP authentication schemes including Basic, Digest, digital certificates, and even Microsoft® .NET Passport. (You can also use Windows Integrated authentication, but only for clients in a trusted domain.) One advantage of using the available HTTP authentication schemes is that no code change is required in a Web service; IIS performs authentication before the ASP.NET Web services are called. ASP.NET also provides support for .NET Passport-based authentication and other custom authentication schemes. ASP.NET supports access control based on target URLs, and by integrating with the .NET code access security (CAS) infrastructure. SSL can be used to ensure private communication over the wire.&lt;br /&gt;Although these standard transport-level techniques to secure Web services are quite effective, they only go so far. In complex scenarios involving multiple Web services in different trust domains, you have to build custom ad hoc solutions. Microsoft and others are working on a set of security specifications that build on the extensibility of SOAP messages to offer message-level security capabilities. One of these is the XML Web Services Security Language (WS-Security), which defines a framework for message-level credential transfer, message integrity, and message confidentiality.&lt;br /&gt;As noted in the previous section, the .NET Remoting plumbing does not secure cross-process invocations in the general case. A .NET Remoting endpoint hosted in IIS with ASP.NET can leverage all the same security features available to ASP.NET Web services, including support for secure communication over the wire using SSL. If you are using the TCP channel or the HTTP channel hosted in processes other than aspnet_wp.exe, you have to implement authentication, authorization and privacy mechanisms yourself.&lt;br /&gt;One additional security concern is the ability to execute code from a semi-trusted environment without having to change the default security policy. ASP.NET Web Services client proxies work in these environments, but .NET Remoting proxies do not. In order to use a .NET Remoting proxy from a semi-trusted environment, you need a special serialization permission that is not given to code loaded from your intranet or the Internet by default. If you want to use a .NET Remoting client from within a semi-trusted environment, you have to alter the default security policy for code loaded from those zones. In situations where you are connecting to systems from clients running in a sandbox—like a downloaded Windows Forms application, for instance—ASP.NET Web Services are a simpler choice because security policy changes are not required.&lt;br /&gt;Conceptually, what is the difference between early-binding and late-binding?&lt;br /&gt;Early binding – Binding at Compile Time&lt;br /&gt;Late Binding – Binding at Run Time&lt;br /&gt;Early binding implies that the class of the called object is known at compile-time; late-binding implies that the class is not known until run-time, such as a call through an interface or via Reflection.&lt;br /&gt;Early binding is the preferred method. It is the best performer because your application binds directly to the address of the function being called and there is no extra overhead in doing a run-time lookup. In terms of overall execution speed, it is at least twice as fast as late binding.&lt;br /&gt;Early binding also provides type safety. When you have a reference set to the component's type library, Visual Basic provides IntelliSense support to help you code each function correctly. Visual Basic also warns you if the data type of a parameter or return value is incorrect, saving a lot of time when writing and debugging code.&lt;br /&gt;Late binding is still useful in situations where the exact interface of an object is not known at design-time. If your application seeks to talk with multiple unknown servers or needs to invoke functions by name (using the Visual Basic 6.0 CallByName function for example) then you need to use late binding. Late binding is also useful to work around compatibility problems between multiple versions of a component that has improperly modified or adapted its interface between versions.&lt;br /&gt;What is an Asssembly Qualified Name? Is it a filename? How is it different?&lt;br /&gt;An assembly qualified name isn't the filename of the assembly; it's the internal name of the assembly combined with the assembly version, culture, and public key, thus making it unique.&lt;br /&gt;e.g. (""System.Xml.XmlDocument, System.Xml, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"")&lt;br /&gt;How is a strongly-named assembly different from one that isn’t strongly-named?&lt;br /&gt;Strong names are used to enable the stricter naming requirements associated with shared assemblies. These strong names are created by a .NET utility – sn.exe&lt;br /&gt;Strong names have three goals:&lt;br /&gt;• Name uniqueness. Shared assemblies must have names that are globally unique.&lt;br /&gt;• Prevent name spoofing. Developers don't want someone else releasing a subsequent version of one of your assemblies and falsely claim it came from you, either by accident or intentionally.&lt;br /&gt;• Provide identity on reference. When resolving a reference to an assembly, strong names are used to guarantee the assembly that is loaded came from the expected publisher.&lt;br /&gt;Strong names are implemented using standard public key cryptography. In general, the process works as follows: The author of an assembly generates a key pair (or uses an existing one), signs the file containing the manifest with the private key, and makes the public key available to callers. When references are made to the assembly, the caller records the public key corresponding to the private key used to generate the strong name.&lt;br /&gt;Weak named assemblies are not suitable to be added in GAC and shared. It is essential for an assembly to be strong named.&lt;br /&gt;Strong naming prevents tampering and enables assemblies to be placed in the GAC alongside other assemblies of the same name.&lt;br /&gt;How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?&lt;br /&gt;The hugely simplistic version is that every time it garbage-collects, it starts by assuming everything to be garbage, then goes through and builds a list of everything reachable. Those become not-garbage, everything else doesn't, and gets thrown away. What makes it generational is that every time an object goes through this process and survives, it is noted as being a member of an older generation (up to 2, right now). When the garbage-collector is trying to free memory, it starts with the lowest generation (0) and only works up to higher ones if it can't free up enough space, on the grounds that shorter-lived objects are more likely to have been freed than longer-lived ones.&lt;br /&gt;Non-deterministic finalization implies that the destructor (if any) of an object will not necessarily be run (nor its memory cleaned up, but that's a relatively minor issue) immediately upon its going out of scope. Instead, it will wait until first the garbage collector gets around to finding it, and then the finalisation queue empties down to it; and if the process ends before this happens, it may not be finalised at all. (Although the operating system will usually clean up any process-external resources left open - note the usually there, especially as the exceptions tend to hurt a lot.)&lt;br /&gt;What is the difference between Finalize() and Dispose()?&lt;br /&gt;Dispose() is called by the user of an object to indicate that he is finished with it, enabling that object to release any unmanaged resources it holds. Finalize() is called by the run-time to allow an object which has not had Dispose() called on it to do the same. However, Dispose() operates determinalistically, whereas there is no guarantee that Finalize() will be called immediately when an object goes out of scope - or indeed at all, if the program ends before that object is GCed - and as such Dispose() is generally preferred.&lt;br /&gt;How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?&lt;br /&gt;The using() pattern is useful because it ensures that Dispose() will always be called when a disposable object (defined as one that implements IDisposable, and thus the Dispose() method) goes out of scope, even if it does so by an exception being thrown, and thus that resources are always released.&lt;br /&gt;What does this useful command line do? tasklist /m "mscor*"&lt;br /&gt;Lists all the applications and associated tasks/process currently  running on the system with a module whose name begins "mscor" loaded into them; which in nearly all cases means "all the .NET processes".&lt;br /&gt;What’s wrong with a line like this? DateTime.Parse(myString);&lt;br /&gt;Therez nothing wrong with this declaration.Converts the specified string representation of a date and time to its DateTime equivalent.But If the string is not a valid DateTime,It throws an exception.&lt;br /&gt;What are PDBs? Where must they be located for debugging to work?&lt;br /&gt;A program database (PDB) files holds debugging and project state information that allows incremental linking of debug configuration of your program.There are several different types of symbolic debugging information. The default type for Microsoft compiler is the so-called PDB file. The compiler setting for creating this file is /Zi, or /ZI for C/C++(which creates a PDB file with additional information that enables a feature called ""Edit and Continue"") or a Visual Basic/C#/JScript .NET program with /debug.&lt;br /&gt;A PDB file is a separate file, placed by default in the Debug project subdirectory, that has the same name as the executable file with the extension .pdb. Note that the Visual C++ compiler by default creates an additional PDB file called VC60.pdb for VisulaC++6.0 and VC70.PDB file for VisulaC++7.0. The compiler creates this file during compilation of the source code, when the compiler isn't aware of the final name of the executable. The linker can merge this temporary PDB file into the main one if you tell it to, but it won't do it by default. The PDB file can be useful to display the detailed stack trace with source files and line numbers.&lt;br /&gt;What is FullTrust? Do GAC’ed assemblies have FullTrust?&lt;br /&gt;Before the .NET Framework existed, Windows had two levels of trust for downloaded code. This old model was a binary trust model. You only had two choices: Full Trust, and No Trust. The code could either do anything you could do, or it wouldn't run at all.&lt;br /&gt;&lt;br /&gt;The permission sets in .NET include FullTrust, SkipVerification, Execution, Nothing, LocalIntranet, Internet and Everything. Full Trust Grants unrestricted permissions to system resources. Fully trusted code run by a normal, nonprivileged user cannot do administrative tasks, but can access any resources the user can access, and do anything the user can do. From a security standpoint, you can think of fully trusted code as being similar to native, unmanaged code, like a traditional ActiveX control.&lt;br /&gt;GAC assemblies are granted FullTrust. In v1.0 and 1.1, the fact that assemblies in the GAC seem to always get a FullTrust grant is actually a side effect of the fact that the GAC lives on the local machine.  If anyone were to lock down the security policy by changing the grant set of the local machine to something less than FullTrust, and if your assembly did not get extra permission from some other code group, it would no longer have FullTrust even though it lives in the GAC.&lt;br /&gt;What does this do? gacutil /l | find /i "Corillian"&lt;br /&gt;The Global Assembly Cache tool allows you to view and manipulate the contents of the global assembly cache and download cache.The tool comes with various optional params to do that.&lt;br /&gt;""/l"" option Lists the contents of the global assembly cache. If you specify the assemblyName parameter(/l [assemblyName]), the tool lists only the assemblies matching that name.&lt;br /&gt;What does this do .. sn -t foo.dll ?&lt;br /&gt;Sn -t option displays the token for the public key stored in infile. The contents of infile must be previously generated using -p.&lt;br /&gt;Sn.exe computes the token using a hash function from the public key. To save space, the common language runtime stores public key tokens in the manifest as part of a reference to another assembly when it records a dependency to an assembly that has a strong name. The -tp option displays the public key in addition to the token.&lt;br /&gt;How do you generate a strong name?&lt;br /&gt;.NET provides an utility called strong name tool. You can run this toolfrom the VS.NET command prompt to generate a strong name with an option "-k" and providing the strong key file name. i.e. sn- -k &lt;&gt;&lt;br /&gt;What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?&lt;br /&gt;The Debug build is the program compiled with full symbolic debug information and no optimization. The Release build is the program compiled employing  optimization and contains no symbolic debug information. These settings can be changed as per need from Project Configuration properties. The release runs faster since it does not have any debug symbols and is optimized.&lt;br /&gt;Explain the use of virtual, sealed, override, and abstract.&lt;br /&gt;Abstract: The keyword can be applied for a class or method.&lt;br /&gt;1. Class: If we use abstract keyword for a class it makes the&lt;br /&gt;class an abstract class, which means it cant be instantiated. Though&lt;br /&gt;it is not nessacary to make all the method within the  abstract class to be virtual. ie, Abstract class can have concrete methods&lt;br /&gt;2. Method: If we make a method as abstract, we dont need to provide implementation&lt;br /&gt;of the method in the class but the derived class need to implement/override this method.&lt;br /&gt;&lt;br /&gt;Sealed: It can be applied on a class and methods. It stops the type from further derivation i.e no one can derive class&lt;br /&gt;from a sealed class,ie A sealed class cannot be inherited.A sealed class cannot be a abstract class.A compile time error is thrown if you try to specify sealed class as a  base class.&lt;br /&gt;When an instance method declaration includes a sealed modifier, that method is said to be a sealed method. If an instance method declaration includes the sealed modifier, it must also include the override modifier. Use of the sealed modifier prevents a derived class from further overriding the method  For Egs: sealed override public void Sample() { Console.WriteLine("Sealed Method"); }&lt;br /&gt;&lt;br /&gt;Virtual &amp;amp; Override: Virtual &amp;amp; Override keywords provides runtime polymorphism. A base class can make some of its methods&lt;br /&gt;as virtual which allows the derived class a chance to override the base class implementation by using override keyword.&lt;br /&gt;&lt;br /&gt;For e.g. class Shape&lt;br /&gt;  {&lt;br /&gt;  int a&lt;br /&gt;  public virtual void Display()&lt;br /&gt;  {&lt;br /&gt;   Console.WriteLine("Shape");&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; class Rectangle:Shape&lt;br /&gt; {&lt;br /&gt;  public override void Display()&lt;br /&gt;  {&lt;br /&gt;   Console.WriteLine("Derived");&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;Explain the importance and use of each, Version, Culture and PublicKeyToken for an assembly.&lt;br /&gt;This three alongwith name of the assembly provide a strong name or fully qualified name to the assembly. When a assebly is referenced with all three.&lt;br /&gt;PublicKeyToken: Each assembly can have a public key embedded in its manifest that identifies the developer. This ensures that once the assembly ships, no one can modify the code or other resources contained in the assembly.&lt;br /&gt;&lt;br /&gt;Culture: Specifies which culture the assembly supports&lt;br /&gt;&lt;br /&gt;Version: The version number of the assembly.It is of the following form major.minor.build.revision.&lt;br /&gt;Explain the differences between public, protected, private and internal.&lt;br /&gt;These all are access modifier and they governs the access level. They can be applied to class, methods, fields.&lt;br /&gt;&lt;br /&gt;Public: Allows class, methods, fields to be accessible from anywhere i.e. within and outside an assembly.&lt;br /&gt;Private: When applied to field and method allows to be accessible within a class.&lt;br /&gt;Protected: Similar to private but can be accessed by members of derived class also.&lt;br /&gt;Internal: They are public within the assembly i.e. they can be accessed by anyone within an assembly but outside assembly they are not visible.&lt;br /&gt;What is the difference between typeof(foo) and myFoo.GetType()?&lt;br /&gt;Typeof is operator which applied to a object returns System.Type object. Typeof cannot be overloaded white GetType has lot of overloads.GetType is a method which also returns System.Type of an object. GetType is used to get the runtime type of the object.&lt;br /&gt;Example from MSDN showing Gettype used to retrive type at untime:-&lt;br /&gt;public class MyBaseClass: Object {&lt;br /&gt;}&lt;br /&gt;public class MyDerivedClass: MyBaseClass {&lt;br /&gt;}&lt;br /&gt;public class Test {&lt;br /&gt;   public static void Main() {&lt;br /&gt;      MyBaseClass myBase = new MyBaseClass();&lt;br /&gt;      MyDerivedClass myDerived = new MyDerivedClass();&lt;br /&gt;      object o = myDerived;&lt;br /&gt;      MyBaseClass b = myDerived;&lt;br /&gt;      Console.WriteLine("mybase: Type is {0}", myBase.GetType());&lt;br /&gt;      Console.WriteLine("myDerived: Type is {0}", myDerived.GetType());&lt;br /&gt;      Console.WriteLine("object o = myDerived: Type is {0}", o.GetType());&lt;br /&gt;      Console.WriteLine("MyBaseClass b = myDerived: Type is {0}", b.GetType());&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;This code produces the following output.&lt;br /&gt;mybase: Type is MyBaseClass&lt;br /&gt;myDerived: Type is MyDerivedClass&lt;br /&gt;object o = myDerived: Type is MyDerivedClass&lt;br /&gt;MyBaseClass b = myDerived: Type is MyDerivedClass&lt;br /&gt;*/&lt;br /&gt;Can "this" be used within a static method?&lt;br /&gt;No 'This' cannot be used in a static method. As only static variables/methods can be used in a static method.&lt;br /&gt;What is the purpose of XML Namespaces?&lt;br /&gt;An XML Namespace is a collection of element types and attribute names. It consists of 2 parts&lt;br /&gt;1) The first part is the URI used to identify the namespace&lt;br /&gt;2) The second part is the element type or attribute name itself.&lt;br /&gt;Together they form a unique name. The various purpose of XML Namespace are&lt;br /&gt;1. Combine fragments from different documents without any naming conflicts. (See example below.)&lt;br /&gt;2. Write reusable code modules that can be invoked for specific elements and attributes. Universally unique names guarantee that&lt;br /&gt;such modules are invoked only for the correct elements and attributes.&lt;br /&gt;3. Define elements and attributes that can be reused in other schemas or instance documents without fear of name collisions. For&lt;br /&gt;example, you might use XHTML elements in a parts catalog to provide part descriptions. Or you might use the nil attribute&lt;br /&gt;defined in XML Schemas to indicate a missing value.&lt;br /&gt;&lt;&gt;&lt;br /&gt;     &lt;&gt;DVS1&lt; /Name &gt;&lt;br /&gt;     &lt; addr="http://www.tu-darmstadt.de/ito/addresses"&gt;&lt;br /&gt;        &lt;&gt;Wilhelminenstr. 7&lt; /addr:Street &gt;&lt;br /&gt;        &lt;&gt;Darmstadt&lt; /addr:City &gt;&lt;br /&gt;        &lt;&gt;Hessen&lt; /addr:State &gt;&lt;br /&gt;        &lt;&gt;Germany&lt; /addr:Country &gt;&lt;br /&gt;        &lt;&gt;D-64285&lt; /addr:PostalCode &gt;&lt;br /&gt;     &lt; /addr:Address &gt;&lt;br /&gt;     &lt; serv="http://www.tu-darmstadt.de/ito/servers"&gt;&lt;br /&gt;        &lt;&gt;OurWebServer&lt; /serv:Name &gt;&lt;br /&gt;        &lt;&gt;123.45.67.8&lt; /serv:Address &gt;&lt;br /&gt;     &lt; /serv:Server &gt;&lt;br /&gt;  &lt; /Department &gt;&lt;br /&gt;What is difference between MetaData and Manifest ?&lt;br /&gt;Metadata and Manifest forms an integral part of an assembly( dll / exe ) in .net framework .&lt;br /&gt;Out of which Metadata is a mandatory component , which as the name suggests gives the details about various components of IL code viz : Methods , properties , fields , class etc.&lt;br /&gt;Essentially Metadata maintains details in form of tables like Methods Metadata tables , Properties Metadata tables , which maintains the list of given type and other details like access specifier , return type etc.&lt;br /&gt;Now Manifest is a part of metadata only , fully called as “manifest metadata tables” , it contains the details of the references needed by the assembly of any other external assembly / type , it could be a custom assembly or standard System namespace .&lt;br /&gt;Now for an assembly that can independently exists and used in the .Net world both the things ( Metadata with Manifest ) are mandatory , so that it can be fully described assembly and can be ported anywhere without any system dependency . Essentially .Net framework can read all assembly related information from assembly itself at runtime .&lt;br /&gt;But for .Net modules , that can’t be used independently , until they are being packaged as a part of an assembly , they don’t contain Manifest but their complete structure is defined by their respective metadata .&lt;br /&gt;Ultimately . .Net modules use Manifest Metadata tables of parent assembly which contain them .&lt;br /&gt;&lt;br /&gt;What is the use of Internal keyword?&lt;br /&gt;Internal keyword is one of the access specifier available in .Net framework , that makes a type visible in a  given assembly , for e.g : a single dll can contain multiple modules , essentially a multi file assembly , but it forms a single binary component , so any type with internal keyword will be visible throughout the assembly and can be used in any of the modules .&lt;br /&gt;&lt;br /&gt;What actually happes when you add a something to arraylistcollection ?&lt;br /&gt;Following things will happen :&lt;br /&gt;Arraylist is a dynamic array class in c# in System.Collections namespace derived from interfaces – ICollection , IList , ICloneable , IConvertible  . It terms of in memory structure following is the implementation .&lt;br /&gt;a. Check up the total space if there’s any free space on the declared list .&lt;br /&gt;b. If yes add the new item and increase count by 1 .&lt;br /&gt;c. If No Copy the whole thing to a temporary Array of Last Max. Size .&lt;br /&gt;d. Create new Array with size ( Last Array Size + Increase Value )&lt;br /&gt;e. Copy back values from temp and reference this new array as original array .&lt;br /&gt;f. Must doing Method updates too , need to check it up .&lt;br /&gt;What is Boxing and unboxing? Does it occure automaatically or u need to write code to box and unbox?&lt;br /&gt;Boxing – Process of converting a System.ValueType to Reference Type , Mostly base class System.Object type and allocating it memory on Heap .Reverse is unboxing , but can only be done with prior boxed variables.&lt;br /&gt;Boxing is always implicit but Unboxing needs to be explicitly done via casting , thus ensuring the value type contained inside .&lt;br /&gt;How Boxing and unboxing occures in memory?&lt;br /&gt;Boxing converts value type to reference type , thus allocating memory on Heap . Unboxing converts already boxed reference types to value types through explicit casting , thus  allocating memory on stack .&lt;br /&gt;&lt;br /&gt;Why only boxed types can be unboxed?&lt;br /&gt;Unboxing is the process of converting a Reference type variable to Value type and thus allocating memory on the stack . It happens only to those Reference type variables that have been earlier created by Boxing of a Value Type , therefore internally they contain a value type , which can be obtained through explicit casting . For any other Reference type , they don’t internally contain a Value type to Unboxed via explicit casting . This is why only boxed types can be unboxed .&lt;br /&gt;Com +&lt;br /&gt;&lt;br /&gt;What are different transaction options available for services components ?&lt;br /&gt;There are 5 transactions types that can be used with COM+. Whenever an object is registered with COM+ it has to abide either to these 5 transaction types.&lt;br /&gt;Disabled: - There is no transaction. COM+ does not provide transaction support for this component.&lt;br /&gt;Not Supported: - Component does not support transactions. Hence even if the calling component in the hierarchy is transaction enabled this component will not participate in the transaction.&lt;br /&gt;Supported: - Components with transaction type supported will be a part of the transaction if the calling component has an active transaction.&lt;br /&gt;If the calling component is not transaction enabled this component will not start a new transaction.&lt;br /&gt;Required: - Components with this attribute require a transaction i.e. either the calling should have a transaction in place else this component will start a new transaction.&lt;br /&gt;Required New: - Components enabled with this transaction type always require a new transaction. Components with required new transaction type instantiate a new transaction for themselves every time.&lt;br /&gt;&lt;br /&gt;Can we use com Components in .net?.How ?.can we use .net components in vb?.Explain how ?&lt;br /&gt;COM components have different internal architecture from .NET components hence they are not innately compatible. However .NET  framework supports invocation of unmanaged code from managed code (and vice-versa) through COM/.NET interoperability. .NET application communicates with a COM component through a managed wrapper of the component called Runtime Callable Wrapper (RCW); it acts as managed proxy to the unmanaged COM component. When a method call is made to COM object, it goes onto RCW and not the object itself. RCW manages the lifetime management of the COM component. Implementation Steps -&lt;br /&gt;Create Runtime Callable Wrapper out of COM component. Reference the metadata assembly Dll in the project and use its methods &amp;amp; properties RCW can be created using Type Library Importer utility or through VS.NET. Using VS.NET, add reference through COM tab to select the desired DLL. VS.NET automatically generates metadata assembly putting the classes provided by that component into a namespace with the same name as COM dll (XYZRCW.dll)&lt;br /&gt;.NET components can be invoked by unmanaged code through COM Callable Wrapper (CCW) in COM/.NET interop. The unmanaged code will talk to this proxy, which translates call to managed environment. We can use COM components in .NET through COM/.NET interoperability. When managed code calls an unmanaged component, behind the scene, .NET creates proxy called COM Callable wrapper (CCW), which accepts commands from a COM client, and forwards it to .NET component. There are two prerequisites to creating .NET component, to be used in unmanaged code:&lt;br /&gt;1. .NET class should be implement its functionality through interface. First define interface in code, then have the class to imlpement it. This way, it prevents breaking of COM client, if/when .NET component changes.&lt;br /&gt;2.Secondly, .NET class, which is to be visible to COM clients must be declared public. The tools that create the CCW only define types based&lt;br /&gt;on public classes. The same rule applies to methods, properties, and events that will be used by COM clients.&lt;br /&gt;Implementation Steps -&lt;br /&gt;1. Generate type library of .NET component, using TLBExporter utility. A type library is the COM equivalent of the metadata contained within&lt;br /&gt;a .NET assembly. Type libraries are generally contained in files with the extension .tlb. A type library contains the necessary information to allow a COM client to determine which classes are located in a particular server, as well as the methods, properties, and events supported by those classes.&lt;br /&gt;2. Secondly,  use Assembly Registration tool (regasm) to create the type library and register it.&lt;br /&gt;3. Lastly install .NET assembly in GAC, so it is available as shared assembly.&lt;br /&gt;What is Runtime Callable wrapper?.when it will created?.&lt;br /&gt;The common language runtime exposes COM objects through a proxy called the runtime callable wrapper (RCW). Although the RCW appears to be an ordinary object to .NET clients, its primary function is to marshal calls between a .NET client and a COM object. This wrapper turns the COM interfaces exposed by the COM component into .NET-compatible interfaces. For oleautomation (attribute indicates that an interface is compatible with Automation) interfaces, the RCW can be generated automatically from a type library. For non-oleautomation interfaces, it may be necessary to develop a custom RCW which manually maps the types exposed by the COM interface to .NET-compatible types.&lt;br /&gt;What is Com Callable wrapper?when it will created?&lt;br /&gt;.NET components are accessed from COM via a COM Callable Wrapper (CCW). This is similar to a RCW, but works in the opposite direction. Again, if the wrapper cannot be automatically generated by the .NET development tools, or if the automatic behaviour is not desirable, a custom CCW can be developed. Also, for COM to 'see' the .NET component, the .NET component must be registered in the registry.CCWs also manage the object identity and object lifetime of the managed objects they wrap.&lt;br /&gt;What is a primary interop ?&lt;br /&gt;A primary interop assembly is a collection of types that are deployed, versioned, and configured as a single unit. However, unlike other managed assemblies, an interop assembly contains type definitions (not implementation) of types that have already been defined in COM. These type definitions allow managed applications to bind to the COM types at compile time and provide information to the common language runtime&lt;br /&gt;about how the types should be marshaled at run time.&lt;br /&gt;What are tlbimp and tlbexp tools used for ?&lt;br /&gt;The Type Library Exporter generates a type library that describes the types defined in a common language runtime assembly.&lt;br /&gt;The Type Library Importer converts the type definitions found within a COM type library into equivalent definitions in a common language runtime assembly. The output of Tlbimp.exe is a binary file (an assembly) that contains runtime metadata for the types defined within the original type library.&lt;br /&gt;What benefit do you get from using a Primary Interop Assembly (PIA)?&lt;br /&gt;PIAs are important because they provide unique type identity. The PIA distinguishes the official type definitions from counterfeit definitions provided by other interop assemblies. Having a single type identity ensures type compatibility between applications that share the types defined in the PIA. Because the PIA is signed by its  publisher and labeled with the PrimaryInteropAssembly attribute, it can be differentiated from other interop assemblies that define the same types.&lt;br /&gt;&lt;br /&gt;ADO.NET&lt;br /&gt;&lt;br /&gt;Explain what a diffgram is and its usage ?&lt;br /&gt;A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order.&lt;br /&gt;When sending and retrieving a DataSet from an XML Web service, the DiffGram format is implicitly used. Additionally, when loading the contents of a DataSet from XML using the ReadXml method, or when writing the contents of a DataSet in XML using the WriteXml method, you can select that the contents be read or written as a DiffGram.&lt;br /&gt;The DiffGram format is divided into three sections: the current data, the original (or "before") data, and an errors section, as shown in the following example.&lt;br /&gt;&lt;?xml version="1.0"?&gt;&lt;br /&gt;&lt;diffgr:diffgram&lt;br /&gt;         xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&lt;br /&gt;         xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"&lt;br /&gt;         xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;br /&gt;   &lt;datainstance&gt;&lt;br /&gt;   &lt;/datainstance&gt;&lt;br /&gt;  &lt;diffgr:before&gt;&lt;br /&gt;  &lt;/diffgr:before&gt;&lt;br /&gt;  &lt;diffgr:errors&gt;&lt;br /&gt;  &lt;/diffgr:errors&gt;&lt;br /&gt;&lt;/diffgr:diffgram&gt;&lt;br /&gt;The DiffGram format consists of the following blocks of data:&lt;br /&gt;&lt;datainstance&gt;&lt;br /&gt;The name of this element, DataInstance, is used for explanation purposes in this documentation. A DataInstance element represents a DataSet or a row of a DataTable. Instead of DataInstance, the element would contain the name of the DataSet or DataTable. This block of the DiffGram format contains the current data, whether it has been modified or not. An element, or row, that has been modified is identified with the diffgr:hasChanges annotation.&lt;br /&gt;&lt;diffgr:before&gt;&lt;br /&gt;This block of the DiffGram format contains the original version of a row. Elements in this block are matched to elements in the DataInstance block using the diffgr:id annotation.&lt;br /&gt;&lt;diffgr:errors&gt;&lt;br /&gt;This block of the DiffGram format contains error information for a particular row in the DataInstance block. Elements in this block are matched to elements in the DataInstance block using the diffgr:id annotation.&lt;br /&gt;Which method do you invoke on the DataAdapter control to load your generated dataset with data?&lt;br /&gt;You have to use the Fill method of the DataAdapter control and pass the dataset object as an argument to load the generated data.&lt;br /&gt;Can you edit data in the Repeater control?&lt;br /&gt;NO.&lt;br /&gt;Which are the different IsolationLevels ?&lt;br /&gt;Following are the various IsolationLevels:&lt;br /&gt;•    Serialized   Data read by a current transaction cannot be changed by another transaction until the current transaction finishes. No new data can be inserted that would affect the current transaction. This is the safest isolation level and is the default. &lt;br /&gt;•    Repeatable Read   Data read by a current transaction cannot be changed by another transaction until the current transaction finishes. Any type of new data can be inserted during a transaction. &lt;br /&gt;•    Read Committed   A transaction cannot read data that is being modified by another transaction that has not committed. This is the default isolation level in Microsoft® SQL Server. &lt;br /&gt;•    Read Uncommitted   A transaction can read any data, even if it is being modified by another transaction. This is the least safe isolation level but allows the highest concurrency. &lt;br /&gt;•    Any   Any isolation level is supported. This setting is most commonly used by downstream components to avoid conflicts. This setting is useful because any downstream component must be configured with an isolation level that is equal to or less than the isolation level of its immediate upstream component. Therefore, a downstream component that has its isolation level configured as Any always uses the same isolation level that its immediate upstream component uses. If the root object in a transaction has its isolation level configured to Any, its isolation level becomes Serialized.&lt;br /&gt;How xml files and be read and write using dataset?.&lt;br /&gt;DataSet exposes method like ReadXml and WriteXml to read and write xml&lt;br /&gt;What are the different rowversions available?&lt;br /&gt;There are four types of Rowversions.&lt;br /&gt;Current:&lt;br /&gt;The current values for the row. This row version does not exist for rows with a RowState of Deleted.&lt;br /&gt;Default :&lt;br /&gt;The row the default version for the current DataRowState. For a DataRowState value of Added, Modified or Current, the default version is Current. For a DataRowState of Deleted, the version is Original. For a DataRowState value of Detached, the version is Proposed.&lt;br /&gt;Original:&lt;br /&gt;The row contains its original values.&lt;br /&gt;Proposed:&lt;br /&gt;The proposed values for the row. This row version exists during an edit operation on a row, or for a row that is not part of a DataRowCollection&lt;br /&gt;Explain acid properties?.&lt;br /&gt;The term ACID conveys the role transactions play in mission-critical applications. Coined by transaction processing pioneers, ACID stands for atomicity, consistency, isolation, and durability.&lt;br /&gt;These properties ensure predictable behavior, reinforcing the role of transactions as all-or-none propositions designed to reduce the management load when there are many variables.&lt;br /&gt;Atomicity&lt;br /&gt;A transaction is a unit of work in which a series of operations occur between the BEGIN TRANSACTION and END TRANSACTION statements of an application. A transaction executes exactly once and is atomic — all the work is done or none of it is.&lt;br /&gt;Operations associated with a transaction usually share a common intent and are interdependent. By performing only a subset of these operations, the system could compromise the overall intent of the transaction. Atomicity eliminates the chance of processing a subset of operations.&lt;br /&gt;Consistency&lt;br /&gt;A transaction is a unit of integrity because it preserves the consistency of data, transforming one consistent state of data into another consistent state of data.&lt;br /&gt;Consistency requires that data bound by a transaction be semantically preserved. Some of the responsibility for maintaining consistency falls to the application developer who must make sure that all known integrity constraints are enforced by the application. For example, in developing an application that transfers money, you should avoid arbitrarily moving decimal points during the transfer.&lt;br /&gt;Isolation&lt;br /&gt;A transaction is a unit of isolation — allowing concurrent transactions to behave as though each were the only transaction running in the system.&lt;br /&gt;Isolation requires that each transaction appear to be the only transaction manipulating the data store, even though other transactions may be running at the same time. A transaction should never see the intermediate stages of another transaction.&lt;br /&gt;Transactions attain the highest level of isolation when they are serializable. At this level, the results obtained from a set of concurrent transactions are identical to the results obtained by running each transaction serially. Because a high degree of isolation can limit the number of concurrent transactions, some applications reduce the isolation level in exchange for better throughput.&lt;br /&gt;Durability&lt;br /&gt;A transaction is also a unit of recovery. If a transaction succeeds, the system guarantees that its updates will persist, even if the computer crashes immediately after the commit. Specialized logging allows the system's restart procedure to complete unfinished operations, making the transaction durable.&lt;br /&gt;&lt;br /&gt;Whate are different types of Commands available with DataAdapter ?&lt;br /&gt;The SqlDataAdapter has SelectCommand, InsertCommand, DeleteCommand and UpdateCommand&lt;br /&gt;What is a Dataset?&lt;br /&gt;Datasets are the result of bringing together ADO and XML. A dataset contains one or more data of tabular XML, known as DataTables, these data can be treated separately, or can have relationships defined between them. Indeed these relationships give you ADO data SHAPING without needing to master the SHAPE language, which many people are not comfortable with.&lt;br /&gt;The dataset is a disconnected in-memory cache database. The dataset object model looks like this:&lt;br /&gt;Dataset&lt;br /&gt;  DataTableCollection&lt;br /&gt;  DataTable&lt;br /&gt;   DataView&lt;br /&gt;   DataRowCollection&lt;br /&gt;    DataRow&lt;br /&gt;   DataColumnCollection&lt;br /&gt;    DataColumn&lt;br /&gt;   ChildRelations&lt;br /&gt;   ParentRelations&lt;br /&gt;   Constraints&lt;br /&gt;   PrimaryKey&lt;br /&gt;DataRelationCollection&lt;br /&gt;Let’s take a look at each of these:&lt;br /&gt;DataTableCollection: As we say that a DataSet is an in-memory database. So it has this collection, which holds data from multiple tables in a single DataSet object.&lt;br /&gt;DataTable: In the DataTableCollection, we have DataTable objects, which represents the individual tables of the dataset.&lt;br /&gt;DataView: The way we have views in database, same way we can have DataViews. We can use these DataViews to do Sort, filter data.&lt;br /&gt;DataRowCollection: Similar to DataTableCollection, to represent each row in each Table we have DataRowCollection.&lt;br /&gt;DataRow:  To represent each and every row of the DataRowCollection, we have DataRows.&lt;br /&gt;DataColumnCollection: Similar to DataTableCollection, to represent each column in each Table we have DataColumnCollection.&lt;br /&gt;DataColumn: To represent each and every Column of the DataColumnCollection, we have DataColumn.&lt;br /&gt;PrimaryKey: Dataset defines Primary key for the table and the primary key validation will take place without going to the database.&lt;br /&gt;Constraints: We can define various constraints on the Tables, and can use Dataset.Tables(0).enforceConstraints. This will execute all the constraints, whenever we enter data in DataTable.&lt;br /&gt;DataRelationCollection: as we know that we can have more than 1 table in the dataset, we can also define relationship between these tables using this collection and maintain a parent-child relationship.&lt;br /&gt;Explain the ADO . Net Architecture ( .Net Data Provider)&lt;br /&gt;ADO.Net is the data access model for .Net –based applications. It can be used to access relational database systems such as SQL SERVER 2000, Oracle, and many other data sources for which there is an OLD DB or ODBC provider. To a certain extent, ADO.NET represents the latest evolution of ADO technology. However, ADO.NET introduces some major changes and innovations that are aimed at the loosely coupled and inherently disconnected – nature of web applications.&lt;br /&gt;A .Net Framework data provider is used to connecting to a database, executing commands, and retrieving results. Those results are either processed directly, or placed in an ADO.NET DataSet in order to be exposed to the user in an ad-hoc manner, combined with data from multiple sources, or remoted between tiers. The .NET Framework data provider is designed to be lightweight, creating a minimal layer between the data source and your code, increasing performance without sacrificing functionality.&lt;br /&gt;Following are the 4 core objects of .Net Framework Data provider:&lt;br /&gt;•    Connection: Establishes a connection to a specific data source&lt;br /&gt;•    Command: Executes a command against a data source. Exposes Parameters and can execute within the scope of a Transaction from a Connection.&lt;br /&gt;•    DataReader: Reads a forward-only, read-only stream of data from a data source.&lt;br /&gt;•    DataAdapter: Populates a DataSet and resolves updates with the data source.&lt;br /&gt;The .NET Framework includes the .NET Framework Data Provider for SQL Server (for Microsoft SQL Server version 7.0 or later), the .NET Framework Data Provider for OLE DB, and the .NET Framework Data Provider for ODBC.&lt;br /&gt;The .NET Framework Data Provider for SQL Server:  The .NET Framework Data Provider for SQL Server uses its own protocol to communicate with SQL Server. It is lightweight and performs well because it is optimized to access a SQL Server directly without adding an OLE DB or Open Database Connectivity (ODBC) layer. The following illustration contrasts the .NET Framework Data Provider for SQL Server with the .NET Framework Data Provider for OLE DB. The .NET Framework Data Provider for OLE DB communicates to an OLE DB data source through both the OLE DB Service component, which provides connection pooling and transaction services, and the OLE DB Provider for the data source&lt;br /&gt;The .NET Framework Data Provider for OLE DB: The .NET Framework Data Provider for OLE DB uses native OLE DB through COM interoperability to enable data access. The .NET Framework Data Provider for OLE DB supports both local and distributed transactions. For distributed transactions, the .NET Framework Data Provider for OLE DB, by default, automatically enlists in a transaction and obtains transaction details from Windows 2000 Component Services.&lt;br /&gt;The .NET Framework Data Provider for ODBC: The .NET Framework Data Provider for ODBC uses native ODBC Driver Manager (DM) through COM interoperability to enable data access. The ODBC data provider supports both local and distributed transactions. For distributed transactions, the ODBC data provider, by default, automatically enlists in a transaction and obtains transaction details from Windows 2000 Component Services.&lt;br /&gt;The .NET Framework Data Provider for Oracle: The .NET Framework Data Provider for Oracle enables data access to Oracle data sources through Oracle client connectivity software. The data provider supports Oracle client software version 8.1.7 and later. The data provider supports both local and distributed transactions (the data provider automatically enlists in existing distributed transactions, but does not currently support the EnlistDistributedTransaction method).&lt;br /&gt;The .NET Framework Data Provider for Oracle requires that Oracle client software (version 8.1.7 or later) be installed on the system before you can use it to connect to an Oracle data source.&lt;br /&gt;.NET Framework Data Provider for Oracle classes are located in the System.Data.OracleClient namespace and are contained in the System.Data.OracleClient.dll assembly. You will need to reference both the System.Data.dll and the System.Data.OracleClient.dll when compiling an application that uses the data provider.&lt;br /&gt;Choosing a .NET Framework Data Provider&lt;br /&gt;.NET Framework Data Provider for SQL Server: Recommended for middle-tier applications using Microsoft SQL Server 7.0 or later. Recommended for single-tier applications using Microsoft Data Engine (MSDE) or Microsoft SQL Server 7.0 or later.&lt;br /&gt;Recommended over use of the OLE DB Provider for SQL Server (SQLOLEDB) with the .NET Framework Data Provider for OLE DB. For Microsoft SQL Server version 6.5 and earlier, you must use the OLE DB Provider for SQL Server with the .NET Framework Data Provider for OLE DB.&lt;br /&gt;.NET Framework Data Provider for OLE DB: Recommended for middle-tier applications using Microsoft SQL Server 6.5 or earlier, or any OLE DB provider. For Microsoft SQL Server 7.0 or later, the .NET Framework Data Provider for SQL Server is recommended. Recommended for single-tier applications using Microsoft Access databases. Use of a Microsoft Access database for a middle-tier application is not recommended.&lt;br /&gt;.NET Framework Data Provider for ODBC: Recommended for middle-tier applications using ODBC data sources. Recommended for single-tier applications using ODBC data sources.&lt;br /&gt;.NET Framework Data Provider for Oracle: Recommended for middle-tier applications using Oracle data sources. Recommended for single-tier applications using Oracle data sources. Supports Oracle client software version 8.1.7 and later. The .NET Framework Data Provider for Oracle classes are located in the System.Data.OracleClient namespace and are contained in the System.Data.OracleClient.dll assembly. You need to reference both the System.Data.dll and the System.Data.OracleClient.dll when compiling an application that uses the data provider.&lt;br /&gt;Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?&lt;br /&gt;Let’s take a look at the differences between ADO Recordset and ADO.Net DataSet:&lt;br /&gt;1. Table Collection: ADO Recordset provides the ability to navigate through a single table of information. That table would have been formed with a join of multiple tables and returning columns from multiple tables. ADO.NET DataSet is capable of holding instances of multiple tables. It has got a Table Collection, which holds multiple tables in it. If the tables are having a relation, then it can be manipulated on a Parent-Child relationship. It has the ability to support multiple tables with keys, constraints and interconnected relationships. With this ability the DataSet can be considered as a small, in-memory relational database cache.&lt;br /&gt;2. Navigation: Navigation in ADO Recordset is based on the cursor mode. Even though it is specified to be a client-side Recordset, still the navigation pointer will move from one location to another on cursor model only. ADO.NET DataSet is an entirely offline, in-memory, and cache of data. All of its data is available all the time. At any time, we can retrieve any row or column, constraints or relation simply by accessing it either ordinarily or by retrieving it from a name-based collection.&lt;br /&gt;3. Connectivity Model: The ADO Recordset was originally designed without the ability to operate in a disconnected environment. ADO.NET DataSet is specifically designed to be a disconnected in-memory database. ADO.NET DataSet follows a pure disconnected connectivity model and this gives it much more scalability and versatility in the amount of things it can do and how easily it can do that.&lt;br /&gt;4. Marshalling and Serialization: In COM, through Marshalling, we can pass data from 1 COM component to another component at any time. Marshalling involves copying and processing data so that a complex type can appear to the receiving component the same as it appeared to the sending component. Marshalling is an expensive operation. ADO.NET Dataset and DataTable components support Remoting in the form of XML serialization. Rather than doing expensive Marshalling, it uses XML and sent data across boundaries.&lt;br /&gt;5. Firewalls and DCOM and Remoting: Those who have worked with DCOM know that how difficult it is to marshal a DCOM component across a router. People generally came up with workarounds to solve this issue. ADO.NET DataSet uses Remoting, through which a DataSet / DataTable component can be serialized into XML, sent across the wire to a new AppDomain, and then Desterilized back to a fully functional DataSet. As the DataSet is completely disconnected, and it has no dependency, we lose absolutely nothing by serializing and transferring it through Remoting.&lt;br /&gt;&lt;br /&gt;How do you handle data concurrency in .NET ?&lt;br /&gt;One of the key features of the ADO.NET DataSet is that it can be a self-contained and disconnected data store. It can contain the schema and data from several rowsets in DataTable objects as well as information about how to relate the DataTable objects-all in memory. The DataSet neither knows nor cares where the data came from, nor does it need a link to an underlying data source. Because it is data source agnostic you can pass the DataSet around networks or even serialize it to XML and pass it across the Internet without losing any of its features. However, in a disconnected model, concurrency obviously becomes a much bigger problem than it is in a connected model.&lt;br /&gt;In this column, I'll explore how ADO.NET is equipped to detect and handle concurrency violations. I'll begin by discussing scenarios in which concurrency violations can occur using the ADO.NET disconnected model. Then I will walk through an ASP.NET application that handles concurrency violations by giving the user the choice to overwrite the changes or to refresh the out-of-sync data and begin editing again. Because part of managing an optimistic concurrency model can involve keeping a timestamp (rowversion) or another type of flag that indicates when a row was last updated, I will show how to implement this type of flag and how to maintain its value after each database update.&lt;br /&gt;&lt;br /&gt;Is Your Glass Half Full?&lt;br /&gt;There are three common techniques for managing what happens when users try to modify the same data at the same time: pessimistic, optimistic, and last-in wins. They each handle concurrency issues differently.&lt;br /&gt;The pessimistic approach says: "Nobody can cause a concurrency violation with my data if I do not let them get at the data while I have it." This tactic prevents concurrency in the first place but it limits scalability because it prevents all concurrent access. Pessimistic concurrency generally locks a row from the time it is retrieved until the time updates are flushed to the database. Since this requires a connection to remain open during the entire process, pessimistic concurrency cannot successfully be implemented in a disconnected model like the ADO.NET DataSet, which opens a connection only long enough to populate the DataSet then releases and closes, so a database lock cannot be held.&lt;br /&gt;Another technique for dealing with concurrency is the last-in wins approach. This model is pretty straightforward and easy to implement-whatever data modification was made last is what gets written to the database. To implement this technique you only need to put the primary key fields of the row in the UPDATE statement's WHERE clause. No matter what is changed, the UPDATE statement will overwrite the changes with its own changes since all it is looking for is the row that matches the primary key values. Unlike the pessimistic model, the last-in wins approach allows users to read the data while it is being edited on screen. However, problems can occur when users try to modify the same data at the same time because users can overwrite each other's changes without being notified of the collision. The last-in wins approach does not detect or notify the user of violations because it does not care. However the optimistic technique does detect violations. Contd....&lt;br /&gt;In optimistic concurrency models, a row is only locked during the update to the database. Therefore the data can be retrieved and updated by other users at any time other than during the actual row update operation. Optimistic concurrency allows the data to be read simultaneously by multiple users and blocks other users less often than its pessimistic counterpart, making it a good choice for ADO.NET. In optimistic models, it is important to implement some type of concurrency violation detection that will catch any additional attempt to modify records that have already been modified but not committed. You can write your code to handle the violation by always rejecting and canceling the change request or by overwriting the request based on some business rules. Another way to handle the concurrency violation is to let the user decide what to do. The sample application that is shown in Figure 1 illustrates some of the options that can be presented to the user in the event of a concurrency violation.&lt;br /&gt;Where Did My Changes Go?&lt;br /&gt;When users are likely to overwrite each other's changes, control mechanisms should be put in place. Otherwise, changes could be lost. If the technique you're using is the last-in wins approach, then these types of overwrites are entirely possible.For example, imagine Julie wants to edit an employee's last name to correct the spelling. She navigates to a screen which loads the employee's information into a DataSet and has it presented to her in a Web page. Meanwhile, Scott is notified that the same employee's phone extension has changed. While Julie is correcting the employee's last name, Scott begins to correct his extension. Julie saves her changes first and then Scott saves his.Assuming that the application uses the last-in wins approach and updates the row using a SQL WHERE clause containing only the primary key's value, and assuming a change to one column requires the entire row to be updated, neither Julie nor Scott may immediatelyrealize the concurrency issue that just occurred. In this particular situation, Julie's changes were overwritten by Scott's changes because he saved last, and the last name reverted to the misspelled version.&lt;br /&gt;So as you can see, even though the users changed different fields, their changes collided and caused Julie's changes to be lost. Without some sort of concurrency detection and handling, these types of overwrites can occur and even go unnoticed.When you run the sample application included in this column's download, you should open two separate instances of Microsoft® Internet Explorer. When I generated the conflict, I opened two instances to simulate two users with two separate sessions so that a concurrency violation would occur in the sample application. When you do this, be careful not to use Ctrl+N because if you open one instance and then use the Ctrl+N technique to open another instance, both windows will share the same session.&lt;br /&gt;Detecting Violations&lt;br /&gt;The concurrency violation reported to the user in Figure 1 demonstrates what can happen when multiple users edit the same data at the same time. In Figure 1, the user attempted to modify the first name to "Joe" but since someone else had already modified the last name to "Fuller III," a concurrency violation was detected and reported. ADO.NET detects a concurrency violation when a DataSet containing changed values is passed to a SqlDataAdapter's Update method and no rows are actually modified. Simply using the primary key (in this case the EmployeeID) in the UPDATE statement's WHERE clause will not cause a violation to be detected because it still updates the row (in fact, this technique has the same outcome as the last-in wins technique). Instead, more conditions must be specified in the WHERE clause in order for ADO.NET to detect the violation.&lt;br /&gt;The key here is to make the WHERE clause explicit enough so that it not only checks the primary key but that it also checks for another appropriate condition. One way to accomplish this is to pass in all modifiable fields to the WHERE clause in addition to the primary key. For example, the application shown in Figure 1 could have its UPDATE statement look like the stored procedure that's shown in Figure 2.&lt;br /&gt;Notice that in the code in Figure 2 nullable columns are also checked to see if the value passed in is NULL. This technique is not only messy but it can be difficult to maintain by hand and it requires you to test for a significant number of WHERE conditions just to update a row. This yields the desired result of only updating rows where none of the values have changed since the last time the user got the data, but there are other techniques that do not require such a huge WHERE clause.&lt;br /&gt;Another way to make sure that the row is only updated if it has not been modified by another user since you got the data is to add a timestamp column to the table. The SQL Server(tm) TIMESTAMP datatype automatically updates itself with a new value every time a value in its row is modified. This makes it a very simple and convenient tool to help detect concurrency violations.&lt;br /&gt;A third technique is to use a DATETIME column in which to track changes to its row. In my sample application I added a column called LastUpdateDateTime to the Employees table.&lt;br /&gt;ALTER TABLE Employees ADD LastUpdateDateTime DATETIME&lt;br /&gt;There I update the value of the LastUpdateDateTime field automatically in the UPDATE stored procedure using the built-in SQL Server GETDATE function.&lt;br /&gt;The binary TIMESTAMP column is simple to create and use since it automatically regenerates its value each time its row is modified, but since the DATETIME column technique is easier to display on screen and demonstrate when the change was made, I chose it for my sample application. Both of these are solid choices, but I prefer the TIMESTAMP technique since it does not involve any additional code to update its value.&lt;br /&gt;Retrieving Row Flags&lt;br /&gt;One of the keys to implementing concurrency controls is to update the timestamp or datetime field's value back into the DataSet. If the same user wants to make more modifications, this updated value is reflected in the DataSet so it can be used again. There are a few different ways to do this. The fastest is using output parameters within the stored procedure. (This should only return if @@ROWCOUNT equals 1.) The next fastest involves selecting the row again after the UPDATE within the stored procedure. The slowest involves selecting the row from another SQL statement or stored procedure from the SqlDataAdapter's RowUpdated event.&lt;br /&gt;I prefer to use the output parameter technique since it is the fastest and incurs the least overhead. Using the RowUpdated event works well, but it requires me to make a second call from the application to the database. The following code snippet adds an output parameter to the SqlCommand object that is used to update the Employee information:&lt;br /&gt;oUpdCmd.Parameters.Add(new SqlParameter("@NewLastUpdateDateTime",&lt;br /&gt;  SqlDbType.DateTime, 8, ParameterDirection.Output,&lt;br /&gt;  false, 0, 0, "LastUpdateDateTime", DataRowVersion.Current, null));&lt;br /&gt;oUpdCmd.UpdatedRowSource = UpdateRowSource.OutputParameters;&lt;br /&gt;The output parameter has its sourcecolumn and sourceversion arguments set to point the output parameter's return value back to the current value of the LastUpdateDateTime column of the DataSet. This way the updated DATETIME value is retrieved and can be returned to the user's .aspx page. Contd....&lt;br /&gt;Saving Changes&lt;br /&gt;Now that the Employees table has the tracking field (LastUpdateDateTime) and the stored procedure has been created to use both the primary key and the tracking field in the WHERE clause of the UPDATE statement, let's take a look at the role of ADO.NET. In order to trap the event when the user changes the values in the textboxes, I created an event handler for the TextChanged event for each TextBox control:&lt;br /&gt;private void txtLastName_TextChanged(object sender, System.EventArgs e)&lt;br /&gt;{&lt;br /&gt;    // Get the employee DataRow (there is only 1 row, otherwise I could&lt;br /&gt;    // do a Find)&lt;br /&gt;    dsEmployee.EmployeeRow oEmpRow =&lt;br /&gt;           (dsEmployee.EmployeeRow)oDsEmployee.Employee.Rows[0];&lt;br /&gt;    oEmpRow.LastName = txtLastName.Text;&lt;br /&gt;    // Save changes back to Session&lt;br /&gt;    Session["oDsEmployee"] = oDsEmployee;&lt;br /&gt;}&lt;br /&gt;This event retrieves the row and sets the appropriate field's value from the TextBox. (Another way of getting the changed values is to grab them when the user clicks the Save button.) Each TextChanged event executes after the Page_Load event fires on a postback, so assuming the user changed the first and last names, when the user clicks the Save button, the events could fire in this order: Page_Load, txtFirstName_TextChanged, txtLastName_TextChanged, and btnSave_Click.&lt;br /&gt;The Page_Load event grabs the row from the DataSet in the Session object; the TextChanged events update the DataRow with the new values; and the btnSave_Click event attempts to save the record to the database. The btnSave_Click event calls the SaveEmployee method (shown in Figure 3) and passes it a bLastInWins value of false since we want to attempt a standard save first. If the SaveEmployee method detects that changes were made to the row (using the HasChanges method on the DataSet, or alternatively using the RowState property on the row), it creates an instance of the Employee class and passes the DataSet to its SaveEmployee method. The Employee class could live in a logical or physical middle tier. (I wanted to make this a separate class so it would be easy to pull the code out and separate it from the presentation logic.)&lt;br /&gt;Notice that I did not use the GetChanges method to pull out only the modified rows and pass them to the Employee object's Save method. I skipped this step here since there is only one row. However, if there were multiple rows in the DataSet's DataTable, it would be better to use the GetChanges method to create a DataSet that contains only the modified rows.&lt;br /&gt;If the save succeeds, the Employee.SaveEmployee method returns a DataSet containing the modified row and its newly updated row version flag (in this case, the LastUpdateDateTime field's value). This DataSet is then merged into the original DataSet so that the LastUpdateDateTime field's value can be updated in the original DataSet. This must be done because if the user wants to make more changes she will need the current values from the database merged back into the local DataSet and shown on screen. This includes the LastUpdateDateTime value which is used in the WHERE clause. Without this field's current value, a false concurrency violation would occur.&lt;br /&gt;Reporting Violations&lt;br /&gt;If a concurrency violation occurs, it will bubble up and be caught by the exception handler shown in Figure 3 in the catch block for DBConcurrencyException. This block calls the FillConcurrencyValues method, which displays both the original values in the DataSet that were attempted to be saved to the database and the values currently in the database. This method is used merely to show the user why the violation occurred. Notice that the exDBC variable is passed to the FillConcurrencyValues method. This instance of the special database concurrency exception class (DBConcurrencyException) contains the row where the violation occurred. When a concurrency violation occurs, the screen is updated to look like Figure 1.&lt;br /&gt;The DataSet not only stores the schema and the current data, it also tracks changes that have been made to its data. It knows which rows and columns have been modified and it keeps track of the before and after versions of these values. When accessing a column's value via the DataRow's indexer, in addition to the column index you can also specify a value using the DataRowVersion enumerator. For example, after a user changes the value of the last name of an employee, the following lines of C# code will retrieve the original and current values stored in the LastName column:&lt;br /&gt;string sLastName_Before = oEmpRow["LastName", DataRowVersion.Original];&lt;br /&gt;string sLastName_After = oEmpRow["LastName", DataRowVersion.Current];&lt;br /&gt;The FillConcurrencyValues method uses the row from the DBConcurrencyException and gets a fresh copy of the same row from the database. It then displays the values using the DataRowVersion enumerators to show the original value of the row before the update and the value in the database alongside the current values in the textboxes.&lt;br /&gt;User's Choice&lt;br /&gt;Once the user has been notified of the concurrency issue, you could leave it up to her to decide how to handle it. Another alternative is to code a specific way to deal with concurrency, such as always handling the exception to let the user know (but refreshing the data from the database). In this sample application I let the user decide what to do next. She can either cancel changes, cancel and reload from the database, save changes, or save anyway.&lt;br /&gt;The option to cancel changes simply calls the RejectChanges method of the DataSet and rebinds the DataSet to the controls in the ASP.NET page. The RejectChanges method reverts the changes that the user made back to its original state by setting all of the current field values to the original field values. The option to cancel changes and reload the data from the database also rejects the changes but additionally goes back to the database via the Employee class in order to get a fresh copy of the data before rebinding to the control on the ASP.NET page.&lt;br /&gt;The option to save changes attempts to save the changes but will fail if a concurrency violation is encountered. Finally, I included a "save anyway" option. This option takes the values the user attempted to save and uses the last-in wins technique, overwriting whatever is in the database. It does this by calling a different command object associated with a stored procedure that only uses the primary key field (EmployeeID) in the WHERE clause of the UPDATE statement. This technique should be used with caution as it will overwrite the record.&lt;br /&gt;If you want a more automatic way of dealing with the changes, you could get a fresh copy from the database. Then overwrite just the fields that the current user modified, such as the Extension field. That way, in the example I used the proper LastName would not be overwritten. Use this with caution as well, however, because if the same field was modified by both users, you may want to just back out or ask the user what to do next. What is obvious here is that there are several ways to deal with concurrency violations, each of which must be carefully weighed before you decide on the one you will use in your application.&lt;br /&gt;Wrapping It Up&lt;br /&gt;Setting the SqlDataAdapter's ContinueUpdateOnError property tells the SqlDataAdapter to either throw an exception when a concurrency violation occurs or to skip the row that caused the violation and to continue with the remaining updates. By setting this property to false (its default value), it will throw an exception when it encounters a concurrency violation. This technique is ideal when only saving a single row or when you are attempting to save multiple rows and want them all to commit or all to fail.&lt;br /&gt;I have split the topic of concurrency violation management into two parts. Next time I will focus on what to do when multiple rows could cause concurrency violations. I will also discuss how the DataViewRowState enumerators can be used to show what changes have been made to a DataSet.&lt;br /&gt;How you will set the datarelation between two columns?&lt;br /&gt;ADO.NET provides DataRelation object to set relation between two columns.It helps to enforce the following  constraints,a unique constraint, which guarantees that a column in the table  contains no duplicates and a foreign-key constraint,which can be used to maintain referential  integrity.A unique constraint is implemented either by simply setting the Unique property of a data  column to true, or by adding an instance of the UniqueConstraint class to the DataRelation object's ParentKeyConstraint. As part of the foreign-key constraint, you can specify referential integrity  rules that are applied at three points,when a parent record is updated,when a parent record is deleted and when a change is accepted or rejected.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2358940550520121354-3263518977980995363?l=aspnetcsharp4.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetcsharp4.blogspot.com/feeds/3263518977980995363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2358940550520121354&amp;postID=3263518977980995363' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3263518977980995363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2358940550520121354/posts/default/3263518977980995363'/><link rel='alternate' type='text/html' href='http://aspnetcsharp4.blogspot.com/2009/07/framework-support.html' title='Framework Support'/><author><name>kulveer singh</name><uri>https://profiles.google.com/114335276984459593648</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-Ow4J9UhedZA/AAAAAAAAAAI/AAAAAAAABV0/qsManVfECEM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2358940550520121354.post-7224027190686498291</id><published>2009-07-24T21:20:00.000-07:00</published><updated>2009-07-24T21:20:00.424-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET Interview Questions'/><title type='text'>.NET FrameWork FAQ's</title><content type='html'>When was .NET announced?&lt;br /&gt;Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET.&lt;br /&gt;&lt;br /&gt;When was the first version of .NET released?&lt;br /&gt;The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on 15-Jan-2002. At the same time, the final version of Visual Studio.NET was made available to MSDN subscribers.&lt;br /&gt;&lt;br /&gt;What platforms does the .NET Framework run on?&lt;br /&gt;The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development.&lt;br /&gt;IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the ASP.NET Web Matrix&lt;br /&gt;web server does run on XP Home.&lt;br /&gt;The Mono project is attempting to implement the .NET framework on Linux.&lt;br /&gt;&lt;br /&gt;What is the CLR?&lt;br /&gt;CLR = Common Language Runtime. The CLR is a set of standard resources that (in theory) any .NET program can take advantage of, regardless of programming language. Robert Schmidt (Microsoft) lists the following CLR resources in his MSDN PDC# article:&lt;br /&gt;Object-oriented programming model (inheritance, polymorphism, exception handling, garbage collection)&lt;br /&gt;Security model&lt;br /&gt;Type system&lt;br /&gt;All .NET base classes&lt;br /&gt;Many .NET framework classes&lt;br /&gt;Development, debugging, and profiling tools&lt;br /&gt;Execution and code management&lt;br /&gt;IL-to-native translators and optimizers&lt;br /&gt;What this means is that in the .NET world, different programming languages will be more equal in capability than they have ever been before, although clearly not all languages will support all CLR services.&lt;br /&gt;&lt;br /&gt;What is the CTS?&lt;br /&gt;CTS = Common Type System. This is the range of types that the .NET runtime understands, and therefore that .NET applications can use. However note that not all .NET languages will support all the types in the CTS. The CTS is a superset of the CLS.&lt;br /&gt;&lt;br /&gt;What is the CLS?&lt;br /&gt;CLS = Common Language Specification. This is a subset of the CTS which all .NET languages are expected to support. The idea is that any program which uses CLS-compliant types can interoperate with any .NET program written in any language.&lt;br /&gt;In theory this allows very tight interop between different .NET languages - for example allowing a C# class to inherit from a VB class.&lt;br /&gt;&lt;br /&gt;What is IL?&lt;br /&gt;IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL. The IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.&lt;br /&gt;&lt;br /&gt;What does 'managed' mean in the .NET context?&lt;br /&gt;The term 'managed' is the cause of much confusion. It is used in various places within .NET, meaning slightly different things.Managed code: The .NET framework provides several core run-time services to the programs that run within it - for example&lt;br /&gt;exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime.&lt;br /&gt;Such code is called managed code. All C# and Visual Basic.NET code is managed by default. VS7 C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/com+).&lt;br /&gt;Managed data: This is data that is allocated and de-allocated by the .NET runtime's garbage collector. C# and VB.NET data is always managed. VS7 C++ data is unmanaged by default, even when using the /com+ switch, but it can be marked as managed using the __gc keyword.Managed classes: This is usually referred to in the context of Managed Extensions (ME) for C++. When using ME C++, a class can be marked with the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector, but it also means more than that. The class becomes a fully paid-up member of the .NET community with the benefits and restrictions that brings. An example of a benefit is proper interop with classes written in other languages - for example, a managed C++ class can inherit from a VB class. An example of a restriction is that a managed class can only inherit from one base class.&lt;br /&gt;&lt;br /&gt;What is reflection?&lt;br /&gt;All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.&lt;br /&gt;Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.&lt;br /&gt;Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember ) ,  or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).&lt;br /&gt;&lt;br /&gt;What is the difference between Finalize and Dispose (Garbage collection) ?&lt;br /&gt;Class instances often encapsulate control over resources that are not managed by the runtime, such as window handles (HWND), database connections, and so on. Therefore, you should provide both an explicit and an implicit way to free those resources. Provide implicit control by implementing the protected Finalize Method on an object (destructor syntax in C# and the Managed Extensions for C++). The garbage collector calls this method at some point after there are no longer any valid references to the object. In some cases, you might want to provide programmers using an object with the ability to explicitly release these external resources before the garbage collector frees the object. If an external resource is scarce or expensive, better performance can be achieved if the programmer explicitly releases resources when they are no longer being used. To provide explicit control, implement the Dispose method provided by the IDisposable Interface. The consumer of the object should call this method when it is done using the object.&lt;br /&gt;Dispose can be called even if other references to the object are alive. Note that even when you provide explicit control by way of Dispose, you should provide implicit cleanup using the Finalize method. Finalize provides a backup to prevent resources from&lt;br /&gt;permanently leaking if the programmer fails to call Dispose.&lt;br /&gt;&lt;br /&gt;What is Partial Assembly References?&lt;br /&gt;Full Assembly reference: A full assembly reference includes the assembly's text name, version, culture, and public key token (if the assembly has a strong name). A full assembly reference is required if you reference any assembly that is part of the common&lt;br /&gt;language runtime or any assembly located in the global assembly cache.&lt;br /&gt;&lt;br /&gt;Partial Assembly reference: We can dynamically reference an assembly by providing only partial information, such as specifying only the assembly name. When you specify a partial assembly reference, the runtime looks for the assembly only in the application&lt;br /&gt;directory.&lt;br /&gt;We can make partial references to an assembly in your code one of the following ways:&lt;br /&gt;-&gt; Use a method such as System.Reflection.Assembly.Load and specify only a partial reference. The runtime checks for the assembly in the application directory.&lt;br /&gt;-&gt; Use the System.Reflection.Assembly.LoadWithPartialName method and specify only a partial reference. The runtime checks for the assembly in the application directory and in the global assembly cache&lt;br /&gt;&lt;br /&gt;Changes to which portion of version number indicates an incompatible change?&lt;br /&gt;Major or minor. Changes to the major or minor portion of the version number indicate an incompatible change. Under this convention then, version 2.0.0.0 would be considered incompatible with version 1.0.0.0. Examples of an incompatible change would be a change to the types of some method parameters or the removal of a type or method altogether. Build. The Build number is typically used to distinguish between daily builds or smaller compatible releases. Revision. Changes to the revision number are typically reserved for an incremental build needed to fix a particular bug. You'll sometimes hear this referred to as the "emergency bug fix" number in that the revision is what is often changed when a fix to a specific bug is shipped to a customer.&lt;br /&gt;What is side-by-side execution? Can two application one using private assembly and other using Shared assembly be stated as a side-by-side executables?&lt;br /&gt;Side-by-side execution is the ability to run multiple versions of an application or component on the same computer. You can have multiple versions of the common language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time. Since versioning is only applied to shared assemblies, and not to private assemblies, two application one using private assembly and one using shared assembly cannot be stated as side-by-side&lt;br /&gt;executables.&lt;br /&gt;&lt;br /&gt;Why string are called Immutable data Type ?&lt;br /&gt;The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is formed &amp;amp; the start address is changed . Thus keeping the Old string in Memory for Garbage Collector to be disposed.&lt;br /&gt;&lt;br /&gt;What does assert() method do?&lt;br /&gt;In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.&lt;br /&gt;&lt;br /&gt;What's the difference between the Debug class and Trace class?&lt;br /&gt;Documentation looks the same.  Use Debug class for debug builds, use Trace class for both debug and release builds.&lt;br /&gt;&lt;br /&gt;Why are there five tracing levels in System.Diagnostics.TraceSwitcher?&lt;br /&gt;The tracing dumps can be quite verbose.  For applications that are constantly running you run the risk of overloading the machine and the hard drive.  Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.&lt;br /&gt;&lt;br /&gt;Where is the output of TextWriterTraceListener redirected?&lt;br /&gt;To the Console or a text file depending on the parameter passed to the constructor.&lt;br /&gt;&lt;br /&gt;How do assemblies find each other?&lt;br /&gt;By searching directory paths. There are several factors which can affect the path (such as the AppDomain host, and application configuration files), but for private assemblies the search path is normally the application's directory and its sub-directories. For shared assemblies, the search path is normally same as the private assembly path plus the shared assembly cache.&lt;br /&gt;&lt;br /&gt;How does assembly versioning work?&lt;br /&gt;Each assembly has a version number called the compatibility version. Also each reference to an assembly (from another assembly) includes both the name and version of the referenced assembly.The version number has four numeric parts (e.g. 5.5.2.33). Assemblies with either of the first two parts different are normally viewed as incompatible. If the first two parts are the same, but the third is different, the assemblies are deemed as 'maybe compatible'. If only the fourth part is different, the assemblies are deemed compatible. However, this is just the default guideline - it is the version policy that decides to what extent these rules are enforced. The version policy can be specified via the application configuration file.&lt;br /&gt;&lt;br /&gt;What is garbage collection?&lt;br /&gt;Garbage collection is a system whereby a run-time component takes responsibility for managing the lifetime of objects and the heap memory that they occupy. This concept is not new to .NET - Java and many other languages/runtimes have used garbage collection for some time.&lt;br /&gt;&lt;br /&gt;Why doesn't the .NET runtime offer deterministic destruction?&lt;br /&gt;Because of the garbage collection algorithm. The .NET garbage collector works by periodically running through a list of all the objects that are currently being referenced by an application. All the objects that it doesn't find during this search are ready to be destroyed and the memory reclaimed. The implication of this algorithm is that the runtime doesn't get notified immediately when the final reference on an object goes away - it only finds out during the next sweep of the heap.&lt;br /&gt;Futhermore, this type of algorithm works best by performing the garbage collection sweep as rarely as possible. Normally heap exhaustion is the trigger for a collection sweep.&lt;br /&gt;&lt;br /&gt;Is the lack of deterministic destruction in .NET a problem?&lt;br /&gt;It's certainly an issue that affects component design. If you have objects that maintain expensive or scarce resources (e.g. database locks), you need to provide some way for the client to tell the object to release the resource when it is done. Microsoft recommend that you provide a method called Dispose() for this purpose. However, this causes problems for distributed objects - in a distributed system who calls the Dispose() method? Some form of reference-counting or ownership-management mechanism is needed to handle distributed objects - unfortunately the runtime offers no help with this.&lt;br /&gt;&lt;br /&gt;What is serialization?&lt;br /&gt;Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process of creating an object from a stream of bytes. Serialization / Deserialization is mostly used to transport objects (e.g. during remoting), or to persist&lt;br /&gt;objects (e.g. to a file or database).&lt;br /&gt;&lt;br /&gt;Does the .NET Framework have in-built support for serialization?&lt;br /&gt;There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code.&lt;br /&gt;&lt;br /&gt;Can I customise the serialization process?&lt;br /&gt;Yes. XmlSerializer supports a range of attributes that can be used to configure serialization for a particular class. For example, a field or property can be marked with the [XmlIgnore] attribute to exclude it from serialization. Another example is the [XmlElement]&lt;br /&gt;attribute, which can be used to specify the XML element name to be used for a particular property or field.&lt;br /&gt;Serialization via SoapFormatter/BinaryFormatter can also be controlled to some extent by attributes. For example, the [NonSerialized] attribute is the equivalent of XmlSerializer's [XmlIgnore] attribute. Ultimate control of the serialization process can be acheived by implementing the the ISerializable interface on the class whose instances are to be serialized.&lt;br /&gt;&lt;br /&gt;Why is XmlSerializer so slow?&lt;br /&gt;There is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize or deserialize an object of a given type in an application, there is a significant delay. This normally doesn't matter, but it may mean, for example, that XmlSerializer is a poor choice for loading configuration settings during startup of a GUI application.&lt;br /&gt;&lt;br /&gt;Why do I get errors when I try to serialize a Hashtable?&lt;br /&gt;XmlSerializer will refuse to serialize instances of any class that implements IDictionary, e.g. Hashtable. SoapFormatter and BinaryFormatter do not have this restriction.&lt;br /&gt;&lt;br /&gt;What are attributes?&lt;br /&gt;There are at least two types of .NET attribute. The first type I will refer to as a metadata attribute - it allows some data to be attached to a class or method. This data becomes part of the metadata for the class, and (like other class metadata) can be accessed via reflection.&lt;br /&gt;The other type of attribute is a context attribute. Context attributes use a similar syntax to metadata attributes but they are fundamentally different. Context attributes provide an interception mechanism whereby instance activation and method calls can be&lt;br /&gt;pre- and/or post-processed.&lt;br /&gt;&lt;br /&gt;How does CAS work?&lt;br /&gt;The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set.&lt;br /&gt;For example, using the default security policy, a control downloaded from a web site belongs to the 'Zone - Internet' code group, which adheres to the permissions defined by the 'Internet' named permission set. (Naturally the 'Internet' named permission set represents a very restrictive range of permissions.)&lt;br /&gt;&lt;br /&gt;Who defines the CAS code groups?&lt;br /&gt;Microsoft defines some default ones, but you can modify these and even create your own. To see the code groups defined on your system, run 'caspol -lg' from the command-line. On my system it looks like this:&lt;br /&gt;Level = Machine&lt;br /&gt;Code Groups:&lt;br /&gt;1.  All code: Nothing&lt;br /&gt;  1.1.  Zone - MyComputer: FullTrust&lt;br /&gt;     1.1.1.  Honor SkipVerification requests: SkipVerification&lt;br /&gt;  1.2.  Zone - Intranet: LocalIntranet&lt;br /&gt;  1.3.  Zone - Internet: Internet&lt;br /&gt;  1.4.  Zone - Untrusted: Nothing&lt;br /&gt;  1.5.  Zone - Trusted: Internet&lt;br /&gt;  1.6.  StrongName - 0024000004800000940000000602000000240000525341310004000003&lt;br /&gt;000000CFCB3291AA715FE99D40D49040336F9056D7886FED46775BC7BB5430BA4444FEF8348EBD06&lt;br /&gt;F962F39776AE4DC3B7B04A7FE6F49F25F740423EBF2C0B89698D8D08AC48D69CED0FC8F83B465E08&lt;br /&gt;07AC11EC1DCC7D054E807A43336DDE408A5393A48556123272CEEEE72F1660B71927D38561AABF5C&lt;br /&gt;AC1DF1734633C602F8F2D5:&lt;br /&gt;Note the hierarchy of code groups - the top of the hierarchy is the most general ('All code'), which is then sub-divided into several&lt;br /&gt;groups, each of which in turn can be sub-divided. Also note that (somewhat counter-intuitively) a sub-group can be associated with a more permissive permission set than its parent.&lt;br /&gt;&lt;br /&gt;How do I define my own code group?&lt;br /&gt;Use caspol. For example, suppose you trust code from www.mydomain.com and you want it have full access to your system, but you want to keep the default restrictions for all other internet sites. To achieve this, you would add a new code group as a sub-group of the&lt;br /&gt;'Zone - Internet' group, like this:&lt;br /&gt;caspol -ag 1.3 -site www.mydomain.com FullTrust&lt;br /&gt;Now if you run caspol -lg you will see that the new group has been added as group 1.3.1:&lt;br /&gt;&lt;br /&gt;  1.3.  Zone - Internet: Internet&lt;br /&gt;     1.3.1.  Site - www.mydomain.com: FullTrust&lt;br /&gt;&lt;br /&gt;Note that the numeric label (1.3.1) is just a caspol invention to make the code groups easy to manipulate from the command-line. The underlying runtime never sees it.&lt;br /&gt;How do I change the permission set for a code group?&lt;br /&gt;Use caspol. If you are the machine administrator, you can operate at the 'machine' level - which means not only that the changes you make become the default for the machine, but also that users cannot change the permissions to be more permissive. If you are a normal (non-admin) user you can still modify the permissions, but only to make them more restrictive. For example, to allow intranet code to do what it likes you might do this:&lt;br /&gt;caspol -cg 1.2 FullTrust&lt;br /&gt;Note that because this is more permissive than the default policy (on a standard system), you should only do this at the machine level - doing it at the user level will have no effect.&lt;br /&gt;&lt;br /&gt;I can't be bothered with all this CAS stuff. Can I turn it off?&lt;br /&gt;Yes, as long as you are an administrator. Just run: caspol -s off&lt;br /&gt;&lt;br /&gt;Can I look at the IL for an assembly?&lt;br /&gt;Yes. MS supply a tool called Ildasm which can be used to view the metadata and IL for an assembly.&lt;br /&gt;&lt;br /&gt;Can source code be reverse-engineered from IL?&lt;br /&gt;Yes, it is often relatively straightforward to regenerate high-level source (e.g. C#) from IL.&lt;br /&gt;&lt;br /&gt;How can I stop my code being reverse-engineered from IL?&lt;br /&gt;There is currently no simple way to stop code being reverse-engineered from IL. In future it is likely that IL obfuscation tools will become available, either from MS or from third parties. These tools work by 'optimising' the IL in such a way that reverse-engineering becomes much more difficult.&lt;br /&gt;Of course if you are writing web services then reverse-engineering is not a problem as clients do not have access to your IL.&lt;br /&gt;&lt;br /&gt;Is there built-in support for tracing/logging?&lt;br /&gt;Yes, in the System.Diagnostics namespace. There are two main classes that deal with tracing - Debug and Trace. They both work in a similar way - the difference is that tracing from the Debug class only works in builds that have the DEBUG symbol defined, whereas tracing from the Trace class only works in builds that have the TRACE symbol defined. Typically this means that you should use System.Diagnostics.Trace.WriteLine for tracing that you want to work in debug and release builds, and System.Diagnostics.Debug.WriteLine for tracing that you want to work only in debug builds.&lt;br /&gt;&lt;br /&gt;Can I redirect tracing to a file?&lt;br /&gt;Yes. The Debug and Trace classes both have a Listeners property, which is a collection of sinks that receive the tracing that you send via Debug.WriteLine and Trace.WriteLine respectively. By default the Listeners collection contains a single sink, which is an&lt;br /&gt;instance of the DefaultTraceListener class. This sends output to the Win32 OutputDebugString() function and also the System.Diagnostics.Debugger.Log() method. This is useful when debugging, but if you're trying to trace a problem at a customer site, redirecting the output to a file is more appropriate. Fortunately, the TextWriterTraceListener class is provided for this purpose.&lt;br /&gt;&lt;br /&gt;What are the contents of assembly?&lt;br /&gt;In general, a static assembly can consist of four elements:&lt;br /&gt;The assembly manifest, which contains assembly metadata.&lt;br /&gt;Type metadata.&lt;br /&gt;Microsoft intermediate language (MSIL) code that implements the types.&lt;br /&gt;A set of resources.&lt;br /&gt;&lt;br /&gt;What is GC (Garbage Collection) and how it works&lt;br /&gt;One of the good features of the CLR is Garbage Collection, which runs in the background collecting unused object references, freeing us from having to ensure we always destroy them. In reality the time difference between you releasing the object instance and it being garbage collected is likely to be very small, since the GC is always running.&lt;br /&gt;[The process of transitively tracing through all pointers to actively used objects in order to locate all objects that can be referenced, and then arranging to reuse any heap memory that was not found during this trace. The common language runtime garbage collector also compacts the memory that is in use to reduce the working space needed for the heap.]&lt;br /&gt;&lt;br /&gt;Heap:&lt;br /&gt;A portion of memory reserved for a program to use for the temporary storage of data structures whose existence or size cannot be determined until the program is running.&lt;br /&gt;&lt;br /&gt;Differnce between Managed code and unmanaged code ?&lt;br /&gt;Managed Code:&lt;br /&gt;Code that runs under a "contract of cooperation" with the common language runtime. Managed code must supply the metadata necessary for the runtime to provide services such as memory management, cross-language integration, code access security, and&lt;br /&gt;automatic lifetime control of objects. All code based on Microsoft intermediate language (MSIL) executes as managed code.&lt;br /&gt;&lt;br /&gt;Un-Managed Code:&lt;br /&gt;Code that is created without regard for the conventions and requirements of the common language runtime. Unmanaged code executes in the common language runtime environment with minimal services (for example, no garbage collection, limited debugging, and so on).&lt;br /&gt;&lt;br /&gt;What is MSIL, IL, CTS and, CLR ?&lt;br /&gt;&lt;br /&gt;MSIL: (Microsoft intermediate language)&lt;br /&gt;When compiling to managed code, the compiler translates your source code into Microsoft intermediate language (MSIL), which is a CPU-independent set of instructions that can be efficiently converted to native code. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations. Before code can be executed, MSIL must be converted to CPU-specific code, usually by a just-in-time (JIT) compiler. Because the common language runtime supplies one or more JIT compilers for each computer architecture it supports, the same set of MSIL can be JIT-compiled and executed on any supported architecture.&lt;br /&gt;When a compiler produces MSIL, it also produces metadata. Metadata describes the types in your code, including the definition of&lt;br /&gt;each type, the signatures of each type's members, the members that your code references, and other data that the runtime uses at&lt;br /&gt;execution time. The MSIL and metadata are contained in a portable executable (PE) file that is based on and extends the published&lt;br /&gt;Microsoft PE and Common Object File Format (COFF) used historically for executable content. This file format, which accommodates&lt;br /&gt;&lt;br /&gt;MSIL or native code as well as metadata, enables the operating system to recognize common language runtime images. The&lt;br /&gt;presence of metadata in the file along with the MSIL enables your code to describe itself, which means that there is no need for type libraries or Interface Definition Language (IDL). The runtime locates and extracts the metadata from the file as needed during&lt;br /&gt;execution.&lt;br /&gt;&lt;br /&gt;IL: (Intermediate Language)&lt;br /&gt;A language used as the output of a number of compilers and as the input to a just-in-time (JIT) compiler. The common language&lt;br /&gt;runtime includes a JIT compiler for converting MSIL to native code.&lt;br /&gt;&lt;br /&gt;CTS: (Common Type System)&lt;br /&gt;The specification that determines how the common language runtime defines, uses, and manages types&lt;br /&gt;&lt;br /&gt;CLR: (Common Language Runtime)&lt;br /&gt;The engine at the core of managed code execution. The runtime supplies managed code with services such as cross-language&lt;br /&gt;integration, code access security, object lifetime management, and debugging and profiling support.&lt;br /&gt;&lt;br /&gt;What is Reference type and value type ?&lt;br /&gt;Reference Type:&lt;br /&gt;Reference types are allocated on the managed CLR heap, just like object types.&lt;br /&gt;A data type that is stored as a reference to the value's location. The value of a reference type is the location of the sequence of bits&lt;br /&gt;that represent the type's data. Reference types can be self-describing types, pointer types, or interface types&lt;br /&gt;&lt;br /&gt;Value Type:&lt;br /&gt;Value types are allocated on the stack just like primitive types in VBScript, VB6 and C/C++. Value types are not instantiated using new go out of scope when the function they are defined within returns.&lt;br /&gt;Value types in the CLR are defined as types that derive from system.valueType.&lt;br /&gt;&lt;br /&gt;A data type that fully describes a value by specifying the sequence of bits that constitutes the value's representation. Type information for a value type instance is not stored with the instance at run time, but it is available in metadata. Value type instances can be treated as objects using boxing.&lt;br /&gt;&lt;br /&gt;What is Boxing and unboxing ?&lt;br /&gt;Boxing:&lt;br /&gt;The conversion of a value type instance to an object, which implies that the instance will carry full type information at run time and will be allocated in the heap. The Microsoft intermediate language (MSIL) instruction set's box instruction converts a value type to an object by making a copy of the value type and embedding it in a newly allocated object.&lt;br /&gt;&lt;br /&gt;Un-Boxing:&lt;br /&gt;The conversion of an object instance to a value type.&lt;br /&gt;What is JIT and how is works ?&lt;br /&gt;An acronym for "just-in-time," a phrase that describes an action that is taken only when it becomes necessary, such as just-in-time compilation or just-in-time object activation&lt;br /&gt;&lt;br /&gt;What is portable executable (PE) ?&lt;br /&gt;The file format used for executable programs and for files to be linked together to form executable programs&lt;br /&gt;&lt;br /&gt;What is strong name?&lt;br /&gt;A name that consists of an assembly's identity—its simple text name, version number, and culture information (if provided)—strengthened by a public key and a digital signature generated over the assembly. Because the assembly manifest&lt;br /&gt;contains file hashes for all the files that constitute the assembly implementation, it is sufficient to generate the digital signature over just the one file in the assembly that contains the assembly manifest. Assemblies with the same strong name are expected to be identical&lt;br /&gt;&lt;br /&gt;What is global assembly cache?&lt;br /&gt;A machine-wide code cache that stores assemblies specifically installed to be shared by many applications on the computer. Applications deployed in the global assembly cache must have a strong name.&lt;br /&gt;&lt;br /&gt;What is difference between constants, readonly and, static ?&lt;br /&gt;Constants: The value can’t be changed&lt;br /&gt;Read-only: The value will be initialized only once from the constructor of the class.&lt;br /&gt;Static: Value can be initialized once.&lt;br /&gt;&lt;br /&gt;What is difference between shared and public?&lt;br /&gt;An assembly that can be referenced by more than one application. An assembly must be explicitly built to be shared by giving it a cryptographically strong name.&lt;br /&gt;&lt;br /&gt;What is namespace used for loading assemblies at run time and name the methods?&lt;br /&gt;System.Reflection&lt;br /&gt;&lt;br /&gt;What are the types of authentication in .net?&lt;br /&gt;We have three types of  authentication:&lt;br /&gt;1. Form authentication&lt;br /&gt;2.  Windows authentication&lt;br /&gt;3.  Passport&lt;br /&gt;This has to be declared in web.config file.&lt;br /&gt;&lt;br /&gt;What is the difference between a Struct and a Class ?&lt;br /&gt;The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects,&lt;br /&gt;you will allocate additional memory for referencing each object. In this case, the struct is less expensive.&lt;br /&gt;When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized. It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values.&lt;br /&gt;It is an error to initialize an instance field in a struct.&lt;br /&gt;There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.&lt;br /&gt;A struct is a value type, while a class is a reference type.&lt;br /&gt;How big is the datatype int in .NET?&lt;br /&gt;32 bits.&lt;br /&gt;&lt;br /&gt;How big is the char?&lt;br /&gt;16 bits (Unicode).&lt;br /&gt;&lt;br /&gt;How do you initiate a string without escaping each backslash?&lt;br /&gt;Put an @ sign in front of the double-quoted string.&lt;br /&gt;&lt;br /&gt;What's the access level of the visibility type internal?&lt;br /&gt;Current application.&lt;br /&gt;&lt;br /&gt;Explain encapsulation ?&lt;br /&gt;The implementation is hidden, the interface is exposed.&lt;br /&gt;&lt;br /&gt;What data type should you use if you want an 8-bit value that's signed?&lt;br /&gt;sbyte.&lt;br /&gt;&lt;br /&gt;Speaking of Boolean data types, what's different between C# and C/C++?&lt;br /&gt;There's no conversion between 0 and false, as well as any other number and true, like in C/C++.&lt;br /&gt;&lt;br /&gt;Where are the value-type variables allocated in the computer RAM?&lt;br /&gt;Stack.&lt;br /&gt;&lt;br /&gt;Where do the reference-type variables go in the RAM?&lt;br /&gt;The references go on the stack, while the objects themselves go on the heap.&lt;br /&gt;&lt;br /&gt;What is the difference between the value-type variables and reference-type variables in terms of garbage collection?&lt;br /&gt;The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects&lt;br /&gt;are picked up by GC when their references go null.&lt;br /&gt;&lt;br /&gt;How do you convert a string 
