Skip to content

Category: Uncategorized

The Adventure called TechEd Europe 2012

What an adventurous week it was. Full of networking, learning, great people and some awesome parties. As I mentioned in my previous post, I was one of the delegate to Microsoft TechEd Europe 2012 at Amsterdam RAI.


It started with a fabulous keynote by Brad Anderson and Jason Zander on Azure, Widows 8, its capabilities and future. Well, did I forget to mention the guest appearance of Scott Gu?

Four days and close to 20 sessions, I can just say that I would need loads of time to just recap what I heard in TechEd 2012.

Here is my list of topics of my interest and to be followed in near future:

  • Windows Azure
    • I have the MSDN professional subscription, still need to say how much I can avail through it.
  • Visual Studio / Team Foundation Server 2012 : I am a big fan of Agile methodology and Microsoft Team has done quite some work to bring the great experience for developers. Especially looking for:
    • Planning and Capacity
    • Storyboarding
    • Intellitrace
  • Unit Testing enhancements: Fakes, Shims
  • Windows 8 : Metro Style Apps

This was just about the learning stuff, but there was this awesome party organized by Microsoft for close to 5000 delegates and staff at Amsterdam Arena Stadium. They streamed the live semi final match between Spain and Portugal. Everyone know what happened later .

The only thing which kind of sucked at the event was NO INTERNET on day 2. They had some technical failure because of which there was no internet available for almost the day.


Why you should use Visual Studio for SharePoint Development

Microsoft has significantly improved the tools available to developers and implementers for SharePoint 2010. The two primary tools, SharePoint Designer 2010 and Visual Studio 2010, have evolved into first class power user, site owner, and developer tools that target different audiences.

Microsoft SharePoint Designer is a specialized HTML editor and web design freeware for creating or modifying Microsoft SharePoint sites and web pages. It is a part of Microsoft SharePoint family of products.
SharePoint Designer features focuses on designing and customizing Microsoft SharePoint websites. For instance, it includes SharePoint-specific site templates.

Visual Studio 2010 is the primary development environment for all custom code and resource development for SharePoint 2010. Developers can also use a new project template that can rebuild a solution by importing an existing solution package (.wsp) file. Visual Studio 2010 provides a new extensibility model named the Managed Extensibility Framework (MEF), and a SharePoint 2010 project system API. Using this framework and API, developers can extend and customize Visual Studio 2010.

Benefits of using Visual Studio

  1. Workflows created in Share point Designer can be exported and imported to visual studio but the other way around is not possible.
  2. When developing solutions for SharePoint using Visual Studio, there is nothing special if you are targeting SharePoint. All of your sources files are handled as they normally are when you are using a version control system.
  3. You can use Visual Studio to group related SharePoint elements into a Feature. Next, you can create a SharePoint solution package (.wsp) to bundle multiple features, site definitions, assemblies, and other files into a single package, which stores the files in a format needed by SharePoint to deploy the files to the server.


Going to TechEd 2012

Hi All,
I am happy to announce that I will be participating as a delegate in Microsoft TechEd 2012 in Amsterdam. Frankly, quite exicted about it. This will be my second TechEd after TechEd 2010 in Berlin.
See you all guys at Amsterdam. Below is the link for more about Tech Ed 2012.


Orchard : Show complete post in blog list

By default, most of the Orchard themes (including the default Theme Machine) shows first couple of sentences with a link ‘more’ to read the entire content. In the latest version of Orchard, the limit is 200 characters and after that a ‘more…’ link  is appended. Look at the example below:


I wanted to override this setting and show the complete post in the list. Currently, I show five latest posts on my homepage. I did the following:

  1.  Add a file with name ‘Parts.Common.Body.Summary.cshtml’ to your themes directory.
    Note : Though this feature can be centrally changed as well, but that would mean all the themes/blogs have the same setting. I would recommend to do it per theme basis.
  2.  With in this file, add the following line:

And that’s it. Your blog list will show complete content of your posts instead of trimming them down to certain characters.

SharePoint 2010 : Sandbox Development in nutshell

Sandbox Development

With SharePoint, the challenge has always been the balance between creating solutions and deploying them in a way that you can trust will not damage or impair the SharePoint farm.

A new feature in SharePoint 2010, called sandboxed solutions, addresses many of these concerns, enabling farm administrators to feel comfortable that the SharePoint farm is safe, giving site collection administrators the authority to manage the applications in their site collection, and providing developers with the flexibility to create solutions they know will be deployed in a safe and rapid manner.

