Bryan's profileSharePoint o RamaBlogLists Tools Help

SharePoint o Rama

All things that are SharePoint.

Bryan Phillips

Occupation
Location
Interests
http://www.composablesystems.net

Co-author of Professional Microsoft Office SharePoint Designer 2007 (I am the guy in the middle.)
Contains links to lists of various SharePoint objects including .Net classes, files, etc...
June 25

Error when applying Service Pack 2 to SharePoint

You may get the following error in your Upgrade.log file when you are applying Service Pack 2:

[SPIisWebSiteWssSequence] [ERROR] [6/25/2009 10:06:42 AM]: Action 3.1.3.0 of Microsoft.SharePoint.Upgrade.SPIisWebSiteWssSequence failed.
[SPIisWebSiteWssSequence] [ERROR] [6/25/2009 10:06:42 AM]: The system cannot find the path specified.

[SPIisWebSiteWssSequence] [ERROR] [6/25/2009 10:06:42 AM]:    at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.get_AdsObject()
   at System.DirectoryServices.PropertyValueCollection.PopulateList()
   at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
   at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
   at Microsoft.SharePoint.Administration.SPIisApplicationPool.get_PeriodicRestartMemory()
   at Microsoft.SharePoint.Administration.SPProvisioningAssistant.EnableMemoryBasedAppPoolRecycling(SPIisApplicationPool local)
   at Microsoft.SharePoint.Administration.SPProvisioningAssistant.EnableMemoryBasedAppPoolRecycling(String applicationPoolId)
   at Microsoft.SharePoint.Upgrade.EnableMemoryBasedAppPoolRecycling.Upgrade()
   at Microsoft.SharePoint.Upgrade.SPActionSequence.Upgrade()
[EnableMemoryBasedAppPoolRecycling] [3.1.3.0] [DEBUG] [6/25/2009 10:06:42 AM]: Begin Rollback()
[EnableMemoryBasedAppPoolRecycling] [3.1.3.0] [DEBUG] [6/25/2009 10:06:42 AM]: End Rollback()
[EnableMemoryBasedAppPoolRecycling] [3.1.3.0] [DEBUG] [6/25/2009 10:06:42 AM]: Begin Dispose()
[EnableMemoryBasedAppPoolRecycling] [3.1.3.0] [DEBUG] [6/25/2009 10:06:42 AM]: End Dispose()
[EnableMemoryBasedAppPoolRecycling] [3.1.3.0] [DEBUG] [6/25/2009 10:06:42 AM]: Elapsed time: 00:00:00.2050000.
[SPManager] [ERROR] [6/25/2009 10:06:42 AM]: Upgrade [Microsoft.SharePoint.Administration.SPIisWebSite] failed.
[SPManager] [ERROR] [6/25/2009 10:06:42 AM]: The system cannot find the path specified.

 

The error is due to a problem with one of the app pools in IIS.  Unfortunately, you may have multiple app pools with this problem.  However, using the following script, you can determine which app pools will have this problem before you try to reapply the service pack.

 

using System;
using System.Collections.Generic;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

… code snipped …

public static void RunSnippet()
{
    Type iisAppPoolType = typeof(SPWebService).Assembly.GetType("Microsoft.SharePoint.Administration.SPIisApplicationPool");
    SPWebService webService = SPFarm.Local.Services.GetValue<SPWebService>();
    foreach(SPWebApplication webApplication in webService.WebApplications){
        string appPoolName = webApplication.ApplicationPool.Name;
        Console.WriteLine(appPoolName);
        object iisAppPool = iisAppPoolType.GetConstructors()[0].Invoke(new object[]{appPoolName});
        try{
            int periodicRestartMemory = (int) iisAppPoolType.GetProperty("PeriodicRestartMemory").GetValue(iisAppPool, null);
            Console.WriteLine("OK");
        } catch (Exception ex){
            Console.WriteLine("BAD" + ex.ToString());
        }
    }
}

I hope this helps other people with getting SP2 to apply successfully.

Technorati Tags: ,,,
June 24

Guerilla SharePoint Designer Tips And Tricks

Jason Graham and I presented at the Kentucky SharePoint Users Group (KYSPUG) last Thursday.  The presentation showed how to create forms in SharePoint Designer without using the DataViewWebPart or having any knowledge of XSLT by using the SPDataSource control and the ASP.Net FormView control.  You can download the slide deck here.

June 17

The next time SharePoint Designer acts weird try this:

From the menu bar, select Site –> Site Settings.

Click the Advanced tab, then click the Delete Files button.

I don’t know what it does, but it fixes some problems that don’t go away when you close and reopen SharePoint Designer.

image

June 16

A note about targeted audiences in Microsoft Office SharePoint Server (MOSS)

If you connect two web parts and assign a targeted audience to only one of them, you may get this cryptic error message:

Could not find the connection consumer Web Part with ID "xxxxxxx".

To solve this problem, assign the same targeted audience(s) to both web parts.

Technorati Tags: ,,
November 24

Unit testing SharePoint without SharePoint

<Begin>
Typemock are offering their new product for unit testing SharePoint called Isolator For SharePoint, for a special introduction price. it is the only tool that allows you to unit test SharePoint without a SharePoint server. To learn more click here.

The first 50 bloggers who blog this text in their blog and tell us about it, will get a Full Isolator license, Free. for rules and info click here.
<End>

Hopefully, I will get a free copy of the license.  I write extensive SharePoint customizations every day for the applications my company writes.  A tool like this will definitely be an asset regardless of whether or not I have to pay for it.  For those of you that know me, it goes without saying that I see a lot of opportunities for code generation here.

Technorati Tags: ,,
November 04

Making the ASP.Net designer work in SharePoint projects.

If you create and deploy your SharePoint functionality using class library, STSDEV or WSPBuilder projects, you may have noticed that you cannot view your ASCX files in design mode.  This is due to the reliance of the ASP.Net designer on the web application project package in Visual Studio.  If you want to enable this functionality, you need to modify your project file:

  1. After backing up your project file, open the project file in notepad.
  2. Paste this line immediately below the line containing <ProjectGuid>:
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
  3. Save the project file and reopen it in Visual Studio.

The beginning of the project file should look like this after adding the new line:

<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">DebugBuild</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{FB6B8816-0B97-4DB7-B810-64F05830EE0D}</ProjectGuid>
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

Technorati Tags: ,,
October 13

Setting the content type for a list item (Part 1)

This is the first post in a small series of posts to list all the ways to set the content type for a list item. 

The easiest way to set the content type for a list item is to use the built-in list management forms in SharePoint.  When a list is set to allow content types and multiple content types have been associated with the list, the new and edit forms for the list item will have a drop down list containing the available content types.  Choose your content type in the drop down list and click the OK button to save the item.  If your list has only one content type assigned, the drop down list will NOT appear because the item will automatically be assigned that single content type.

Technorati Tags: ,
October 10

Weird error when opening SharePoint Designer

The other day I got the following error when opening SharePoint Designer:

"Microsoft Office SharePoint Designer is not installed properly and cannot function.  Please exit and reinstall Microsoft Office SharePoint Designer, and then try this operation again."

I guessed that it was due to a resource problem so I started closing some of the instances of Visual Studio 2008 that were open.  After getting the number of instances below 5, the problem went away.

October 08

SPException occurred: Invalid text value

You may get the following exception when calling the Update method of the SPListItem class:  "Invalid text value  A text field contains invalid data. Please check the value and try again."  This occurs when the value you supplied for a text field is larger than 255 characters.  To address the problem, store less text in the field or change the field type from text to note.

Technorati Tags: ,,
October 06

Beware of read-only files in the 12 hive

I just recently discovered that I had some read-only files in my feature folder.  Apparently, the solution package deployment process does NOT overwrite read-only files and gives no warning when the problem occurs.  Once I manually deleted the read-only files, the problem went away.  If you are deploying solution packages and your functionality does not seem to be updated in SharePoint, be sure to check for read-only files too.

 

Technorati Tags: ,,
October 05

Tab order is reset to zero when changing a control to another type

When you right-click a control and choose "Change To", it will reset the control's tab order to zero. Remember to set this value after changing it if you are using a specific tab order in your form.

Technorati Tags: ,,

Non-supported field type change. The field cannot be changed to the new type. Please check the new type and try again.

You will get this error if you activate a feature that provisions a list with a field whose name matches an existing site column but the two columns do not have the same data type.  You will have to remove the conflicting site column or list field before the error goes away.  In my case, I had deleted some old, unused InfoPath forms but forgot to remove the site columns and content types it created.

Technorati Tags: ,,
October 03

Error when starting the WSS Admin service or when accessing Central Admin

You may get this error in your event log when starting the WSS Admin service or when accessing the Central Admin web site:

Service cannot be started. System.ComponentModel.Win32Exception: The group name could not be found
   at Microsoft.SharePoint.AdministrationOperation.Win32.SPNetApi32.NetLocalGroupGetMembers(String groupName)
   at Microsoft.SharePoint.AdministrationService.SPAdministrationService.RegisterSPAdministrationOperation()
   at Microsoft.SharePoint.AdministrationService.SPAdministrationService.OnStart(String[] args)
   at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

When the WSS Admin service starts, it looks for a local group named WSS_RESTRICTED_WPG and enumerates its members.  If this local group is deleted or renamed or if the server is upgraded to be a domain controller after SharePoint has already been installed, this exception will be thrown. 

Never rename or delete the build-in SharePoint local groups:  WSS_ADMIN_WPG, WSS_RESTRICTED_WPG, and WSS_WPG.

Technorati Tags: ,,
September 22

Anonymous Audiences in MOSS code has moved to CodePlex

The code for my Anonymous Audience feature for MOSS has moved to Scot Hillier's CodePlex project located here.  Scot's project has a great list of tools built by the SharePoint community.

Technorati Tags: ,
September 16

Creating SharePoint Designer add-ins

