17

how about; warning: your feature needs to be scoped as web for it to work obviously ;) public override void FeatureActivated(SPFeatureReceiverProperties properties) { // No need to dispose the web istance, as indicated in the "Do not dispose" guidance SPWeb web = (SPWeb) properties.Feature.Parent; // added semicolon ClassOfMine....


10

Get-SPWebApplication xxx | Get-SPSite -Limit ALL | % {Enable-SPFeature "xxx" -Url $_.Url}


9

Remove feature receiver Clean solution Close Visual Studio Delete SharePoint project's obj folder in Windows Explorer Delete SharePoint project's bin folder in Windows Explorer Open Visual Studio and re-add feature receiver Start Debugging


8

Yep the place to do it is the feature activated portion of the feature receiver. You can check if one of your others are already activated and throw an exception if they are. Certain exceptions when thrown will display the message to the end user, others will just say an unexpected event occurred. I think if you throw an applicationexception it will ...


8

Usually this happens if you have feature activated event receiver and use http context in code somehow (accessing to SPContext.Current or creating web part, that might use internally Http context). When you activate your feature through UI, Http context is not null and all may work as expected, but when activating through PS or stsadm Http context is null ...


8

Ok so the Get-SPFeature works differently depending on what parameters you pass it. The following line is asking which features are enabled at the Web Scoped level. $webFeature = Get-SPFeature -Web $spSiteCollection | Where-Object.... However, if you want to see if your feature is installed then you need to use Get-SPFeature without passing any scope to it....


7

If the assembly contains any event or feature receivers then the deployment target should be Global Assembly Cache. And if you deploy the solution using a command line then you should start a new instance of that before activating the feature (this is most important when you get to upgrading) as an old version of the dll can't be unloaded.


6

This error mostly occurs when you go wrong with the name of the feature. Activate it using GUID instead, should help!


6

It’s better to use the Delete() method of SPWeb.Lists instead of using the Delete() method on the SPList because the latter doesn't delete lists properly sometimes. Try something like: SPWeb mySite= SPContext.Current.Web; SPList myCustomList = mySite.Lists["MyCustomList"]; mySite.Lists.Delete(myCustomList.ID); mySite.Update();


6

My issue got resolved. This may help someone in future. What I tried: Since the feature was not getting displayed in "Manage Site Features", I tried to enable feature using powershell. Enable-SPFeature -identity featureID -URL yoursiteURL This command failed with error: The feature is not a Farm Level feature and is not found in a Site level defined ...


5

Since this is a PowerGUI issue, you can fix it by following this solution. Follow these steps. Open your windows explorer and navigate to C:\Program Files (x86)\PowerGUI\ and open the configuration file ScriptEditor.exe.config. Change the supportedRuntime version under Startup settings by removing the version=”v4.0″ as below Final <Startup> element ...


5

Here is the C# version of Anders answer as it was not as straightforward as I would have thought. public static void SetFormJSLink(this SPList list, PAGETYPE formBaseView, string jsLinkUrl) { var file = list.ParentWeb.GetFile(list.Forms[formBaseView].Url); file.CheckOut(); using (var manager = file.GetLimitedWebPartManager(PersonalizationScope....


4

I think you should check this: Removing Provisioned Files from SharePoint During Feature Deactivation


4

The FeatureInstalled method is called when the WSP is loaded into the Farm and the Feature files are copied into the 12 hive. This is done in Central Administration or via the command line (Powershell or STSADM). Because of this, there is no website Context to speak of, no site collection or no SPWeb.


4

By design ListAdded can be hosted by SPWeb or SPSite only as documented here. So Feature Stapling cannot be avoided if you want to enforce that across the farm. UPDATE: As per MSDN Documentation, If the Receivers tag has no ListTemplateId or ListUrl attribute, the event receiver is registered at the same scope as the Feature. Which means you should not use ...


4

Simillarly as with Content Query Web Part (CQWP) also the Summary Link Web Part is governed by an XSL file in charge of rendering content available at the Site Collection Level in the Style Library called SummaryLinkMain.xsl. I would strongly recomand simply copy that file, rename it to your liking and then export your SLWP and change its attributes to ...


4

A really good explanation is already been given on this blog, so I would suggest you to look at it features-with-powershell/ Possibly Duplicate Question EDIT detect if a feature is deployed or not detecting-solution-deploying-status Edit 2 Code of checking if a feature is activated or not $featureGuid = "PUT-GUID-HERE" $web = Get-SPWeb http://...


4

Why dont you just add the feature to SiteFeatures or WebFeatures element of onet.xml ? It is what it is there for :) The features are executed synchronous, so only in very rare occasions have I experienced race conditions.


4

If you know the name of the feature, you can retrieve the feature's definition ID by iterating the SPFeatureDefinitionCollection. Guid yourGuid; foreach (SPFeatureDefinition featureDef in web.FeatureDefinitions) { if (featureDef.DisplayName == "YourTitle" && featureDef.Scope == SPFeatureScope.Web) // Check the scope just to be safe { ...


4

make sure the solution deployment job was finished before you activate the feature. have a look at this blog: Programmatically waiting on SharePoint Solutions to deploy


4

function Deactivate-SPFeature { param ($FeatureID, $SiteUrl, $WebApplicationUrl) $Feature = Get-SPFeature -Identity $FeatureID -ErrorAction SilentlyContinue $IsActiveFeature If ($Feature -eq $null) { Write-Warning "The specified feature ($FeatureID) was not found." return } If ($Feature.Scope -eq [Microsoft....


4

I have faced the same situation many times. I used a tool called Feature Admin. It shows any features that are isolated and cannot be used including error occured. You can delete the unwanted or error occurred features through it.


4

Go to Site Content Types, then, go to the Document Content Types section Click Document in that section Click Advanced on the Site Content Types for that content type In the Read Only section of that page click YES Click OK Source: Geoff Evelyn's answer here: https://social.technet.microsoft.com/Forums/en-US/bc53d0ff-b7b4-4cc3-b3e9-87af23f8ba8e/...


4

Make the feature scope in Visual Studios be "Site" instead of "Web". https://msdn.microsoft.com/en-us/library/ee231541.aspx


4

You should be aware of the PWA setting can not be enabled on a publishing site, it only activated on the Team Site or Project Site template. For more details check Add Project Online to a site collection


3

some good practices are: use feature activation dependencies to control multiple hidden features activations with single master feature clean up web parts on deactivating for web parts added by feature activation some bad practices are: rely on feature activation order using dependencies clean up data structures (lists/sites) on feature deactivation some ...


3

You should dispose of the SPWeb reference after each feature receiver has executed. public override void FeatureActivated(SPFeatureReceiverProperties properties) { using (SPWeb web = properties.Feature.Parent as SPWeb) { } } Admittedly, feature receivers such as this are one of the few places where you don't "have to" dispose of your SPWeb ...


3

Try restarting Visual Studio. Sometimes it locks some stuff, I've seen it before.


3

Please follow this tutorial, I have done it thousands of time and it always work the same way. http://msdn.microsoft.com/en-us/library/ff798479.aspx


3

If your page is in _layouts folder, you may need to make similar change to {sharepoint root}\TEMPLATE\LAYOUTS\web.config as well. Disclaimer: I would refrain from making a change in this file in production environments.


Only top voted, non community-wiki answers of a minimum length are eligible