Because sandboxed solutions cannot affect the whole server farm, they do not have to be deployed by a farm administrator. Sandboxed solutions can be deployed by a site collection administrator or, in certain situations, by a user who has the Full Control permission level at the root of the site collection.

Benefits of sandboxed solutions

The main benefits of using sandboxed solutions are as follows:

1.Sandboxed solutions can be added to a production SharePoint Server environment without the risk of affecting processes outside the sandbox.

2.Scalability and flexibility are increased because sandboxes run in a separate process that can be restricted by quotas, and their effect on the farm can be monitored.

3.A solution does not have to be modified or recompiled if it is moved from a sandbox to running directly on the farm.

Restrictions (and workarounds) on Sandboxed Solutions 

The following list identifies the most common things that an assembly that will run in a sandbox cannot do:

Connect to resources that are not located on the local farm.

Access a database.

Sometimes, you may want to view and edit data from one of your core business systems. To access that data, you can use a “Hybrid Approach”. One such approach involves creating an external content type for the line of business data, then using the SPList API in the sandbox to work with that data. This is less of a workaround and more of a structured approach to working with external data in a sandboxed solution.

Change the threading model.

Call unmanaged code.

Write to disk.

You can write to SharePoint lists in a sandboxed solution. You can use a full-trust proxy with the SharePoint Logger to write to the Windows Event Log and SharePoint Unified Logging Service (ULS) logs.

Access resources in a different site collection.

Developing Visual Web Parts.

Visual Studio 2010, out of the box, does not allow you to use the visual editor to create Web Parts for a sandboxed solution. Microsoft has provided a Visual Studio 2010 Power Tool for SharePoint 2010 developers. In addition to allowing for visual editing of sandboxed Web Parts, this Power Tool provides some helpful compiler tips.

Writing Fully Coded Workflows.

You should consider using declarative workflows in a sandbox and deploying coded workflows as a farm solution when environment allows for it.

Validating Solutions in the Sandbox

The SharePoint sandbox framework provides an additional way for farm administrators to monitor and validate solutions that run in the sandbox. Farm administrators can deploy solution validators that run when a solution is uploaded to a Solution Gallery. Administrators can create validators that allow only code signed with a particular certificate to run, for example, or they can create a validator to allow only Web Parts. Another good use for validators is to log and catalog solutions in the farm as they are activated. You can see how this simple but powerful tool helps farm administrators get a handle on the solutions running in the farm.

Each solution validator is called when a solution is activated. If the validator is updated, solutions are validated again the next time they are executed.


Problem with Wireless Adapter or Access Point

After moving to a new Network Provider and of course to new Modem/Wireless Adapter (HUAWEI-HG655d), I could connect all my devices except my Windows 7 laptop.
I repeatedly received error stating that connection was not successful. After some more steps with Windows Help and Diagnostics, Windows finally said:
‘Problem with Wireless Adapter or Access Point’
Now, I was like WOW. What an explanation :). Did some googling but wasn’t getting anyway near to it. So decided to call the help desk from Though, I am usually not very optimistic of getting any help from help desks; this guy was just on spot. He asked to change the following settings and it now works like Charm 🙂
Mode: 802.11b/g/n -> 802.11b/g
WPA encryption:   AES -> TKIP/AES

An introduction to SharePoint 2010 workflows


SharePoint 2010 introduces many new capabilities that are categorized into six different workloads, one of which is the composites workload. A key component of creating composite applications is SharePoint 2010’s ability to create custom workflows, allowing end users to attach behaviour to data.

Workflows in SharePoint Server 2010 enable enterprises to reduce the amount of unnecessary interactions between people as they perform business processes. For example, to reach a decision, groups typically follow a series of steps. The steps can be a formal, standard operating procedure, or an informal implicitly understood way to operate. Collectively, the steps represent a business process. The number of human interactions that occur in business processes can inhibit speed and the quality of decisions.

Workflow in SharePoint 2010

SharePoint Foundation 2010 workflows are made available to end-users at the list or document-library level. Workflows can be added to documents or list items. Workflow can also be added to content types. Multiple workflows may be available for a given item. Multiple workflows can run simultaneously on the same item, but only one instance of a specific workflow can run on a specific item at any given time. For example, you might have two workflows, called SpecReview and LegalReview, available for a specific content type, Specification. Although both workflows can run simultaneously on a specific item of the Specification content type, you cannot have two instances of the LegalReview workflow running on the same item at the same time.

The figure below illustrates the conceptual workflow architecture in SharePoint Foundation. Each content type, list, and document library in the farm is linked to the workflows added to it through the workflow association table. Each workflow has a workflow definition. This XML definition specifies the identity of the actual workflow assembly, and class within that assembly, as well as the location of any workflow forms the workflow needs to run.


Share point workflow Life Cycle

Fig. below illustrates the four stages of the SharePoint workflow life cycle. These stages allow for the assignment of workflows to content type, handle the different ways for starting workflows, and keep the workflow infrastructure flexible during execution. This custom life cycle is provided by the SharePoint-specific workflow hosting environment. During some of the following stages, forms can be used to gather additional user input as parameters, which are required for this stage to execute.


Workflow Solution Spectrum



 ‘Out of the box’ Workflows

SharePoint 2010 Standard and Enterprise include a selection of ‘out of the box’ workflows.  These tools help you automate the most common business tasks – sharing and collecting feedback on documents.

Workflow Types

Windows Workflow Foundation supports two fundamental workflow styles. You can create workflows of either type for Microsoft SharePoint Foundation 2010.

Sequential Workflows

A sequential workflow represents a workflow as a procession of steps that execute in order until the last activity completes. However, sequential workflows are not purely sequential in their execution. Because they can receive external events, and include parallel logic flows, the exact order of activity execution can vary somewhat.


State machine workflow

A state machine workflow represents a set of states, transitions, and actions. One state is denoted as the start state, and then, based on an event, a transition can be made to another state. The state machine can have a final state that determines the end of the workflow.

In the state machine style of workflow authoring, the author models the workflow as a state machine. The workflow itself consists of a set of states. One state is denoted as a start state. Each state can receive a certain set of events. Based on an event, a transition can be made to another state. The state machine workflow can have a final state. When a transition is made to the final state, the workflow is completed.

The following flowchart is an example of a state machine workflow.



Workflows Development Tools

Workflows for SharePoint can be designed in Visio and/or developed using Share point designer or visual studio.

Schematic diagram of the tools available for developing SharePoint workflows is as follows:


Designing workflows

It is also possible to design the share point workflows using Microsoft Visio and export it to share point designer for further development.

Points to consider:

  1. Only design of the workflow is possible (the business logic conditions need to be filled in later after importing to share point designer)
  2. Microsoft Visio Premium or higher is required to design the share point workflows

Developing SharePoint workflows

Share point workflows can be developed in SharePoint designer or visual studio.

Points to consider:

  1. Workflows created in Share point Designer can be exported and imported to visual studio but the other way around is not possible
  2. If input is needed for workflows, the forms for input can be done either using InfoPath or custom page.
  3. Custom workflow activities can be developed in visual studio and can be used in share point designer along with the other built-in activities to create workflows.


Share point designer activities reference:

Custom activities:


Workflows authored with SharePoint Designer 2010 can run in a protected environment called the sandbox where they cannot put the farm in danger; workflows generated with Visual Studio must run in the farm mode, but not in a sandbox environment.



Workflow versioning is a very important technique. When a workflow goes idle, the state of the workflow is and saved (hydrated) into the database. This saving of a workflow’s state is called hydration. When the workflow resumes, the state is dehydrated out of the database and the workflow starts processing again. Versioning is important because if you change the assembly while the workflow is hydrated (saved in the database), there’s no guarantee that when the workflow dehydrated it will match the construct of the new assembly. If it doesn’t match the construct upon de-serialization, the workflow will break. Changes like adding or removing activities and changing property values may necessitate a new workflow version. The best practice is to create a new version every time rather than just push the assembly and cross your fingers.


Delete Similar Databases


I had these similar databases on my dev environment which I had to delete multiple times during development. As this process was becoming more and more mechanical, I wanted to have a script which would do this for me.

Using the code

Below is the script which looks for the database(s) with name pattern and deletes them. I use the @DatabaseSearch variable to look for the databases with similar names.


[codesyntax lang=”sql”]


DECLARE @DatabaseSearch nvarchar(48)
DECLARE @Sql nvarchar(max)

SET @DatabaseSearch = 'DeleteDatabasesLikeThis%'

