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
Remove feature receiver
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
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 ...
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 ...
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....
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.
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"];
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 ...
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
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);
using (var manager = file.GetLimitedWebPartManager(PersonalizationScope....
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.
If you mean EventReceiver for the feature then you need to attach to the VSSHost process of Visual Studio 2010 which is actually running the code on activation during an F5 deploy.
Another approach would be to set the solution to 'no activation' and then attach the debugger to the process after a F5, activate the feature, now it should hit the feature code.
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.
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 ...
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 ...
A really good explanation is already been given on this blog, so I would suggest you to look at it
Possibly Duplicate Question
detect if a feature is deployed or not
Code of checking if a feature is activated or not
$featureGuid = "PUT-GUID-HERE"
$web = Get-SPWeb http://...
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.
If you know the name of the feature, you can retrieve the feature's definition ID by iterating the SPFeatureDefinitionCollection.
foreach (SPFeatureDefinition featureDef in web.FeatureDefinitions)
if (featureDef.DisplayName == "YourTitle" &&
featureDef.Scope == SPFeatureScope.Web) // Check the scope just to be safe
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.
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
Source: Geoff Evelyn's answer here: https://social.technet.microsoft.com/Forums/en-US/bc53d0ff-b7b4-4cc3-b3e9-87af23f8ba8e/...
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
This seems to me an unnecessarily confusing way of going about things. If you have a feature that depends on another solution I would recommend creating a solution dependency between the "dependency" solution and the solution that contains the dependent feature. Unfortunately that wasn't available in SP2007, so you may have to do something in your deployment ...