Thursday, December 1, 2011

Failed to create receiver object from assembly and System.ArgumentNullException: Value cannot be null for solution deployment

We ran into an error when reinstalling a webpart WSP package which has a new feature receiver in new version. The Central Administration has the following error:

SPSERVER11 : Failed to create receiver object from assembly ", Version=, Culture=neutral, PublicKeyToken=c5b8095908c623e3",
class "xxxxx.sp.web.webparts.Features.QualcommWebParts.QualcommWebPartsEventReceiver" for feature "QualcommWebParts" (ID: 94487eef-bc72-4034-8f5f-3f03f8676647).: System.ArgumentNullException: Value cannot be null. Parameter name: type at System.Activator.CreateInstance(Type type, Boolean nonPublic) at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

After looking at the message and we realized that this is similar to what we faced to timer service cleanup. Here is the explanation and solution.

The new webpart DLL has been deployed to GAC and the SharePoint timer service which handles solution installation caches DLL is still holding the old one. The cached old  DLL has no feature receiver. As a result, the error is Failed to create receiver object from assembly for event receiver.

The best way to resolve this is to clean up the SharePoint timer service configuration cache and rebuild them on ALL your servers as James mentioned. However, it’s kind of tedious and my college Curtis McDonald developed a script that will clean the configuration cache on all servers and restart it.

Although SharePoint timer service will rebuild the configuration cache after it restarts, it may take several minutes to complete the cache rebuild. In our case, it took about five minutes to rebuild the cache. Your WSP deployment will fail if the new SharePoint timer service configuration cache has not be rebuilt. You could go to the cache directory to verify the timestamp of the caches. The location of the cache is similar to C$\ProgramData\Microsoft\SharePoint\Config\d29cacae-41fc-4aad-a61d-83f43bfdf35d. The last part is the GUID of the process as indicated in blog.

Well, if you redeploy the solution after the cache rebuild, you should be able resolve the issue as mentioned in different blog.

Wednesday, November 30, 2011

Utilize the Managed Metadata Service application tip #9 - Managed metadata field displayed as term with term Id

If you use Managed metadata field in your email notification, you will find some strange ID attached to your field. What is the strange ID?

Here is the steps how to reproduce the issue.

1.       Create a custom list “MMD"
2.       Add an managed metadata column named “Managed Metadata Field” to use local term store as in the following screen shot 

3.       Create a designer workflow to send email 
4.       Send email with body to display value of the “Managed Metadata Field” as in the following screen shot 

5.       In the email, you will see term value concatenated with some IDs like “Term1|75e251f8-d30b-4de2-a388-4ee9c2a1d807” instead of just “Term1” value

If you review my previous blog on the Managed Metadata Column relationship, you will noticed that ID is the ID for the term. You could verify if you view the hidden list http://sbx01/sites/Harry/Lists/TaxonomyHiddenList/AllItems.aspx. See attached screen for details.

There are other cases you will get unexpected value of managed metatdata values.

1. If you export the list and the value of the managed metadata fields will also displayed as “ID;#Text”. The following field value "Test1" is displayed as "1;#Test1" instead.

2. If you use OoB web service to display the field, you will display ID;#Text” as well. There is a way you could trim for the webpart. Does anyone have a way to trim the term ID and just display term value for email and exported excel file?

After some researching, I saw  someone reported the similar issue and it might be fixed by December CU 2011.


You could refer other blog on managed metadata service.

Utilize the Managed Metadata Service application tip #1 - How to resolve "The required feature is not enabled for this column type" error 

Utilize the Managed Metadata Service application tip #2 - Metadata column not visible for users other than site collection administrators

Utilize the Managed Metadata Service application tip #3 – Impact of message “Earlier versions of client programs might not support this type of column” on Document Library

Utilize the Managed Metadata Service application tip #4 – How to workaround "Deletion of this user as a contributor failed" for local term store 

Utilize the Managed Metadata Service application tip #5 – Be aware of "Deletion of this user as a contributor failed" error on AD groups for local term store

Utilize the Managed Metadata Service application tip #6 – How to fix "The default termstore for this site cannot be identified " error

Utilize the Managed Metadata Service application tip #7 – How to read managed metadata column relationship 

Utilize the Managed Metadata Service application tip #8 - How to resolve error "This operation cannot be completed. The term store may be unavailable."

Thursday, November 17, 2011

SharePoint 2010 issue - Site owners are able to delete site templates or sandbox solutions from solution gallery without deactivating them

If you are using sandbox solution or saved site template on SharePoint 2010, you will noticed those solutions will be uploaded into solution gallery. We are currently run into an issue that site owners are able to delete site templates or sandbox solutions from solution gallery without deactivating them on some circumstances. More precisely site owners are able to delete site templates or sandbox solutions from solution gallery without deactivating them on load balanced multiple tier environment through edit item.

Here is the detailed steps to produce on SharePoint 2010 SP1 + June CU we are using.

1.       Setup SharePoint farm to have two IIS front servers and one or more application servers as multiple tier environment
2.       Save one site (Ex. http://sharepoint/it/EMS)  as site template ems.wsp and it will be loaded to solution gallery
3.       Navigate to solution gallery and active the solution if not already (Se screen shot the “Delete” icon is disabled from top ribbon)

4.       Click the Edit icon next to the solution and click “Delete Item” icon from the ribbon of the Edit Item dialog (See screen shot that it is not disabled!)
5.       The solution will be deleted from the solution gallery without deactivating

Two interesting observations are:

  • You could not delete the activated solution directly from the top ribbon since it is disabled when solution is activated.
  • Even you delete the solution from edit item dialog on single server environment, you will get an error without deleting the solution. See the screen shot for error if you delete the solution without activating it.

Since we have identical third party solutions and customizations installed, the only difference is the single server farm and front server with application server architecture. If we delete the solution without deactivating it, the template becomes orphan. Even it displaced when you create new site as show in the following screen shot, but you will get the error in the screen shot if you use it to create the site.

I also noticed that several people mentioned that might be a bug to delete solution from gallery that December CU 2011 might fix it. See the blog posting for details. I’m not sure whether our issues is related to this.

We have confirmed with Microsoft that can be reproduced on multiple tier architecture SharePoint farm. If you have web front servers and applications servers architecture, you will have this issues on the web front  servers. This is related to two services  “SharePoint 2010 User Code Host”  and the “Microsoft SharePoint Sandboxed Code Service” implementation.

This issue seems to be resolved on 2011 DEC. CU after initial testing.You can check the blog how to fix the issue on the existing site collections.

Wednesday, November 16, 2011

Tips to change SharePoint 2010 behavior without change out of box UI - Part I tag mapping

Write customer webpart and application pages to change SharePoint out of box behaviors are very common. However, these changes will ask users to use the customized UI (webparts or application pages) instead of out of box UI. There are some cases users want to change some SharePoint behavior globally without changing SharePoint UI. One example is for our SharePoint 2010 extranet implementation, security team asked us to restrict people picker to display users ONLY belongs to the site collection instead of whole farm for external users login from form based authentication. However, the same people picker needs to display all users in the whole farm for internal users login from Kerberos authentication. This requirement drives us to override SharePoint People Picker logic using tag mapping design. 

The tag mapping functionality is a mechanism to instruct the parser to substitute a different derived type implementation whenever it encounters the type being mapped. It was originally invented as part of the WebPart framework so as to allow the ASP.NET WebPartManager to be mapped to the derived Sharepoint WebPartManager implementation without having to change individual pages. However, it is quite powerful and generally applicable.

Here are major steps how to implement this without changing SharePoint UI.
1.    Identify the control out of box used for People Picker using browser tools to view source
2.    Create a new class deriving Microsoft.SharePoint.WebControls.PeopleEditor identified in #1
3.    Overwrite the functions inside class #2 to display only people inside the site collection for external users
4.    Sign the assembly with a Strong Name and install assembly into the GAC using feature
5.    Configure tag mapping entry in the Web.Config for the targeted webapp

The code for #3 is like this:

public class QCPeopleEditor : Microsoft.SharePoint.WebControls.PeopleEditor
        protected override void OnLoad(System.EventArgs e)

            // Determine which claims authentication type was used to log in
            SPClaimProviderManager mgr = SPClaimProviderManager.Local;
            if (mgr != null)
                SPClaim userLogonNameClaim = mgr.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName);
                SPOriginalIssuerType issuerType = SPOriginalIssuers.GetIssuerType(userLogonNameClaim.OriginalIssuer);

                // If user used FBA then switch people picker to only show users already in the site
                if (issuerType == SPOriginalIssuerType.Forms)
                    this.PrincipalSource = Microsoft.SharePoint.Utilities.SPPrincipalSource.UserInfoList;

The configuration for #5 is like this:
<add tagType="Microsoft.SharePoint.WebControls.PeopleEditor" mappedTagType="" />

This sounds very simple for certain circumstances. We have other people to use same design to modify people picker and use feature to update the web.config. This has been also used to change other UI as well. The most common user control we may modify using tag mapping design are as follows.
·         Assert Picker
·         People Picker
·         Time Picker
·         List Picker

However, sometime, it will become extremely difficult if you could not identify the out of box control used by SharePoint or the class you need to overwrite is sealed. One example is our users want to allow SharePoint 2010 BCS List Filter Web Part returns 500 items instead of only first 200 items. We have seen such requests from other people also but do not seen any good solution besides adding filters. Here is the difficulties as you might encounter if you try to overwrite.

There are several classes you may identify that need to be modified. Two of them are:
Class Microsoft.SharePoint.Portal.WebControls.SpListFilterValuesPickerUI function protected override void PopulateListItems()
Class Microsoft.SharePoint.WebControls.EntityEditorWithPicker function protected override int IssueQuery(string searchString, string filterName, int pageIndex, int pageSize)
SpListFilterValuesPickerUI is a sealed class and it will invoke other functions that are also sealed that would be very difficult to change them all. EntityEditorWithPicker will aslo call some utility class that are sealed and it is difficult to get the required dll or reference to compile the overwritten classes. Here are two examples of sealed class or functions.
internal sealed class SpListFilterValuesPickerUI : ListFilterValuesPickerUIBase<SpListFilterValuesPickerContext>
BdcClientUtil.GetEntity(BdcClientUtil.MetadataCatalog, pickerDialog.EntityNamespace, pickerDialog.EntityName);

If you try to use third party tool such as Lightning BCS metaman, designer, inforpath to retrieve external BCS items, you will always =get the first 200 items since they will internally call SharePoint default API.

As a result, change SharePoint 2010 behavior without change out of box UI using tag mapping is very useful but it may not be possible for all circumstances.

Thursday, November 10, 2011

Tips to resolve SharePoint 2010 users are prompted to save PDF file instead to open directly issue

We have SharePoint users reported an issue - users are prompted to save PDF files instead of opening directly when they try to open the files.  I looked at the issues and it has been addressed by several people for different directions. However, there is no easy way to verify the root cause for end users. In this blog, I will provide an simple way for end users to verify whether you have any open PDF file issues for specific library. Here is the details. 

Issue summary – In SharePoint 2010, users are prompted to save PDF files instead of opening directly when they try to open the files on some libraries. You could see detailed description in here. 

Root cause and solutions – In SharePoint 2010, there is a setting called “Browser File Handling” on both webapp level and library level that you could adjust to change this behavior. If the value has been set to “strict” instead of “permissive”, users are prompted to save PDF file.  Please note the setting on the library level is hidden value and will overwrite webapp level setting. As a result, if “Browser File Handling” is set up as  “permissive” on webapp level but as “strict” on library level, users will be prompted to save file.  You could follow the following steps to check and adjust the setting. 

       1. Browser File Handling setting on webapp level - You could use central administration UI or powershell to view/change the setting.

Go to Central Admin > Application Management > Manage Web Applications > Select the web application > Click General Setting in the Ribbon > Select “Permissive”  for “Browser File Handling” setting. You could use powershell to update all webapp setting to “permissive”

Get-SPWebApplication | ForEach-Object {$_.BrowserFileHandling = “permissive”; $_.update()} 

2. Browser File Handling setting on library level – You could not use SharePoint UI to view and change the value. You could use powershell or API to view and change the value. Here is a simple way I would prefer for end user to view  “Browser File Handling” hidden value for any list library. 

Use SharePoint designer to open the site. Then click the list library and find the ID (GUID) for the list. Then use the following URL http://<servername>:portnumber/<siteURL>/_vti_bin/owssvr.dll?Cmd=ExportList&List=<listHUID> to view the list settings. 

One example is listed below.


Of cause you still could use the following powershell to view and update the value. 

Add-PSSnapin Microsoft.SharePoint.Powershell
$site = Get-SPSite("http://sbx01/sites/Harry")
$web = $site.OpenWeb()
$list = $web.GetList("http://sbx01/sites/Harry/Shared Documents")
$list.browserfilehandling                       //list the value “Strict” is the return for example

$list.browserfilehandling = "Permissive"
$list.update()                                             // set the value to “Permissive”
$list.browserfilehandling                      // list the value again  

You could use the script published to loop through the site collection to update all list libraries through powershell.   One example is to loop through one web.

Add-PSSnapin Microsoft.SharePoint.Powershell
$site = Get-SPSite("http://sbx01/sites/Harry")
$web = $site.OpenWeb()
foreach ($list in $web.Lists) 
     if($list.browserfilehandling -eq "Strict") 
          $list.browserfilehandling = "Permissive"; 
          $list.update(); $site.url, $list.title, $list.browserfilehandling

After you update both “Browser File Handlingsettings on webapp and list library level to “Permissive”, you should open PDF file directly.  Please remember, you should verification the setting again by browsing URL like http://<servername>:portnumber/<siteURL>/_vti_bin/owssvr.dll?Cmd=ExportList&List=<listHUID>.

Friday, November 4, 2011

Different ways to identify what template is used for the site for SharePoint sites

I have receives several requests from different people who what to know the site template that was used to create their sites. Since there are several different options to get site template information and each one may be better under certain condition. Sometimes, you will get the site template ID instead name. You could refer here to relate the ID to name.

Here is the summary of the options and you could chose based on your situation.

1.  View site home page source code - Easiest way for end users
Login to the site. Click browser's View menu and source the source code. Search the variable g_wsaSiteTemplateId and the value associated. The example for a “Team Site” is:

         <script type="text/javascript">
         var g_wsaLCID = 1033;
         var g_wsaSiteTemplateId = 'SPS#0';

2.  View saved site template configuration – Another accurate way for end users
Save the site as template. Get the saved site template (ex. Test.wsp) from Solutions Galleries and saved to local drive. Rename the .wsp to .rar file. Then you could browse to folder TestWebTemplate and open file Elements.xml. Search BaseTemplateName value. Example for a “Blank Site” is:

            <Elements xmlns="">
               <WebTemplate AdjustHijriDays="0" AlternateCssUrl="" AlternateHeader="" 
               BaseTemplateID="53" BaseTemplateName="BLANKINTERNET" BaseConfigurationID="0"

3.       View WebTemplateId property from SharePoint Manager tool – easy way for system admin or developer who have access to the server
Download the SharePoint Manager tool and open the site. Browse to view WebTemplateId property. Example for a “Team Site” is:

4.       Command to display the site template IDs and site map status for all site collections and subsites – easy for system admin to get for all sites
STSADM -o enumallwebs
Example is:

  <Database SiteCount="1" Name="WSS_Content_3333" DataSource="SBX10\sharepoint">
    <Site Id="2e4d5a29-8e4a-4403-8a14-4ceb454c74d3" OwnerLogin="NA\pdssbx" InSiteMap="True">
      <Webs Count="1">
        <Web Id="cd21314c-e8e2-46cf-a8e5-a9392bda6526" Url="/sites/mmd1" LanguageId="1033" TemplateName="STS#0" TemplateId="1" />

5.       API or Powershell – Complicated but much flexible to generate the formatted report and even send email used by developers
You could use SharePoint API to get SPWeb.WebTemplate property of a site. You could format the report to display all site collections and site for the whole farm. You could generate the nice report and send emails. Here is the simple code using API. You could find other example for powershell. Here is code snippet to list all sites.

SPWeb web = site.OPenWeb(“url”);
       templateName = web.WebTemplate;
       templateID = web.WebTemplateId;

6.       Database query – simple query for DBA
If you are DBA, you may login to the sql server management studio and execute below query on the content database of the application. Please note the dbo.Webs is a database view and the return WebTemplate is the site template ID. You need to associate the ID with template name.
SELECT Title, WebTemplate FROM dbo.Webs WHERE Title='Test Site'

Now, you have different ways to identify what template is used for the site for SharePoint sites. If you need to know more about the site definition for the site, append the  /_vti_bin/owssvr.dll?Cmd=GetProjSchema to the site URL (ex. http://sbx01/sites/Harry/_vti_bin/owssvr.dll?Cmd=GetProjSchema). You will have another whole world you could explore.