Monday, 6 April 2015

Step-by-Step: Create the Search Service Application in SharePoint 2010

In my current project, I got the opportunity to set up the SharePoint 2010 farm creation. In this blog I will only talk about the way I configured the Search Service application. There are numerous links/contents available, this piece only talks about what I did. If I have missed any points please put your comments. Hope to talk about more configurations in coming blogs….
When we deploy and configure a Search service application, we perform the following basic steps:

  1. Create accounts – Domain user accounts are required to run the various search services and components.
  2. Create a Search service application – A Search service application provides enterprise search features and functionality.
  3. Configure the Search service application – Basic configuration of a Search service application includes configuring a default content access account, an e-mail contact, and content sources.
  4. Configure the Search topology – You can deploy crawl components, query components, and the administration component on different servers in the farm. You can also specify which instance of SQL Server is used to host the administration, crawl, and property databases.

1.1    Create Accounts


The below Accounts are required to configure search service application
#
Account
Use
1
Search service application
SharePoint Foundation Search Service Account: “spSearch”
The Windows user account that is used for the SharePoint Server Search service, the Search Admin Web Service application pool, and Search Query and Site Settings Web Service application pool.
2
Default content access
SharePoint Foundation Search Content Access Account:
“spSearchCA”
The identity that is used by the Search service application to access content when crawling.

1.1.1     Register Managed Accounts

The service account for search (the account used for the Search service account, the Search Admin Web Service, and the Search Query and Site Settings Web Service) must be registered as a managed account in SharePoint Server 2010 to make it available when you create the Search service application. Use the following procedure to register this account as a managed account.
#
Description
1
On the Central Administration home page, in the Quick Launch, click Security
2
On the Security page, in the General Security section, click Configure managed accounts
3
On the Managed Accounts page, click Register Managed Account (the AD users should have “Read” access permission defined in AD)

4
On the Register Managed Account page, in the Account Registration section, type the user name and password that you want to use as credentials for the service account
clip_image002
5
If you want SharePoint Server 2010 to manage password changes for this account, select the Enable automatic password change check box and configure the parameters for automatic password change

1.1.2     Search Database Architecture

#
Description
1
Architecture (Databases)
When you create a Search service application, SharePoint Server creates three databases for storing search information and associated data:
·         Administration Database – used to store search admin information
·         Crawl database – used to store crawl information
·         Property Database – used to store index information


1.2    Create a Search service application


You can create multiple Search service applications if you have to have multiple search indexes.

#
Description
1
Verify that the user account that is performing this procedure is a member of the Farm Administrators group for the farm for which you want to create the service application
2
On the Central Administration Home page, in the Application Management section, click Manage service applications
3
On the Manage Service Applications page, on the ribbon, click New, and then click Search Service Application
clip_image004
4
On the Create New Search Service Application page, accept the default value for Name, or type in a new name for the Search service application.
5
In the Search Service Account list, click the account that you created in the previous procedure to run the Search service
6
In the Application Pool for Search Admin Web Service section, do the following:
1.     Select the Create new application pool option, and then type a name for the application pool in the Application pool name text box.
2.     In the Select a security account for this application pool section, select the Configurable option, and then select the account that you created to run the application pool for the Search Admin Web Service from the list.
7
In the Application Pool for Search Query and Site Settings Web Service section, do the following:
1.     Choose the Create new application pool option, and then type a name for the application pool in the Application pool name text box.
2.     In the Select a security account for this application pool section, select the Configurable option, and then select the account that you created to run the application pool for the Search Query and Site Settings Web Service from the list.

8
Click OK on the new Create New Search Service Application dialog to provision the new service application.
9
Once the Search Service Application has been successfully provisioned on the server farm you will have a topology with 1 Search Administration, 1 Crawl, and 1 Query component on the machine hosting SharePoint 2010 Central Administration and all associated databases on the default database server.


1.3    Configure the Search service application


You configure a Search service application on the Search Administration page for that service application.

Use the following procedure to navigate to the Search Administration page for a particular Search service application.

#
Description
1
Verify that the user account that is performing this procedure is an administrator for the Search service application that you want to configure.
2
On the Home page of the Central Administration Web site, in the Application Management section, click Manage service applications.
On the Manage Service Applications page, click the Search service application that you want to configure. Go to the Search Administration page
clip_image006
4
On the Search Administration page, configure the following settings as described in the following sections:
  • Default content access account
  • Contact email address
  • Content sources

5

Specify the default content access account