DECLARE @DatabaseName nvarchar(48)

[Name] AS [DatabaseName]
INTO #Databases
FROM sys.databases
[Name] LIKE @DatabaseSearch

DECLARE DBNameCursor CURSOR FOR SELECT DatabaseName FROM #Databases
OPEN DBNameCursor
FETCH NEXT FROM DBNameCursor INTO @DatabaseName
SET @Sql =
@DatabaseName +
'DROP DATABASE [' + @DatabaseName +'];'


FETCH NEXT FROM DBNameCursor INTO @DatabaseName
CLOSE DBNameCursor

DROP TABLE #Databases



Extracting Table Data from Word Document using Aspose Words

For one my projects, I had a requirement where the data from word documents had to be extracted and exported to a database. The biggest challenge was that I had to support the existing word documents. Basically, there were thousands of word documents of same format which had chunks of data. This document format was never designed to be read by another system. This means, no bookmarks, merge fields, styles to identify the actual data from the standard instructions etc.Luckily, for our rescue all the input fields were in the table. But these tables were again of different formats, some with single row/cell and some with varying number.

I use Aspose Words extensively for creating and manipulating word documents. And considering the expertise I had with the component, I decided to go with it. To solve the issue, I created a similar table model in C# so that I can use it later on while reading the documents.

Below, you can see I created a class called WordDocumentTable with three properties i.e. TableID, RowID and ColumnID. As I explained earlier that we had no support for TableID/RowIDs, these properties simply imply the position in the word document. The start index is assumed to be 0.

public class WordDocumentTable
	public WordDocumentTable(int TableID) 
		TableID = TableID; 

	public WordDocumentTable(int TableID, int ColumnID) 
		TableID = TableID;  
		ColumnID = ColumnID; 

	public WordDocumentTable(int TableID, int ColumnID, int RowID) 
		TableID = TableID;  
		ColumnID = ColumnID;  
		RowID = RowID; 

	private int TableID = 0;

	public int TableID 
		get { return TableID; }  
		set { TableID = value; } 

	private int RowID = 0;    
	public int RowID 
		get { return RowID; }  
		set { RowID = value; } 

	private int ColumnID = 0;    
	public int ColumnID 
		get { return ColumnID; }  
		set { ColumnID = value; } 


Now comes the extraction part. Below, you will see the collection of table cells which I want to read from the document.

private List<WordDocumentTable> WordDocumentTables
		List<WordDocumentTable> wordDocTable = new List<WordDocumentTable>();      
		//Reads the data from the first Table of the document.    
		wordDocTable.Add(new WordDocumentTable(0));      
		//Reads the data from the second table and its second column. This table has only one row .    
		wordDocTable.Add(new WordDocumentTable(1, 1));      
		//Reads the data from third table, second row and second cell.    
		wordDocTable.Add(new WordDocumentTable(2, 1, 1));  
		return wordDocTable;  

Below is the method which extract the data from Aspose Word Document based on the Table, Row and Cell.

public void ExtractTableData(byte[] PobjData)
	using (MemoryStream Stream = new MemoryStream(PobjData)) 
		Document AsposeDocument = new Document(Stream);     
		foreach(WordDocumentTable wordDocTable in WordDocumentTables)  
			Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)AsposeDocument.GetChild(NodeType.Table, wordDocTable.TableID, true);   
			string cellData = table.Range.Text;

			if (wordDocTable.ColumnID > 0)   
				if (wordDocTable.RowID == 0)    
					NodeCollection Cells = table.GetChildNodes(NodeType.Cell, true);     
					cellData = Cells[wordDocTable.ColumnID].ToTxt();
					NodeCollection Rows = table.GetChildNodes(NodeType.Row, true);     
					cellData = ((Row)(Rows[wordDocTable.RowID])).Cells[wordDocTable.ColumnID].ToTxt();    

			Console.WriteLine(String.Format("Data in Table {0}, Row {1}, Column {2} : {3}",           

How to get column values as comma separated string in SQL

Ever wondered that how to get a comma (pipe or whatever) separated result for a column in a table in SQL Server?

The following statement show a simple example you can take as a starting point.

Select (Stuff((Select ', ' + FName From Accounts FOR XML PATH('')),1,2,''))

Update: Elina Blank suggested an alternative to the approach above on my CodeProject Tip. Thanks Elina 🙂

Have a look at alternative here at CodeProject.