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

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

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

If you created your list instance based on a Custom list, which you deploy in another feature (Content types & List definition in feature 1 - Site Collection Scope should be fine), and the list Instances in feature 2 (probably Web Level), then you should add another attribute (FeatureId) to your 2nd feature specifying the Id of the 1st feature. Also do ...


3

I like the idea of hiding all of your features and having one un-hidden feature that activates the hidden ones.


3

The issue is the lists get created after the feature stapling is called in the Site Collection creation process. The My Site is a new Site Collection, not a new subsite, that's why the event receivers don't fire and the manual activation works. I have used a thread pool solution like the one in the link below to delay the execution until the lists have been ...


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

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.


3

You mention that you already have PowerShell scripts to deploy your packages. That is a good start. I would recommend starting from Gary Lapointe's excellent Deploy-SPSolution scripts for this purpose. You should make sure you have configured feature dependencies appropriately for your solution, this will ensure no one can make mistake and activate them in ...


3

If you dont use powerGUI but use powershell.exe: Go to: C:\Windows\System32\WindowsPowerShell\v1.0 Find: powershell_ise.exe.config Change: <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" /> </startup> <...


3

You need to use the Update() method on the SPListItem object. Also, you want the line: listitem["Activated Time"] = DateTime.Now.TimeOfDay; to be simply: listitem["Activated Time"] = DateTime.Now; otherwise you'll get an unhandled exception. This is the code I have, which works (the method being the same one you've selected): SPSite site = SPContext....


3

Try running a check on the parent web to see if the feature is activated. Since this is only applying to sub webs and it is in the FeatureActivated event, it will already be activated on the parent for you to verify. Edit Code added to check if web.ParentWeb != null bool isChild = false; if (web.ParentWeb != null) { foreach (SPFeature parentFeature ...


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