7

Your plan is good, and respects good practices (at least the practices I've been following for ages). Your approach is to: Create the solution in VS Create one feature (scope: Web) Create two classes for the event receivers (both inheriting from SPItemEventReceiver) Add a feature event receiver on the feature (inheriting from SPFeatureReceiver) In the ...


4

The code compiles and runs fine for me as long as there is a reference to Microsoft.SharePoint (2010). Are you building a console application? In that case make sure you are using the .NET 3.5 framework (not compact or anything else) and set the platform target to Any CPU in the build section of the project properties. BTW. note that you are leaking a site ...


3

If I remember correctly the flow is: Site Collection Scoped Features Web Scoped Features Lists Modules Your stapled features would be shot in after Site collection scoped features or Web scoped features (depending on scope) and hence the lists is not guaranteed to be created before the lists. Found a source here: http://blogs.msdn.com/b/chrischiaro/...


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 ...


3

Looks like it is a DLL caching issue. When you start Powershell command line window, it loads all DLLs available in the GAC. So, if you have updated DLL for the feature receiver, and deploying it within the same PS session then it will not reload updated DLL. I had experienced similar behaviour before. To tackle it, I created two seperate PS1 files. First ...


3

Well. It really depends on which feature you have to activate. The id of a feature does not change during its life. This means that if you can find out the id you will be sure it stays the same, regardless of the specific SharePoint farm instance. That said, you can "hardcode" your ID in a support class, much like SharePoint does with fields id in the ...


3

My solution to the problem was to change assembly version from 1.0.0.0 to 1.0.0.1 and build the SharePoint project. After that I deleted feature receiver and added feature receiver again so that feature manifest XML file gets updated with correct version of feature receiver assembly. More details on http://slavensemper.blogspot.hr/2015/08/failed-to-load-...


2

I dont think you will need Event Receiver for your purpose, please find this thread of stackexchange SP 2010 Custom Access Denied Pages For help with command you may find this MSDN Article helpful For details steps please go through this Customize the Access Denied Page


2

Use the -Force option with -globalassemblycache deployment


2

Please check this link to see how to set your home page. If this does not work, please try to debug and check if your FeatureActivated event gets fired. Hope this helps Cheers! My bad that I did not see that. Anyways can you please try below, Please use this in feature activating, SPWeb web = properties.Feature.Parent as SPWeb; if (web != null) ...


2

I'm not sure this will work, but I would try this: public override void FeatureActivated(SPFeatureReceiverProperties properties) { //Get webapplication SPWebApplication webApplication = properties.Feature.Parent as SPWebApplication; //Get current user from any sitecollection and rootweb SPUser user = webApplication.Sites[0].RootWeb....


2

If your class is: in the same project inherits from SPFeatureReceiver is public has the right [Guid(xxx)] attribute then it should work, but I would consider it a bad practice. A better solution woulc be to have two destinct feature receivers calling common functions, then if at some point you need to differentiate (could be in regards to FeatureUpgrading),...


2

I found the problem: my solution was in Sandboxed mode! Changed the "Sandboxed solution" project's property to False and now it compiles :)


2

You are using the rootweb of the site, not the current web, so any changing you are making is always to the rootweb. Instead of using webTemp to get rootweb, just use webTemp as the web. private const string QuicklaunchHeader = "Saksmappe"; public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = properties.Feature....


2

All Ended up getting things to work After getting SPSite site = properties.Feature.Parent as SPSite; I found out that all I needed to do was add the rest of the url which was could be something like "/NewPage" to the rest of the url since I already had the full site url from the properties. Created a method that passed in the site and the weburl to get my ...


2

Often this is due to the SPTimerV4 holding a cached reference to your solution .dll:s try do net stop SPTimerV4 net start SPTimerV4 in PowerShell or cmd when you have retracted your .wsp before reinstalling them


2

You should be able to use event recievers to do this, more specifically the SPWebEventReciever. From Microsoft: An event receiver is a piece of managed code that responds to SharePoint events when specific triggering actions occur on a SharePoint object. Triggering actions include activities such as adding, updating, deleting, moving, checking in, and ...


2

You should use Delete() method of SPWeb.Lists SPWeb webSite = properties.Feature.Parent as SPWeb; SPList myCustomList = mySite.Lists["MyCustomList"]; mySite.Lists.Delete(myCustomList.ID); mySite.Update(); You should also create a new SPSite object while running a code as elevated privileges: SPSecurity.RunWithElevatedPrivileges(delegate() {...


2

I would suggest that you break the whole thing into two features, first one to deploy the List Template and second one to create the instance of the list based on template.. On the later one, you will need to define Feature Activation Dependency of List Template feature.. Both features can be hidden and you just need to activate the Feature that creates ...


2

Make sure to not use SPContext.Current in the FeatureReciever, this will be NULL in powershell (due to lack of HttpContext basically). This is one of the most common cause of errors in FeatureReceivers


2

Looks like your master page is being used by device channels throughout your sites. Microsoft doesn't provide a public API for viewing or modifying the configured master pages for a device channel. With that said, in my book (SharePoint 2013 WCM Advanced Cookbook: http://tinyurl.com/lutktay), I have some samples on how to view and modify the configured ...


2

I don't know if this is the best way to fix this problem but I was able to resolve the issue by manually editing the __DeviceChannelMappings.aspx on the Feature Deactivation. This will release the mappings to the custom master page and allow it to be deleted. Here is the final code: public class PulseMasterPageEventReceiver : SPFeatureReceiver { ...


2

By looking into your code, i think the problem is item.Delete(); item.Update(); You are updating item after you are deleting, there is no need to update the item after delete. You can not update a deleted item.


2

as far as I know retracting solutions doesn't deactivate their features, so although you wont be able to find or activate/deactivate those features, their references are still there. on the particular case of event receivers, it could turn out to be a major problem. the receiver may still be attached and if you redeploy/reactivate you may end up with firing ...


2

The visual web part should be included to the Site-scoped feature, as a result properties.Feature.Parent is a SPSite object. You need to check feature scope and use the code below if the scope is site. SPSite site = properties.Feature.Parent as SPSite; if (site != null){ SPWeb web = site.RootWeb; SPList laptopList = web.Lists["Laptops"]; ... }


2

The problem you would have is timing, the field must have been created before you provision your content type. So the FeatureActivated is a no go. I would not go for FeatureInstalling either since you can not control with ease the execution order. I sometimes uses the FeatureActivated event, but in those cases I create both content type, fields, and binds ...


2

changing out the project’s strong key assembly worked in this particular case. If you haven’t had to change this before, it is under the properties of the project -> Signing. Under ‘Choose a strong name key file’, select New. The password is optional.


2

The SharePoint Timer Windows Service (SPTimerV4) may be holding a copy of your DLL in memory and you need to flush it by restarting that Windows service.


2

In CSOM Feature Object, there is no "FeatureDefinitionScope", please check the documentation: Feature properties If you are using SharePoint On-Premise Environment, you can use the Server Object Model below to get this property: SPSite site = new SPSite("http://sp/sites/dev/"); SPWeb web = site.OpenWeb(); foreach (SPFeature feature in site....


2

With your code, you will only retrieve all features with scope "Web". There is actually a difference between features scoped to a site ("Web" class) or to a site collection ("Site" class). The following adjusted code retrieves all active features for the site collection and the site: string siteUrl = "http://MyServer/sites/MySiteCollection"; ClientContext ...


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