If you have ever wanted to create add-ins for SharePoint Designer 2007, then read this.  I have just created VSTO project templates for SharePoint Designer 2007 for C# and VB.Net.  These are available on my CodePlex site at:  http://www.codeplex.com/VSTO/Release/ProjectReleases.aspx?ReleaseId=17375.  Let me know if you find them useful.

Technorati Tags: ,,,,
June 29

How to determine if MOSS is installed.

An easy way to determine if MOSS is installed is to check the farm's property bag for a property named "SearchProviderName".  If that property exists and its value is "Office SharePoint Server Search", then MOSS is installed. 

Here is a snippet of code that shows the property in action (it assumes that the site variable is a SPWeb object):

SPFarm farm = site.Site.WebApplication.Farm;

if (farm.Properties["SearchProviderName"] != null
    && farm.Properties["SearchProviderName"].ToString() == "Office SharePoint Server Search") {

    // MOSS is installed.
} else {    // MOSS is NOT installed.
}

 

Technorati Tags: ,,
May 06

An easy way to debug SharePoint SPFeatureReceiver classes

Until now, I used to debug SharePoint feature activation by using the Attach Debugger feature to launch the debugger from inside the IIS worker process my SharePoint site was using.  After some tinkering, I was able to determine that you can also debug by configuring your SharePoint feature product to start STSADM.EXE and supply the command line options to activate the feature.

See this screenshot for details:

image

If you don't already know the location of STSADM.EXE, it is located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE.

Once your project is configured, you can set a breakpoint in the FeatureActivated method of your feature receiver and debug the project.

 

Technorati Tags: ,,
May 04

Anonymous Audiences in MOSS

In a past project, I needed to be able to create an audience in MOSS that would apply only to anonymous users in an SharePoint site configured to use forms-based authentication.  Additionally, anonymous users could not access a page in SharePoint if the page contained a web part that was configured with an audience.

I noticed that the RuntimeFilter tag in the web.config file referenced the AudienceManager class: 

<RuntimeFilter Assembly="Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Class="Microsoft.Office.Server.Audience.AudienceManager" BuilderURL="audience_chooser.aspx" />

Using Reflector, I was able to determine that this class was responsible for both supplying the audience controls in the tool part window and for determining whether or not the user was in the audience configured for the web part. 

Normally, these controls are displayed when a web part is edited:

image

But after writing a wrapper for the AudienceManager class, I was able to add an additional checkbox to allow the user to specify that only anonymous users should see the webpart:

image

Now, when the user checks the check box, only anonymous users will see the web part.  I also made an additional change to workaround the problem of anonymous users not being able to see pages that had web parts configured with audiences.

To implement the same functionality, you will need two classes:  one that implements the Microsoft.SharePoint.WebPartPages.IRuntimeFilter2 interface and one that implements the Microsoft.SharePoint.WebPartPages.IToolPaneControl interface.  The IRuntimeFilter2 interface is used to determine if the current user is in a particular audience when the web page is rendering and the class you create will need to be configured in the RuntimeFilter tag in the web.config file.  The IToolPaneControl interface is used to display the audience control in the tool pane when the web part is edited.

You can download the code I used here.

Technorati Tags: ,

Exception when calling SharePoint web services

You may get the following exception when calling SharePoint web services:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Attempted to perform an unauthorized operation.

In my case, the problem was that the URL I used did not map to a site collection in SharePoint since I had previously deleted that site collection and forgot to recreate it.  Once I recreated the site collection, the error went away.

Technorati Tags: ,,
April 18

"Object reference not set to an instance of an object." when trying to Detach from Page Layout in SharePoint Designer.

If you get this error message in SharePoint Designer when you are detaching a page from its page layout, reopen the site using the original public URL for the zone you configured for Windows Auth.  If you don't know the URL, open Central Administration, click the Operations tab, and click the Alternate Access Mappings link.  Then, select the web application from the Alternate Access Mapping Collection dropdown.  The URL you need to use will be in the Public URL for Zone column.

Technorati Tags: ,

Tab order is reset to zero when changing a control to another type

When you right-click a control and choose "Change To", it will reset the control's tab order to zero. Remember to set this value after changing it if you are using a specific tab order in your form.
November 15

Slow InfoPath form performance

If you have data connections that are unused on the view you are displaying, be aware that the data returned by the data connections is still transfered from the server to the browser during post backs. This will cause any business logic or custom code to be slow since so much data is returned after the code on the server runs.

Technorati Tags: ,,

Making file attachments work in InfoPath Form Server

File attachments in InfoPath browser-based forms will not work unless the form tag of the master page is modified to include the encoding type. Ex: <form enctype="multipart/form-data" .... >

Technorati Tags: ,,

Saved forms and alternate access paths

If you try to view a saved form using a different alternate access path than the one used to save it, you will get an error message. The problem stems from the fact that the saved form XML has a fully-qualified, hard-coded path to the site collection where it was saved and it is not being translated to another other alternate access path.

Technorati Tags: ,,

Promoting properties of forms already published

If you promote a new property in a form that has already been published, it will not update the form's content type until you deactivate and reactivate it to the site collection where it is deployed.

Technorati Tags: ,,