Friday, August 10, 2012

Error: The Process Cannot Access the File Because It is Being Used By Another Process

Most of the Asp.Net (VS) developers might have faced and will be facing a problem in building the solution in Visual Studio with an error saying "Unexpected error creating debug information file at XXXXX. The process cannot access the file \bin\Debug\filename.pdb because it is being used by another process."

This means that the respective .pdb or .dll file is being used by some process. And in-order to build the solution the file must be either deleted in file system or the process which is associated must be killed.

The system won't allow to delete the file from file system anyways, the other option is to kill the respective process. But finding the respective process is not straight.

Here we have a nice tool "Process Explorer" to identify the process for which the file is being used using search in the tool and respective process can be killed as well.

Isn't it so useful and nice tool.

Wednesday, May 30, 2012

Migration SharePoint 2007 to SharePoint 2010


As we know SharePoint 2010 has significant user experience, performance, and other improvements, most of the organizations with existing SharePoint 2007 applications are planning to upgrade to SharePoint 2010. New hardware and software requirements, architectural changes, and UI changes in the product will require solid migration and testing plans to ensure these upgrades proceed smoothly.

My goal of this migration article is to illustrate step by step migration from SharePoint 2007 to SharePoint 2010.
Here I am going to describe the migration process steps for the below scenario which exists in SharePoint 2007 environment.

Scenario: Migrating Team Site with below content/functionalities/custom solutions
  • Ø  Regular Team Site
  • Ø  Team Site with sub-sites
  • Ø  Team Site with list template
  • Ø  Team Site with sub sites using Site Template
  • Ø  Team Site with sub sites using Site Template + Custom WP solution
  • Ø  Team Site with sub sites using Site Template + Custom WP solution + Custom Content Types
Before you run any process to upgrade from Microsoft Office SharePoint Server 2007 to Microsoft SharePoint Server 2010, you have to determine which upgrade approach to take from the below two major approaches. The Article Upgrade process overview (SharePoint Server 2010) gives the more information possible approaches for migration.
The article Determine upgrade approach (SharePoint Server 2010) helps in comparing the pros and cons for each approach and to review information about special cases that might influence your approach. In addition to this information, be sure to read Review supported and unsupported upgrade paths (SharePoint Server 2010) to understand exactly which upgrade situations are valid and lead to successful upgrades.

Here in my case I am using the Database Attach Approach. The Source and Destination servers are different. The below describes the Step-by-Step Migration Process.

1.      Check Pre-Requisites for upgrading from SharePoint 2007 to 2010

2.       SharePoint 2007 with SP2 environment
3.       A web application with above scenario in SharePoint 2007 environment
5.       A web application with no site collection in SharePoint 2010 environment

2.      Run the pre-upgrade check

Note: To perform an upgrade, you must have installed Office SharePoint Server 2007 with Service Pack 2 (SP2).

The pre-upgrade checker is a STSADM operation that you run in a Microsoft Office SharePoint Server 2007 environment to find any potential issues for upgrade and to review recommendations and best practices.
STSADM -o preupgradecheck

In my environment, I got the following issues after running the preupgradecheck.

Issue 1: This server machine in the farm does not have a 64 bit version of Windows Server 2008 SP2 or higher installed.
Description: This issue is related to hardware, software, pre-requisites of SharePoint 2010 server.

Issue 2: Orphaned site collections
An orphaned site collection is a site collection exists in the content database, but it is not available in the configuration site map(CA/UI). Such site collections are not accessible and will not be upgraded properly. The following orphaned site collections were found.

/sites/MyTest (Data Source=WS2003\OfficeServers; Initial Catalog=WSS_Content_80; Integrated Security=True; Enlist=False; Connect Timeout=15)

Description: This issue is related to MyTest Site is corrupted in SharePoint 2007 server.

Issue 3: Missing server file or server configuration issues
Description: This issue is related to custom web parts, event handlers, and features etc.

Note: The generated report is available in LOG files.  

3.      Clean up the Environment:

Resolution of Issue 1:
Resolve all the environment issues mentioned in Issue 1.

Resolution of Issue 2:
·         Verify whether the reported orphan site collection exists in the specified web application through CA (UI).

Then verify whether the same orphaned site collection exists in content database using the below STSADM command
STSADM -o enumallwebs -databasename  <<name of the content database>>

It gives the count of the site collections in content database and lists all the site collections and webs inside with IDs. The orphaned site collection should be found here.

·         The orphaned site collection Sites/MyTest is deleted in content database using below STSADM command
STSADM -o deletesite -force -siteid <<site guid>> -databaseserver <<database server>> -databasename <<name of the content database>>

·         RECOMMENDATION: After deleting the orphaned site collection, it is recommended to repair the content database for any schema related issues using below STSADM command.
STSADM -o databaserepair -url <<site collection url>> -databasename  <<name of the content database>>

Note: The siteid is copied from the STSADM command prompt after running enumallwebs command.

Resolution of Issue 3:
This issue is related to custom solution. Lists all the missing web parts, features, content types etc., in content database; Make sure all the custom solutions are deployed to the farm.

Note: Run the preupgradecheck command again after resolving all the listed issues to see if there are any issues still.

4.      Backup Content Database -SharePoint 2007 Environment 

In any type of database attach upgrade, you can set the database to read-only temporarily to ensure that you capture all the data in the backup so that you are restoring and upgrading the current state of the environment. If the database are set to read-only, users can continue to view content, but they will be unable to add or change content.

5.      Restore Content Database - SharePoint 2010 Environment 

After you configure the new server farm (SharePoint 2010), you can restore the backup copies of the database new environment.

You must also set the database back to read-write before you attach and upgrade them.

6.      Verify Custom Components 

Before you attach the content database to the Web application, use the 
Test –SPContentDatabase Windows PowerShell cmdlet to verify that you have all the custom components that you need for that database against the web application.
Test-SPContentDatabase -Name <<restored content database name>> -WebApplication <URL>

7.      Attach a Content Database to a Web application 

You can use either the Mount -SPContentDatabase cmdlet in Windows PowerShell or the addcontentdb Stsadm command to attach a content database to a Web application.

Note: Using the SharePoint Central Administration pages to attach a content database is not supported for upgrading.

PowerShell Cmdlet
Mount-SPContentDatabase -Name <<restored content database name>> -DatabaseServer <<database server>> -WebApplication <<URL>> [-Updateuserexperience]

 STSADM command
STSADM -o addcontentdb -url <<web application url>> -databasename <<content database name>> [-preserveolduserexperience]

Note: Updateuserexperience & preserveolduserexperience are optional and used for visual upgrade respectively, which applies the 2010 look and feel for 2007 pages.
After you have attached a database, you can use the Upgrade Status page in Central Administration to check the status of upgrade on your site collections. After the upgrade process is complete, you can review the upgrade log file to see whether there were any issues during upgrade. Also, you can review each upgraded site to find and address any issues with how the content is displayed. For more information, see Verify upgrade and review upgraded sites (SharePoint Server 2010).

To view the Upgrade Status page:
In Central Administration, click Upgrade and Migration, and then click Check upgrade status.

8.      Visual Upgrade 

Once the content database is restored, attached to a web application and the site is accessed through browser, the site holds the 2007 look and feel if user experience operation is not used in PowerShell/STSADM while attaching content database.
To apply the 2010 look and feel to the restored sites follow the below simple approach.
Logon to SharePoint 2010 team site; click on Site Settings->Visual Upgrade, select the update the user interface radio button, which will update the SharePoint 2010 interface.

9.      Verify Successful Upgrade 

Run the below PowerShell command to check whether the upgrade/migration is successful
Test-SPContentDatabase –Name <name of the content database > -WebApplication <web application url>

It generates a report of missing custom features, web parts and event receivers….etc.

10. Deploy Custom Solution 

1.      Add & deploy the custom solution to SharePoint 2010 restored site using PowerShell or STSADM.
2.      Activate the content type and webpart features in SharePoint 2010 restored site.

11. Again Verify Successful Upgrade 


Run the PowerShell command as follows to check for successful upgrade
Test-SPContentDatabase –Name <database name> -WebApplication <URL>

      This time it should be successful, no warning/errors.

I hope this post is useful in manual migration.

Wednesday, May 9, 2012

SharePoint Registering Event Handlers to Content Type

Recently i have a requirement to registering the event handler to multiple lists having the same content type. Actually the event handler has ItemAdded/ItemUpdated events.

The complexity has been increased when new lists keep-on added at different places/sites. So i keep registering the same event handler with each newly created list which has same content type. I felt this is not a good approach to registering the event handler for each and every list.

When i investigated for the better solution, i found that event handlers can be registered for a specific content type. So as soon as the content type is added to the list, the same event handler is available on the list for a specific content type items. With this no need to register event handler for each list with same content type.

Binding Event Handlers to Content Type can be done by using SharePoint content type feature/elements xml.
Feature - XML
<?xml version="1.0" encoding="utf-8"?>
<Feature Scope="Web" 
  Title="Sample Event Handler Registration" 
  Id="A6B8687A-3200-4b01-AD76-09E8D163FB9A" 
  xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="elements.xml"/>
  </ElementManifests>
</Feature>
ConteType with Event Handler Binding - XML
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ContentType Name="ContentType Name"
   ID="ConteTypeGUID"
   Description="ContentType Description"
   Group="ContentType Group Name" >  
  <XmlDocuments>
    <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
      <spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">
        <Receiver>
          <Name>List Item Updated Event Receiver</Name>
          <Type>ItemUpdated</Type>
          <SequenceNumber>10001</SequenceNumber>
          <Assembly>Sample.Solution, Version=1.0.0.0, Culture=neutral, Public                    KeyToken=285bf69c25gca888</Assembly>
          <Class>Sample.Solution.ListItemUpdatedHandler</Class>
          <Data></Data>
          <Filter></Filter>
        </Receiver>          
      </spe:Receivers>
    </XmlDocument>
  </XmlDocuments>
 </ContentType> 
</Elements>
Hope this helps in reducing the development efforts and increases the efficiency.

Tuesday, April 24, 2012

PowerShell Update Publishing Page Properties

Here is the simple powershell script to update the Publishing Pages properties. The web url and list name is read from the user.
#Declare variables

#Read web site url
$Url=Read-Host "Enter a web site url"

#Read list name
$ListName=Read-Host "Enter list name"

$FieldInternalName = "ArticleSortOrder"
$comment = "Added article sort order"

#Get web, list objects
$web = Get-SPWeb -Identity $Url
$spList = $web.Lists[$ListName]
if(!$spList)
{
 write-host $ListName" list doesn't exist"
 $web.Dispose()
 return
}

