Tuesday 18 February 2014

Create Group in SharePoint 2010 Programmatically

To Create group in site collection level use the following command:

   string siteUrl = SPContext.Current.Web.Url;
   using (SPSite spsite = new SPSite(siteUrl))
   {
      using (SPWeb web = spsite.OpenWeb())
      {
          web.SiteGroups.Add("GroupName", web.CurrentUser, web.CurrentUser, "GroupDescription");
          web.Update();
      }
   }

To Create group in site level use the following command:

   string siteUrl = SPContext.Current.Web.Url;
   using (SPSite spsite = new SPSite(siteUrl))
   {
      using (SPWeb web = spsite.OpenWeb())
      {
          web.Groups.Add("GroupName", web.CurrentUser, web.CurrentUser, "GroupDescription");
          web.Update();
      }
   }

Thursday 13 February 2014

How to find public key token for a .NET DLL or assembly

Steps :
1. Go to Start and search for "Visual Studio Command Prompt" and open it.
2. Type the DLL file path and type the following command.
     Command: sn -T myDll.dll

Example: E:\ExampleProject\bin\Debug> sn -T ExampleProject.dll

The output will be as follows:

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.
Public key token is 4e4ed2e4e49b94ff


Total Pageviews