When you create a Search service application, the account that you specify for the Search Service Account is automatically configured as the default content access account. The crawler uses this account to crawl content that does not have an associated crawl rule that specifies a different account. For the default content access account, we recommend that you specify a domain user account that has read access to the content that you want to crawl. You can change the default content access account at any time.

If you need to crawl certain content using a different account, you can create a crawl rule and specify a different account for crawling. For information about how to create a crawl rule, see Manage crawl rules (SharePoint Server 2010).Use the following procedure to specify the default content access account.

To specify the default content access account

1.     On the Search Administration page, in the System Status section, click the link in the Default content access account row.
2.     In the Default Content Access Account dialog box, in the Account box, type the account that you created for content access in the form domain\user name.
3.     Type the password for this account in the Password and Confirm Password boxes.
4.     Click OK.
6

Specify the contact e-mail address

The contact e-mail address is written to the logs of crawled servers. The default contact e-mail address, someone@example.com, is a placeholder. We recommend that you change this to an account that an external administrator can contact when a crawl might be contributing to a problem such as a decrease in performance on a server that the search system is crawling.
Use the following procedure to specify the contact email address.

To specify the contact e-mail address

1.     On the Search Administration page, in the System Status section, click the link for the Contact e-mail address.
2.     In the Search Email Setting dialog box, in the E-mail Address box, type the e-mail address that you want to appear in the logs of servers that are crawled by the search system.
3.    Click OK.
7

Create content sources

Crawling requires at least one content source. A content source called Local SharePoint sites is created automatically during installation and is automatically configured for crawling all of the SharePoint sites in the server farm. If you perform a Server Farm installation of SharePoint Server 2010, no crawls are automatically scheduled or performed.
1.     Click the Content Sources from quick launch menu
2.     Click Local SharePoint Sites (otherwise you can create New Content Source)
3.     Add the url in “Start Address”
4.     Click “Start all crawls” from the Content Sources page.


1.4    Configure the Search topology


The search topology covers the below:

The Search administration (Admin) topology does not scale out - there can be on one (1) search administration component and one (1) search administration database per Search Service Application.

The Crawl topology can be scaled out by adding Crawl Components or Crawl Databases.  Crawl Components can have a many-to-one relationships with Crawl Databases.

The Query topology can be scaled out by adding Property Databases or by adding Query Components.  Index Partitions subdivide the full-text index.   A new Query Component can either be the first component in a new partition or an additional component in an existing partition.

The next step is to move the query components to the servers on the Web tier, the crawl and property store (query) databases are provisioned on the SQL server instance that was specified for the SharePoint Server farm. If you have more than one application server in your farm, you can deploy these components on other application servers, depending on your requirements. You can deploy multiple instances of each crawl component and each query component.

#
Description
1

To move the query component to a Web server (with query component in 2 WFEs)

1.     On the Central Administration Home page, click Manage service applications.
2.     On the Services Applications page, click Search Service Application.
3.     On the Search Administration page, in the Search Application Topology section, click Modify.
4.     On the Topology for Search Service Application: Search Service Application page, in the Index Partition section, click Query component 0, and then click Edit Properties.
5.     On the Edit Query Component page, select one of the front-end Web servers from the Server drop-down list, and then click OK.
6.     On the Topology for Search Service Application: Search Service Application page, in the Index Partition section, click Query component 0, and then click Add mirror (for fail over).
7.     On the Add mirror query component page, in the Server drop-down list, select the front-end Web server that you identified on the Edit Query Component page, and then click OK.
2

To move the crawl component to a Web server

1.     On the Central Administration Home page, click Manage service applications.
2.     On the Services Applications page, click Search Service Application.
3.     On the Search Administration page, in the Search Application Topology section, click Modify.
4.     You can edit or create a new crawl component and select the App Server.
5.     Finally click Apply Topology Changes
3
Finally the Topology would look like below:

clip_image008

Wednesday, 1 April 2015

list of the service applications in SharePoint 2010 and 2013


Below you can find the list of services which require database and which are cross-farm compatible and make your life easy.
SharePoint Foundation Service Applications
fsp
SharePoint Server 2010 Standard Service Applications
ssp
SharePoint Server 2010 Enterprise Service Applications

ESP 

Sharepoint 2013 service Application features:

add 2 new features;


Application Management Service   (new) Is responsible for storing and providing   information concerning SP App licenses and permissions
SharePoint Translation Services   (new) Provides built-in machine   translation capabilities on the SharePoint platform



Access Services 2010 Let’s users view, edit, and   interact with Access 2010 databases in a Web browser.
Access Services Let’s users view, edit, and interact with Access 2013 databases in a Web browser.
Business Data Connectivity service Gives access to line-of-business   data systems.
Excel Services Application Let’s users view and interact   withExcel 2010 files in a Web browser.
Managed Metadata service Manages taxonomy hierarchies,   keywords and social tagging infrastructure, and publish content types across   site collections.
PerformancePoint Service Application Provides the capabilities of   PerformancePoint.
Search service Crawls content, produces index   partitions, and serves search queries.
Secure Store Service Provides single sign-on   authentication to access multiple applications or services.
State service Provides temporary storage of user   session data for SharePoint Server components.
Usage and Health Data Collection   service Collects farm wide usage and   health data, and provides the ability to view various usage and health   reports.
User Profile service Adds support for My Sites, profile   pages, social tagging and other social computing features.
Visio Graphics Service Lets users view and refresh   published Visio 2010 diagrams in a Web browser.
Word Automation Services Performs automated bulk document   conversions.
Microsoft SharePoint Foundation   Subscription Settings Service Provides multi-tenant   functionality for service applications. Tracks subscription IDs and settings   for services that are deployed in partitioned mode. Deployed through Windows   PowerShell only.
(Moved into Search)Web Analytics service Provides Web service interfaces.



Wednesday, 18 March 2015

SharePoint 2010 site accessing error - The server is busy now. Try again later

While accessing ee.ihess.com (SharePoint 2010) site, I got the error saying that “The server is busy now. Try again later” as shown the image below.

We can get this error when on the processes/services taking up the bulk of your server resources you can take different actions to reduce this overload (For example: recycling the timer service more often). We have the option to turn off HTTP throttling for an entire web application in Central Administration.
We can fix this error by using the steps below
  • Navigate to Central Admin > Application Management > Manage Web Applications. 
  • Select the problematic Web App > Select the down arrow next to General Settings and click Resource Throttling.

  • On the bottom of the window there will be an option to turn HTTP Request monitoring and Throttling Off. Click OK to save changes.

Monday, 6 January 2014

Top five differences between SharePoint 2007 and SharePoint 2010

SharePoint has been around since 2001 and is one of the top collaboration resources.  However, it wasn't until the SharePoint 2007 (known as Microsoft Office SharePoint Server 2007 or MOSS 2007) release that businesses really started to harness the power of collaboration. The latest 2010 version goes even further and offers sought after services straight out of the box.

So what is actually the difference between SharePoint 2007 and 2010? Well what a difference three years makes. This post looks at the key differences between SharePoint 2007 and the latest 2010 release and why SharePoint 2010 is what SharePoint 2007 should have been but wasn't.

1.    Improving social networking capability

A lot has changed in the World since 2007 and one of the biggest is the online explosion of social networking websites.
SharePoint 2010 has dramatically improved its capability in this arena with the addition of personal blogs, tagging and activity feeds within its social networking sites - MySites. MySites allow integration with Microsoft's BCS (Business Connectivity Services), which allows IT to link employees' MySites profiles to non-SharePoint data, such as information from a human resources system.
Wiki and blog integration in MOSS 2007 wasn't great and was widely panned by experts for not being very user friendly. Usability has been a key focus for SharePoint 2010 and it has been dramatically improved.
Similarly, community interaction within SharePoint 2007 was pretty poor and has been given a helping hand with user interfaces similar to Facebook profile pages. SharePoint 2010 has also added keyword tagging so that content can be found quicker.
SharePoint 2010 is even following in Twitters footsteps by adding micro blogging and activity feeds into the service.

2.     Improved search and content management

The search function in SharePoint 2010 is far more superior to previous versions because of improved scalability, query functionality and index redundancy.
As for managing business content, Microsoft has removed limitations in MOSS 2007's Enterprise Content Management (ECM) feature so document libraries can grow to 200 million items.

3.    Working offline  

SharePoint 2010 makes up some ground on the likes of Lotus Notes with SharePoint Workspace.  Workspace makes SharePoint libraries, lists and forms accessible offline. This is a huge step forward and helps to improve the productivity and efficiency of the users.

4.    Better connection to line-of-business data

Previous versions of SharePoint have had difficulties when trying the access enterprise software systems.  Microsoft has made significant improvements to integrate more business data in SharePoint 2010 by using its BCS (Business Connectivity Services) suite.
A recent Forrester report cited that the BCS helps make SharePoint 2010 the "connective tissue that bridges line-of-business systems and knowledge worker systems". The previous iteration of BCS, called BDC (Business Data Catalog), could bring only line-of-business data into SharePoint. BCS will provide both read and write access between business applications and SharePoint 2010.

5.    Developing SharePoint Apps  

Improvements to the design tool SharePoint Designer means that developer will need to deal less with coding. Tighter integration between Visual Studio and SharePoint, and built-in support for Silverlight is a great improvement on its predecessor MOSS 2007.

Wednesday, 4 December 2013

when & why to use delegates?



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DelegateApp
{
    /// <summary>
    /// A class to define a person
    /// </summary>
    public class Person
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public string Address { get; set; }
    }

    class Program
    {
        //Our delegate
        public delegate bool FilterDelegate(Person p);

        static void Main(string[] args)
        {

            //Create 4 Person objects
            Person p1 = new Person() { Name = "John", Age = 41 ,Address ="Hyd"};
            Person p2 = new Person() { Name = "Jane", Age = 69 ,Address = "Blr"};
            Person p3 = new Person() { Name = "Jake", Age = 12 , Address ="NLR" };
            Person p4 = new Person() { Name = "Jessie", Age = 25,Address ="Chennai" };

            //Create a list of Person objects and fill it
            List<Person> people = new List<Person>() { p1, p2, p3, p4 };
            DisplayPeople("Children:", people, IsChild);
            DisplayPeople("Adults:", people, IsAdult);
            DisplayPeople("Seniors:", people, IsSenior);
            DisplayPeople("Middle Age:", people, MiddleAge);

            List<Person> test = new List<Person>() { p1 };
            TestDisplay("testing data", test);
            Console.Read();
        }

        /// <summary>
        /// A method to filter out the people you need
        /// </summary>
        /// <param name="people">A list of people</param>
        /// <param name="filter">A filter</param>
        /// <returns>A filtered list</returns>
        ///
        static void TestDisplay(string title1, List<Person> test)
        {
            Console.WriteLine(title1);
            foreach (Person t in test)
            {
                Console.WriteLine(" {0} ,{1} years of testing data", t.Name, t.Age);
            }
        }
       
        static void DisplayPeople(string title, List<Person> people, FilterDelegate filter)
        {
            Console.WriteLine(title);

            foreach (Person p in people)
            {
                if (filter(p))
                {
                    Console.WriteLine("{0}, {1} years old", p.Name, p.Age ,p.Address );
                }
            }

            Console.Write("\n\n");
        }

        //==========FILTERS===================
        static bool IsChild(Person p)
        {
            return p.Age <= 18;
        }

        static bool IsAdult(Person p)
        {
            return p.Age >= 18;
        }

        static bool IsSenior(Person p)
        {
            return p.Age >= 65;
        }
        static bool MiddleAge(Person p)
        {
            return p.Age >= 18 && p.Age <= 40;
        }
    }
}
















.
.
.
.
.
.

Delegates Overview
Delegates have the following properties:
  • Delegates are similar to C++ function pointers, but are type safe.
  • Delegates allow methods to be passed as parameters.
  • Delegates can be used to define callback methods.
  • Delegates can be chained together; for example, multiple methods can be
    called on a single event.
  • Methods don't need to match the delegate signature exactly. For more
    information, see Covariance and
    Contra variance
  • C# version 2.0 introduces the concept of Anonymous Methods, which permit code blocks to be passed as parameters in place of a separately
    defined method.

Friday, 15 November 2013

Design Pattern Examples in C#






Introduction

Design patterns are some common ideas in writing programs. The whole list and their definitions can be found here. The link has very good descriptions and examples, so I won't repeat the definitions here. I think that the design patterns are not easy to understand, and there are too many examples to remember. In order to apply the design patterns to solve a problem, you would need to understand and remember the patterns so that you could see them in the problem. I couldn't remember even half of the names; I couldn't accurately recite a single pattern definition; and I am not sure whether I fully understand the definitions of the design patterns. However, I have been helped by a simple example which makes the patterns easy to understand and remember. I would like to share it and hope that it can help other people, too.

Background

I took the training from NetObjectives several years ago. I don't remember much of the definitions or principles from the training, but their example sticks in my mind. It is a simple problem but it holds several patterns in the problem.
The example is this: We need to design classes for two Shapes: Rectangle and Circle. We need to draw them on different devices: Console and Printer. The shapes can be moved and expanded. In the future, we might need to support other forms of transformation, such as rotate and distort. After transforming the shapes, we need to be able to undo it. We need to support more complex shapes which are comprised of simpler shapes.

Patterns in this Example

We first abstract the Rectangle and Circle as Shape. If the Shapes know how to draw on Printer and Console, then we would need different versions of Shapes. So, it is better to separate the Shape from the Drawing devices.We also abstract the Console and Printer as Drawing devices. This is actually using Bridge pattern because that it decouples the implementation of Shape and Drawing. In the following snippet, the IShape holds a reference to IDrawing object. Shape has two implementations: Circle and Rectangle. Drawing has two implementations: V1 and V2.
/*
IShape------------->IDrawing
 /    \              / \
Circle Rectangle    V1 V2
*/
abstract class IShape
{
 protected IDrawing drawing;
 abstract public void Draw();
}
abstract class IDrawing
{
    abstract public void DrawLine();
 abstract public void DrawCircle();
}
class Circle:IShape
{
 override public void Draw(){drawing.DrawCircle();}
}
class Rectangle:IShape
{
 override public void Draw(){drawing.DrawLine(); drawing.DrawLine();}
}
class V1Drawing:IDrawing
{
 override public void DrawLine(){}
 override public void DrawCircle(){}
}
class V2Drawing:IDrawing
{
 override public void DrawLine(){}
 override public void DrawCircle(){}
}
Suppose that there are fixed number of Shapes, but there will be new types of Transformations. In order to support new types of Transformations, we can use the Visitor pattern to make Shapes class future proof. In the following snippet, the Shape class defines operation interface Accept(ITransform), so that new transform types can operated on shapes without modifying Shape classes.
/*
   IShape---------->ITransform
 /    \            / \
Circle Rectangle Move Expand
*/
    abstract class IShape
    {
        abstract public void Accept(ITransform transform);
    }
    abstract class ITransform
    {
        abstract public void TransformCircle(Circle c);
        abstract public void TransformRectangle(Rectangle rect);
    }
    class Circle : IShape
    {
        override public void Accept(ITransform transform)
        {
            transform.TransformCircle(this);
        }
    }
    class Rectangle : IShape
    {
        override public void Accept(ITransform transform)
        {
            transform.TransformRectangle(this);
        }
    }
    class Move : ITransform
    {
        override public void TransformCircle(Circle c) { }
        override public void TransformRectangle(Rectangle rect) { }
    }
    class Expand : ITransform
    {
        override public void TransformCircle(Circle c) { }
        override public void TransformRectangle(Rectangle rect) { }
    }
If we want to undo the transform, we can use Memento pattern, where we can store the state of the Shape object without exposing its internal state.
//Memento--->IShape

interface IMemento
{
 void ResetState();
}
class IShape
{
 public abstract IMemento GetMemento();
}
If we have a shape which is comprised of collections of other shapes, we can use Composite pattern so that we may handle the complex shape the same way.
/*        IShape
         / | \
    Circle | Rectangle
           |
    CompositeShape 1--->* IShape

*/

class CompositeShape : IShape
{
 List<IShape> list = new List<IShape>();
}
If you call MembewiseClone() on an object, you only get a shallow copy of the object. The book “C# 3.0 Design Patterns” has a solution for DeepCopy. It serializes the object into a MemoryStream, and then Deserializes it back to a cloned object.
[Serializable]
class IShape
{
public IShape DeepCopy()
{
 using (MemoryStream m = new MemoryStream())
 {
    BinaryFormatter f = new BinaryFormatter();
    f.Serialize(m, this);
    m.Seek(0, SeekOrigin.Begin);
    IShape ret = (IShape)f.Deserialize(m);
    ret.Drawing = drawing;
    return ret;
 }
}
}

Design Pattern Examples in C# and .NET Libraries

There are many examples in C# and .NET libraries. For example:

Adapter Pattern

Streams are tools to read/write a sequence of bytes. If you need to read/write strings or characters, you would need to create a Reader/Writer class. Fortunately, all the Reader/Writer classes can be constructed from a stream object. So, I think that the Reader/Writer classes are adapters which convert a byte array interface to string/char interface.
Reader/Writer-->Stream
BinaryReader/Writer{ReadChars,ReadString}
TextReader/Writer{ReadLine,ReadBlock}
|-StreamReader/Writer
|-StringReader/Writer
Stream{Read(byte[]), Write(byte[], Seek, Position)
|
|-NetworkStream(socket){DataAvailable}
|-FileStream(path){ Lock/Unlock/GetACL,IsAsync}
|-MemoryStream (byte[]){GetBuffer(), WriteTo(stream),ToArray()}
I think "boxing" is also an adapter. It converts a value type into a reference type.

Decorator Pattern

When you need encryption or compression, or need to add a buffer on the network stream, you can use Decorator pattern. The bufferedStream, CryptoStream, and DeflateStream are decorators to other streams. They attach additional functionalities to existing streams without changing the interface of the original streams.
Stream
|
|- BufferedStream(stream,buffersize), for network
|- CryptoStream: for encryption
|- DeflateStream: for compression

Flyweight Pattern

To save space, String class holds a reference to an Intern object. So, if two strings have the same literal, they share the same storage space. It uses "sharing" to support a large number of fine grained objects efficiently so that it is using Flyweight pattern.
String s3 = String.Intern(s2); 

Object Pool Pattern

Creating threads are expensive. You can call Threadpool.QueueUserWorkitem() which uses thread pool to better use the system resources. So, I think that threadpool is a good example of object pool pattern.

Observer Pattern

Observer pattern defines a one to many dependency so that when one object changes state, all its dependencies are notified. The event in C# is exactly for this purpose. An event can be subscribed:
UnhandledExceptionEventHandler handler =
 (object sender, UnhandledExceptionEventArgs v) => {
Console.WriteLine(
  "sender={0}, arg={1}, exception={2}, v.IsTerminating={3}",
  sender, v, v.ExceptionObject, v.IsTerminating);
  };
AppDomain.CurrentDomain.UnhandledException += handler;
throw new Exception("hiii");
To unsubscribe, you just need to call event-=.
AppDomain.CurrentDomain.UnhandledException -= handler;
You can also define your own events:
static public event EventHandler<EventArgs> breakingNews;
if(breakingNews!=null)
breakingNews("NBC", EventArgs.Empty);
If you don't want to check whether the event is null, just add a dummy subscriber:
breakingNews += delegate { }; 

Iterator Pattern

Iterator provides a way to access the elements inside an aggregate object. C# has foreach keyword which makes Iterator really easy. It is hard for me to understand what Enumerable and Enumerator are. It is even more confusing why I have to define GetEnumerator for both IEnumerable and IEnumerable<T>. So, I just try to remember this example:
class IntEnumerable:IEnumerable<int>
{
public IEnumerator<int> GetEnumerator()
{
    yield return 1;
    yield return 2;
}
IEnumerator IEnumerable.GetEnumerator()
{
    return this.GetEnumerator();
}
}
//Then you use the iterator like this:
foreach(int i in new IntEnumerable())Console.WriteLine(i);

Singleton Pattern

The simplest way to create a singleton is to use a static variable in C#.
class Singleton
{
    private static Singleton instance = new Singleton();
    public static Singleton GetInstance()
    {
        return instance;
    }
}
Some people use the double-checked-lock to create a thread safe lazy initialization singleton. However, it is so subtle to implement that some people consider it as Anti-pattern: [Read this].
Netobjectives has this method which I think is the best way to create a thread safe lazy init singleton. Note that the static constructor disables BeforeFieldInit flag (see this link). The inner class Nested avoids early init when other static fields or methods of Singleton are called.
class Singleton
{
    private Singleton() { }
    public static Singleton GetInstance()
    {
        return Nested.instance;
    }
    private class Nested
    {
        internal static Singleton instance = new Singleton();
        //static constructor to prevent beforefieldInit
        // see http://www.yoda.arachsys.com/csharp/beforefieldinit.html
        static Nested() {}
    }
} 

Using the Code

The sample code is written in C# 3.0.

Conclusion

I am sure I missed many patterns and might have misunderstood some in the above examples. If so, please let me know so that they can be corrected.
I have benefited from the examples I got from the training in NetObjectives. I felt that the training is an eye opener and I really learnt a lot. After a couple years, the only thing I still remember is their example about Shape, Drawing, and Transform. If you are not familiar with design patterns, I hope that this example gets you interested in reading Wikipedia or a book, or taking the training from NetObjectives. If you have taken their training or are familiar with design patterns, then the examples might help you quickly refresh your memory of design patterns.
One thing I learned is that if my code has a lot of copy/paste, or has a lot of switch/case statements, then I might need to think about using some design patterns.
I think the idea of design pattern is similar to Database normalization. During database normalization, we break one big table into several smaller tables, so that the total number of rows in tables is much smaller, and modification in one small table won't affect other tables. If we can separate/isolate the concepts in our problem, then we are likely applying the ideas of design pattern already, even if we don't remember the pattern names.