if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) 
{
 write-host "Reviewing pages in"$web.Title"site...."
 #Get the Publishing Web and pages within it
 $publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
 $publishingPages = $publishingWeb.GetPublishingPages()
 foreach ($publishingPage in $publishingPages)
 {
  $file = $web.GetFile($publishingPage.Uri.ToString())

  [Microsoft.SharePoint.SPListItem]$spListItem = $file.Item
  $FieldValue = $spListItem[$FieldInternalName]
  if(!$FieldValue -or $FieldValue -eq 0)
  {
   $FieldValue = 9999
   
   Write-Host "Checking out page: " $publishingPage.Title
   $file.CheckOut()
   
   Write-Host "Updating`t" $spListItem.Name "`tArticleSortOrder to $FieldValue"
   $spListItem[$FieldInternalName] = $FieldValue
   $spListItem.Update()

   $file.CheckIn($comment, [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn)        
   write-host "Added article sort order and checked in file: " $publishingPage.Title "`n"
  }
  else
  {   
   continue
  }
 }
}
else
{
    #Notify user that the site is not a publishing site
    write-host $web.Title"is not a publishing site"
}
$web.Dispose()

Monday, April 9, 2012

HTML Double Click Event

This morning i am surprised when i came to know html control does have a event called ondblclick for double click event. I know it is new for most of the html developers though they have extensive knowledge.

I feel its really useful for double click functionality.

<a  ondblclick="javascript:alert('double click event')">double click</a>

Wednesday, March 21, 2012

SharePoint/.Net Openings for Experience Professionals

We (Applied Information Sciences) have openings for SharePoint/.Net developers with 3+ years experience in the following technologies.

SharePoint – 2010/2007, Infopath Forms, Publishing..
.Net – ASP.Net, C#, WCF, MVC, Linq, Entity Framework.
.Net – ASP.Net, C#, Jquery, HTML/HTML5, CSS

Let me know if you are interested and need more details... 

Tuesday, February 21, 2012

SharePoint 2010 Certification Dumps

I know most of the developers who is going for Microsoft SharePoint Certification looks for dumps or material. Of course one can find material by Googling  but getting the right dump is very important and difficult.

However i found one efficient dump and followed for all my SharePoint Certifications (SharePoint 2010 Certification and Moss 2007 Certification).

You can find the dumps for SharePoint 2010 Certification and dumps for Moss 2007 Certification by accessing the link below.
SharePoint 2010 Certification Dumps and Moss 2007 Certification Dumps

PS: But i still suggest to follow the Text Books for extensive knowledge.

The site also provides dumps for All the Microsoft Certifications along with below other certifications.

Microsoft Certification Dumps
Cisco Certification Dumps
CompTIA Certification Dumps
Oracle Certification Dumps
Sun Certification Dumps
RedHat Certification Dumps
Citrix Certification Dumps
HP Certification Dumps
IBM Certification Dumps
CheckPoint Certification Dumps
CIW Certification Dumps
LPI Certification Dumps
Novell Certification Dumps
VMware Certification Dumps
CWNP Certification Dumps
EXIN Certification Dumps
Other Certification Dumps

SharePoint 2010 Sandbox Solution Limitations

The high level advantages and limitations of Sandbox solutions over Farm solutions.
What is Sandbox Solutions in SharePoint 2010?

Friday, February 17, 2012

Open SharePoint List Form in Edit Mode (New / Edit / View Form Pages)

I wanted to customize list's New form to load the JavaScript code by adding CEWP to auto populate some fields. But i could not find the option to Edit list form pages in the browser. i.e. New Form / Edit Form / View Form. It can be done using Designer but it is not handy.

I could edit the list form in the browser by using a simple technique.
Add the querystring &toolpaneview=2 at the end of the list form Url and hit ENTER.
That's it now the form is in edit mode, you can customize list form in the browser by adding web part or list views.

Tuesday, February 7, 2012

SharePoint AutoComplete Lookup Field with JQuery

I have Created a Custom SharePoint Lookup field that offers new functionalities to default SharePoint lookup field by allowing Auto Complete or Type Ahead search functionality with Contains CAML query.

Below is a few of the features offered by AutoComplete Lookup field over standard SharePoint Lookup field:
  • Auto Complete or Type Ahead lookup search (queries after each typing)
  • OTB SharePoint Lookup Dropdown look and feel for the results
  • Proper validations
  • Searches the lookup keyword with Contains CAML query
  • Configurable for No.of results to be displayed
  • Configurable for No.of characters to start the auto complete search

With few limitations:
  • It cannot be multi-valuated
  • Only one AutoComplete Lookup field is allowed per list
  • The target lookup field is frozen and always the Title field
The AutoComplete Lookup Field Solution (as SharePoint Solution installer) and Source Code are available for download at my CodePlex project SPAutoCompleteLookup.


Monday, February 6, 2012

SharePoint Calendar Setting a default duration for new Events as Outlook

First of all i would like to thank Ryan for his post on Setting a default duration for new SharePoint Calender Events, which helped me in providing a better solution to my client.

However I have updated the script for my requirement to auto-updating the end date time based on start date time, not only for the first time load but also for consequent start date time changes similar to Outlook functionality.
Note: The outlook loads the 30 mins duration for first time and for any consequent duration change by changing the end date time, it keeps the updated duration for start time change.

My updated JavaScript has below functionality:
1. Sets the default duration to 30 mins on first time load
2. It updates the end date time accordingly on updating start date, start hours or start minutes.
3. It provides the similar functionality as Outlook, sets the default duration 30 mins and keeps the updated duration (by changing the end date time) and doesn't allow end date time less than current date time.
4. It works for All Day, Recurrence and All Day + Recurrence Events

To apply the functionality follow the below simple steps:
1. Go to Calendar -> Click “New” in your Calendar to open up NewForm.aspx
2. Edit New Form -> Add a query string &ToolPaneView=2 onto the end of the URL to open the page in edit mode
3. Add a Content Editor Web Part to the page (below the New Form)
4. Click Open the toolpane or Edit > Modify Share Web Part
5. Click Source Editor and paste in the following JavaScript

JavaScript to auto-update end date time with a specific duration with start date time.