Microsoft SharePoint and .NET Technology Insight

SharePoint, .NET, Office365, Windows Azure, TFS, Project Server and SQL Server Technology Insights

Leave a comment

SharePoint Guidance Library

The SharePoint Guidance Library is a set of reusable components and utility classes,
developed by the patterns & practices team at Microsoft, which can help you to build
more robust applications for SharePoint 2010. You can download the SharePoint
Guidance Library as source code, build the assembly, and use the components in your own

The SharePoint Guidance Library includes the following components:

  • The SharePoint Logger, which can help you to log exceptions and trace information in a consistent, informative way, by providing easy-to-use utility methods that write to the Microsoft Windows® Event log and the ULS (SharePoint Unified Logging Service) trace log.
  • The Application Setting Manager, which can help you to manage configuration settings, by providing a robust, consistent mechanism that you can use to store and retrieve configuration settings at each level of the SharePoint hierarchy.
  • The SharePoint Service Locator, which can help you develop testable, modular code, by enabling you to decouple your code from dependencies on external types.

Additional Information:


Leave a comment

Working with custom user profile properties programmatically

This one is just to share how can we get the values of custom properties in user profiles in SharePoint 2010. actually this was the outcome of a quick POC while answering on MSDN SharePoint forums. so thought to share as this may help someone.

I have created a custom user profile property of type string and internal name is set to PrefferedColor while display name is – Preffered Color.

Then a simple web part which reads this custom user profile property.

All you need to do is Include references of following assemblies


public class ShowPropertyWp : WebPart
  private string m_propertyInternalName = “PrefferedColor”;
  private string m_propertyDisplayName = “Preffered Color”;
  private string color;
  protected override void CreateChildControls()
      Guid siteId = SPContext.Current.Site.ID;
      Guid webId = SPContext.Current.Web.ID;
      using (SPSite site = new SPSite(siteId))
        SPServiceContext serviceContext = SPServiceContext.GetContext(site);
        UserProfileManager upm = new UserProfileManager(serviceContext);
        if (upm != null)
             UserProfile up = upm.GetUserProfile(“domain\\user”);
             if (up != null)
                color = up[m_propertyInternalName].Value.ToString();
                color = up[m_propertyDisplayName].Value.ToString(); // This will give an error.
      if (!string.IsNullOrEmpty(color))
         this.Controls.Add(new LiteralControl(“You Have Preffered Color – ” + color));
         this.Controls.Add(new LiteralControl(“You have not selected any preffered color”));
  catch (Exception ex)
     this.Controls.Add(new LiteralControl(“Error: ” + ex.Message));

Leave a comment

Adding Diagnostic information for WCF Services

Here is diagnostic information in the web.config for Web Hosted WCF services:

<!– child of the <configuration> element –>



<source name=”System.ServiceModel”



<add name=”xmlTraceListener” />



<source name=”System.ServiceModel.MessageLogging”



<add name=”xmlTraceListener” />





<add name=”xmlTraceListener”


initializeData=”ClientLogBasic.svclog” />


<trace autoflush=”true” />


<!– child of the <system.serviceModel> element –>


<messageLogging maxMessagesToLog=”10000″










Leave a comment

SharePoint 2010 Installation related

The very first step is to check the minimal requirements for hardware (Windows server 64 bit) and MS-SQL 2005 SP3 or 2008 R2, but even before that, ensure you have your Active Directory installed and properly configured (all the users needed for the installation, domain, permissions) after having the previous points covered, you must run the prerequisites from SP 2010 after that you can install the desired and required copy of MS SharePoint 2010

Here are list of useful resources for SharePoint 2010 Installation:

  1. The Technet resource provides details required to SharePoint 2010 Software and Hardware installation pre-requisites. The site also includes additional information on SharePoint 2010 Farm Architecture and Capacity planning.
  2.  This site also has a lot of other installation and configuration samples related to SharePoint 2010 (search, ups and etc.)
  3. AutoSPInstaller (from requires more expertise and could be little bit complex for you if you are new to SharePoint. You can find information about AutoSPInstaller from the following URLs:

1 Comment

SharePoint Content Type Hub

SharePoint 2010: Sharing Content Types Across Site Collections

One of the challenges with SharePoint 2007 was working with enterprise wide content types. Fortunately, SharePoint 2010 that supports an enterprise approach to managing and working with Content Types.

Say for example you have a Site Collection Web Application 1 and you have created a series of content types to use. Now, you create Web Application 2 and find the necessity to reuse the content types created in Web Application 1. There is no way you could share or reference those content types created in Web Application 1 in Web Application 2. The only way possible is to create or write an application which would install those content types. This situation is pretty common in large organizations. This can be even considered for exposing base content types you use across multiple web applications in the farm.

The fundamental challenge faced by organizations with respect to specifying content types and metadata in pre-SharePoint 2010 versions has been the inability to easily repurpose or reuse them across site collections.

Because site collections have represented fairly strict boundaries, most organizations have been forced to design and build custom solutions to get around this problem. Synchronization of content types and metadata across site collections required them to be copied or updated to each site collection, either manually by an administrator or programmatically through workarounds to the system itself.

SharePoint 2010 Content Type Hub

Fortunately, SharePoint 2010 has addressed this issue through the implementation of Content Type Hubs. With the Content Type Hub, a specific site collection is selected to act as the central repository for content types intended for use enterprise-wide. Content types that are made part of the hub can then be syndicated, or published out, for consumption across other site collections.

This allows you to centrally manage all your content types and send updates to these content types from a single location. While third-party products have offered similar functionality for SharePoint 2007, it is nice to see Microsoft including this as part of the product.

The SharePoint 2010 content type hub does quite a good job of managing and publishing a centrally controlled set of content types. There are a few quirks and limitations, some of them documented in Content Type Hub FAQ and Limitations by Chaks’ SharePoint Corner; not to forget the content type publishing timer jobs that actually push the content types to the subscribers.