Archive

Archive for June, 2012

Querying for Feature Upgrades error: The site with id cannot be found

June 20, 2012 4 comments

Introduction

I am involved in a large project which is creating a large number of SharePoint webs. The webs content and configuration are being modified using Features and Feature Upgrades.

We are using PowerShell to process the Feature Upgrades using Chris O’Brien’s excellent SharePoint Feature Upgrade Kit.

One of the issues that we started to see during testing was when looking for Features which are scoped at the Site Collection using the SPWebApplication object’s QueryFeatures(SPFeatureScope, Boolean) function.

The following PowerShell was being used:-

$webapp = Get-SPWebApplication http://dev.itsp.local;
$webapp.QueryFeatures("Site",$true);

When this code was run in SharePoint 2010 Management Console the following error was displayed.

An error occurred while enumerating through a collection:
The site with the id f6f2e2bb-46bf-4c46-995e-65055512114e could not be found..
At line:1 char:22 + $webapp.QueryFeatures <<<< ("Site",$true); + CategoryInfo
: InvalidOperation: (Microsoft.Share...esultCollection:SPFeatureQueryResultCollection) [],
RuntimeException + FullyQualifiedErrorId : BadEnumeration

Investigation

Investigation started by looking at whether this error could be reproduced on other SharePoint environments which it could. Further testing was performed using different SharePoint builds including SharePoint 2010 Service Pack 1 and Cumulative Updates from June 2011 to December 2011.

The cause of the error seems to be when you have a site collection that has been deleted from SharePoint but had a feature that needs to be upgraded.

Looking in the Content Database for the Web Application revealed a entry in the AllSites table which looked like this:-

contentdb_deletedsiteentry

Reminder: Accessing the SharePoint databases is not supported by Microsoft and should not be performed in a production environment.

The row in the database has a column called Deleted which has a status of 1.

Using the Get-SPSite cmdlet the Site Collection could not be found. However, a colleague reminded me that there is a Get-SPDeletedSite. This returns back site collections that are found in the site collection recycle bin. The command returned a site collections that had been deleted a few weeks ago.

There is a function, Remove-SPDeletedSite but while this removes the site collection so it cannot be accessed via Get-SPDeletedSite, the error still occurs and the record is still found in the Content Database.

The issue seems to be down to the way that the SPWebApplication.QueryFeatures function works and does not filter the site collections which have been deleted and hence the error occurs.

Solution

Currently there is no fix for this issue that I am aware of. However, all is not lost and a workaround was possible by a few additional lines of PowerShell.

$webapp = Get-SPWebApplication http://dev.itsp.local;
$webapp.Sites | ForEach-Object {$queryFeatureResults += $_.QueryFeatures("Site",$true)};

This PowerShell command will enumerate through all the SPSite in the Web Application and call the same function but on each Site Collection. This gets around the problem with the QueryFeature() function finding the deleted site collection.

queryfeature-foreach-withresult

June 10, 2012 Leave a comment

Simon Doy:

Updated with SharePoint 2010 Version of Script

Originally posted on iThink SharePoint:

Update: 10th June 2012

A few people have posted comments about the script not working for SharePoint 2010. This code was built for SharePoint 2007. However I have been through the code and an updated version can be found below.

Apologies that it has taken a while to respond.

The SharePoint 2010 Code version works slightly differently and uses the jQuery Live method and JavaScript OnMouseOver event to update the PDF’s a tags.

Introduction

One of our clients wanted a way to ensure that Adobe PDF’s did not open in the current browser window.

By default a PDF opened into Adobe Acrobat will open in the current browser window.

This presents a usability problem as user’s lose the reference to the site they were in also other applications, such as Word and Excel, do not behave in this way.

How Acrobat opens a document…

View original 1,004 more words

Categories: Uncategorized

Useful Visual Studio External Tools

June 6, 2012 Leave a comment

Introduction

I have been meaning to document this for a while. Every time I set up a new machine I have to check the configuration of my Visual Studio external tools.

External Tools? If you don’t know what I am talking about then take a look at the image below.

image

Currently I have the following External Tools:-

  • Create GUID – this allows me to quickly get a new GUID when creating all those SharePoint resources, including Content Types, List Schemas, Feature Receivers etc.
  • Get Public Key Token – this uses the .Net Framework Signing Tool (sn.exe) to get the Public Key token, although with the new SharePoint tools in Visual Studio this isn’t needed so much there are always those odd occasions.
  • Get Full Assembly Name – This is used lots particularly when having to hack together various SharePoint Xml files or Entity Framework resource connection strings. I can’t take credit for this one, Sahil Malek – http://blah.winsmarts.com/2009-12-SharePoint_Productivity_Tip_of_the_day.aspx), did all the hard work.
  • Get IIS Web Application Information – This saves me so much time when debugging code especially, feature receivers, application page, web part code. The tool will display a list of all the Web Applications and there Process ID (PID).

Setting up the Tools

Create GUID Tool

First of all locate the Guidgen Tool which should be found in your Windows SDK folder. The path will depend on the Windows Version you are running, this one is for Windows 2008 R2. “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\”

  • The GUID Generator application can be found in the bin subfolder
  • Full Path: “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\guidgen.exe”
  • Now you have the path, fire up Visual Studio

clip_image002

  • Click Tools->External Tools
  • Click Add
  • Title: Generate GUID
  • Command: : “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\guidgen.exe”
  • Click Apply

clip_image004

When this tool is used then the following window will popup:-

clip_image006

Get Public Key Token Tool

This retrieves the public key token for the assembly that is associated to the file that is open in Visual Studio.

To setup the tool do the following:-

  • Get the Path to the SN.exe tool which is found in the .Microsoft SDK Path
  • “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe”
  • From Visual Studio
  • Click Tools->External Tools
  • Click Add
  • Title: Get Public Key Token
  • Command: : “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe”
  • Attributes: -Tp $(TargetPath)
  • Check “Use Output Window”
  • Click Apply

clip_image008

When the External Tool is used then the following output will appear in Visual Studio’s Output Window

clip_image010

Get Full Assembly Name Tool

This tool is excellent and saves me lots of time when you need the full Assembly Name for all the numerous SharePoint development tasks.

The setup of the tool comes from Sahil Malek (http://blah.winsmarts.com/2009-12-SharePoint_Productivity_Tip_of_the_day.aspx).

  • Fire up Visual Studio
  • Click Tools->External Tools
  • Click Add
  • Title: Get Full Assembly Path
  • Command: PowerShell
  • Arguments: -command “[System.Reflection.AssemblyName]::GetAssemblyName(\”$(TargetPath)\”).FullName”
  • Check “Use Output Window”
  • Click Apply

clip_image012

The output for this tool is as follows:-

clip_image014

Get IIS Web Application Info

This tool is great for getting information on the Web Server Application Pools. This is great if you need to debug a particular Web Application Pool Process.

  • Fire up Visual Studio
  • Click Tools->External Tools
  • Click Add
  • Title: Get IIS WP Info
  • Command: “c:\windows\system32\inetsrv\appcmd.exe”
  • Arguments: list WP
  • Check “Use Output Window”
  • Click Apply

clip_image016

The Output for this tool is as follows:-

clip_image018

Conclusion

I hope you find some of those tools useful, I would love to hear about any that you use.

%d bloggers like this: