.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Weird error when creating a site from a feature receiver

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :C#

Hello everybody

I'm writing a feature in a sandboxed solution (scope of the feature : Web)

I've added to that feature a feature receiver that is supposed to create a subsite in the site in which it has been activated.

Here is the code

public override void FeatureActivated(SPFeatureReceiverProperties properties)
      string url="";
      using (SPWeb site = properties.Feature.Parent as SPWeb)
          site.Title = "root";
          SPWebTemplateCollection webTemplates = site.Site.RootWeb.GetAvailableWebTemplates(site.Language);
          url = site.IsRootWeb ? "subnews" : site.ServerRelativeUrl.Substring(1) + "/subnews";
          SPWebTemplate webTemplate = (from SPWebTemplate t
                         in webTemplates

View Complete Post

More Related Resource Links

Why feature with event receiver doesn't activate properly after site provisioning?



I have defined feature with event receivers for my document library and for users List .

I try to activate my feature in onet.xml in section <WebFeatures>. After provisioning a new site from onet.xml  all work fine and my feature is shown as activated, but event receivers doesn't fire. It fires only after reactivating my feature (deactivate, then activate it again). But I need my feature works immediately after site provisioning without deactivating and activating it again. Who knows how to solve this problem?

part of ONET.xml



        <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5"/>

        <!-- TeamCollab Feature -->

        <Feature ID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4"/>

        <!-- MobilityRedirect -->

        <!--My EventReceivers Feature-->

        <Feature ID ="41178843-A6A4-47c7-9EF9-B8A432E02B88"></Feature>





Error Creating Site Collection

Hello, I have created a basic claims-based web app in SharePoint 2010. When I try to create a Site Collection, after filling out all the details, I get the following error:   Error  Cannot complete this action. Please try again.  Troubleshoot issues with Microsoft SharePoint Foundation.  Correlation ID: 349b9ae9-7bda-41eb-921a-87974afb289c    I have tried ever which way to try and get it to work, but am still stuck. Any ideas as to why I can't create a Site Collection? Thanks!

Error when creating site collection through programmatically?

hi all, When i am creating SharePoint Site collection through programmatically i am getting an error message. i am using below code...   using (SPSite site = new SPSite("http://servername:7853/")) {   using (SPWeb web = site.OpenWeb()) {   SPWebApplication oweb = web.Site.WebApplication; site.AllowUnsafeUpdates = true;   SPSiteCollection sitecol = oweb.Sites;   SPSite site1 = oweb.Sites.Add("sites/DemoSiteCol", "DemoSiteCol", "Welcome to the Client SiteCol",1033, "STS#0", "Domian\\user", "display name", "user@domian.com");//here i am getting the error message as "Object refernce not set to an instance of an Object". oweb.Update(); } Please tell me why i am getting the error message.... thanks in advance.....

Running code after site definition site creation in a event receiver or feature receiver

Hi guys I've got a site definition which is pretty much based on STS.This is it's own sharepoint project. Let's call this project SiteDefProj. Next in another SharePoint project (same solution though). Let's call this CustomListProject. In this project I've got a feature which provisions a bunch of lists based on custom content types - this feature is a site scoped. Let's call this feature: CustomListInstances. I have added a feature receiver to this feature to execute some custom code on the lists themselves (under feature activated) In my ONET.XML (part of the SiteDefProj) I have CustomListInstances feature ID as part of my <sitefeatures>. When I do a create site I can actually step through the code and see it actually being executed but after the site is created the list instances are created but it's like the code never run or did anything. The weird part is that stepping through the code while creating a site collection using my SiteDefProj the code runs great with no errors. All lists are there and the code runs smooth. If I manually create a STS site and activate my feature everything works and the code does actually run and the effects are visible after the feature is created. Again I can actually step through it in debug. My suspicion is that there's some sort of a race condition in the CREATE SITE functionality where maybe the web or site collection hol

Duplicate field name error, creating new site from custom template

I've made a site that maps the site (with a table of contents) and i export it to another site collection. I'm able to install and activate the solution in the other site collection, however when i'm going to create a new site using the site i've installed as a template it pops an error saying "A duplicate field name Wiki_x0020_Page_x0020_CategoriesTaxHTField" was found." I have no clue what this means. Can anyone help me? Thanks in advance

Feature with wsp for creating specific groups on any site creation

hi, i need to create a sharepoint feature for wss 3.0 with .wsp (wsp for easy deployment) which do folowing funtionality: Ability to run some custom code for creating specific custom groups on every site creation. Feature needs to be activated when deployed so when user create new site it creates groups based on our custom code( i have custom code for creating gorups just need to know how to attached it to feature which works on every site creation event) Any workable example is very helpful for me because i am very confuse and already did reasearch on that. i guess feature stapling is not the solution in my case. Thanks in advanced shaheen

Error in creating Search Site


I am trying to create search site.If I try to create site using the 'Basic Search Center' its is creating a search site.But after creating the site if I try to search anything it is showing me the following error.


Internal server error exception:

Troubleshoot issues with Microsoft SharePoint Foundation.

Correlation ID: a1132c1b-2ecb-4f0e-afbb-f42422aaec33


And if I am trying to create site using 'Enterprise Search Center' or 'FAST Search Center' its is showing the following error and not possible to create the search site


An unexpected error has occured.

CorrealationID :{7abd617e-8438-4ce7-bb7b-12761b8b8f97}



here is the Log file:

09/20/2010 09:43:11.22     OWSTIMER.EXE (0x2A5C)                       0x2D14    SharePoint Server Search          Administration                    dl2i    Medium      Search application 'SharedServices - Search Ser

MySite creation fail - There has been an error creating the personal site. Contact your site adminis



I have a MOSS 2007 installation patched up to Cumulative Patch December, but are experiencing some issues with MySite.

When users access MySite, they recieve this errormessage in their browser: There has been an error creating the personal site. Contact your site administrator for more information.

This is followed up with this logged event on the server:


My Site creation failure for user 'DOMAIN\username' for site url 'https://mysite.domain.com/personal/domain_user'. The exception was: Microsoft.Office.Server.UserProfiles.PersonalSiteCreateException: A failure was encountered while attempting to create the site. ---> Microsoft.SharePoint.SPException: User cannot be found .
   at Microsoft.SharePoint.Administration.SPSiteCollection.Add(SPContentDatabase database, String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail, String quotaTemplate, String sscRootWebUrl, Boolean useHostHeaderAsSiteName)
   at Microsoft.SharePoint.Administration.SPSiteCollection.Add(String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerE

Creating a Site Column that Looks up an External List causes error when saving site as a template.


I'm not sure what the best practice is here, but I'm having a major issue trying to save sites as templates and I think I narrowed it down as to what the issue is.

When I try to save a site as a template, it creates the solution package, but it doesn't activate it.  When I try to activate it manually, I get the following error:

Feature definition with Id e9431ed5-27b1-4c33-9eeb-81b4ace9d372 failed validation, file 'test1ListInstances\ElementsFields.xml', line 481, character 231: The 'SystemInstance' attribute is not allowed.

I opened up the solution package and looked at the ElementsFields.xml file.  I traced the line to this:

<Field Type="BusinessData" DisplayName="Acme People Name" Required="FALSE" EnforceUniqueValues="FALSE" Group="Custom Columns" ID="{55b3bbba-a7e3-4698-9946-648a6b726e9e}" SourceID="{026904fd-f2d0-4e57-a239-c6da838458fa}" StaticName="Acme_x0020_People_x0020_Name" Name="Acme_x0020_People_x0020_Name" SystemInstance="ACME" EntityNamespace="http://????????:28241" EntityName="People" BdcField="FullName" Profile="" HasActions="True" SecondaryFieldBdcNames="0" RelatedF

Error while installing a feature on sharepoint site


Hi everyone,

  I am trying to install a feature that creates an custom menu item.

  When I run the stsadm command the following error comes :

Required tag 'http://schemas.microsoft.com/sharepoint/:Feature' is missing from XML file ...\12\Templates\Features\GoogleMenuItem\feature.xml'. found 'Feature' instead.

Kindly help me resolve this error...


Thank you

Error creating site template from wsp



I am installing myCustomSiteTemplate.wsp, on SP 2010 server, activating the solution , my customized template is listed under site templates.

however when I am creating a new site using that template , it is throwing error as

Thie site Template requires that the Feature {909ada82-494c-41a2-9c10-630f1588c9c2} be installed in the farm or site collection.

I checked on Sharepoint Power Sheel console, with the following command

get-spfeature 909ada82-494c-41a2-9c10-630f1588c9c2. it does not show any feature .

I have activated all Publishing feature on site collection.

please help

Getting error when creating SharePoint site



When i login as site collection administrator then i can able to create Share Point site. But when i login as contributor user then i am unable to create Share Point site.

I have also tried 'FormDigestSettings' but still issue is there.

When i turnoff security from CA site then i can able to create site as contributor user.Might be it is security issue. please suggest.


public SPWeb CreateSiteWithElevatedPrivileges(ProjectSiteEntity objProjectSiteEntity, SPUser objSiteOwner)
            SPWeb newSite = null;
                using (SPSite elevatedSite = SpSecurityHelper.GetCurrentSiteAsElevated())
                    using (newSite = elevatedSite.AllWebs.Add(objProjectSiteEntity.SiteName, objProjectSiteEntity.SiteName, objProjectSiteEntity.Description, 1033, objProjectSiteEntity.SiteTemplate, true,

Error when creating a custom site template



In VS 2010, I created a new SP project to create a custom site template.

W/O modifying the content, except setting the output path of the webtemp file to another language, I have the following error when I try to create a site based on this template :


failed to instantiate file "default.master" from module "defaultmasterpage": source path "default.master" not found


I've taken a look at OOB site templates, and I don't see what is missing.

I'd appreciate any help.




FYI, here is the content of my onet.xml  file :




there has been an error creating the personal site - Contact your site administrator for more inform


Hi All,

I feel like starting with the usual line - "please contact your site administrator" - I am the site administrator. Sharepoint 2010 Ent, getting this message when I click on the "MyContent" link in the MySite area, am aware that this is when the users my site is getting created. This has never worked, this is a new production build, the "My News Feed" & "My Profile" are working but the MySite "MyContent" link returns the above message. I have  included two windows log files below. Appreciate any help in advance.

 + System

  - Provider

   [ Name]  Microsoft-SharePoint Products-SharePoint Foundation
   [ Guid]  {6FB7E0CD-52E7-47DD-997A-241563931FC2}
   EventID 6141
   Version 14
   Level 2
   Task 13
   Opcode 0
   Keywords 0x4000000000000000
  - TimeCreated

   [ SystemTime]  2010-10-11T20:38:35.129624700Z
   EventRecordID 53482
  - Correlation

   [ ActivityID]  {32EF2BA9-B9C3-4223-B5B1-4BBAEC495A53}

Creating a feature that will recreate a existing site with all it's subsite content


i have a site saye http://intranet

under that site i have http://intranet/eng


now i have to create a Feature that once activated will recreate the same site http://intranet and its subsites http://intranet/eng

http://intranet/IT with all its contents

in another site collection in the same FARM.

Any suggestions that will help me here 

There has been an error creating the personal site. Contact your site administrator for more informa


Hi All

I have already created a web application and site collection for my site, now the scenario is I have a server on which moss 2010 is installed now when I create personal site for the user "moss2010\abc" its working fine but I have another domain "xyz" here I can easily create my site for "xyz\abc" but for this user when I click on "My Content" it gives me the ERROR as below:

There has been an error creating the personal site. Contact your site administrator for more information

I have already enable the self site creation and create manage path personal(Wildcard inclusion) these both are working fine with the domain "moss2010\abc" but give error as above for the "xyz\abc"

I want personal site for all the user of "xyz\abc".

If you have any idea regarding that please help me ,I tried almost everything which are available on net




Error creating MySite: There has been an error creating the personal site



When creating a MySite users get this error message:

There has been an error creating the personal site. Contact your site administrator for more information.

Here is our setup:

  • 1 web application for central administration
  • 1 web application for ssp administration site
  • 1 web application at port 80 (collaboration portal)
    • this web app uses (and requires) SSL
    • managed path: "mysite" (explicit inclusion)
    • managed path: "personal"(wildcard inclusion)
    • site collection based on the MySite Host on the "mysite" managed path
  • SSP: personal site provider: https://[portalurl]:443/mysite/
  • SSP: personal site location: "personal"

Initially we hosted the the MySites in a separate web application, but we migrated them to this new setup. The users who had a mysite before the migration have no issue, they can get to their mysite just fine.

If I look in the SharePoint logs I find this error message: "Value does not fall within the expected range"

Any ideas what we are doing wrong?

Here's an extract of the logfile:

CreatePersonalSite: Testing for personal site at:

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend