Tag Info

Hot answers tagged

13

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 ClassOfMine.doYourStuff(web); } not using ...


12

I came across this link by Josh Gaffey that describes how to set the welcome page for a publishing site. The code I used is: ... // Create publishing page if (bPageCreated) { using (SPSite site = new SPSite(p_sSubSiteUrl)) { using (SPWeb web = site.OpenWeb()) { PublishingWeb publishingWeb = null; if ...


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

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


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

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


6

What i usually do is very lo-tech: i use NotePad++ or UltraSeek's "Search In Files" functionality to search for the GUID in question in the FEATURES folder in the 12 hive. That gives me both where it is defined and where it is used.


6

Add a page to the Pages library of your site, name it HomePage.aspx. Add whatever webpart etc. you need to it. Then, in the site settings of the site (_Layouts/AreaWelcomePage.aspx) set the url to point to your custom homepage. Now when someone enters the url of your site (ie. http://mycoolportal.company.local) IIS / SharePoint will point the browser to the ...


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

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.


5

I'm pretty sure that if your assemblies contain feature receivers then they need to be installed into the GAC. There is a post about it here, but in my opinion it doesn't give a good explanation why. My theory is that when you attach a feature receiver to a feature, the assembly needs to be globally available, since FeatureInstalled/Activated etc can be ...


5

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


4

If you have SP2 installed in your environment you could run the preupgradecheck via STSADM e.g. STSADM -o preupgradecheck This will generate a report for you which among other things will list all the features in your environment and give you the feature name and GUID. http://technet.microsoft.com/en-us/library/dd789638.aspx


4

Isn't too difficult really, in the FeatureActivated method, you just create a new SPieldLookup (using SPWeb.Fields.AddLookup() for the SPSite's RootWeb), and set the properties for the SPFieldLookup as required. First time doing it? Bit tricky if you've never made a FeatureReceiver before, let me know if you need a tutorial do that, and here's some sample ...


4

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


4

According to this post How to debug Feature Receiver you can add this line of code to the method you are trying to debug: System.Diagnostics.Debugger.Launch();


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

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


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

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


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.


3

Looks like you have some kind of threading issue here. Standard PowerShell runs each pipeline/line on different threads while the SharePoint PowerShell console runs all in the same thread. Try starting a std PowerShell console and write $Host.Runspace.ThreadOptions = "ReuseThread" And then run your script again and report back. Also make sure that you ...


3

With SharePoint 2010 you shouldn't be creating folders under the SharePoint Root (14 folder) directly, nor manually copying files to the GAC. You should be using Visual Studio 2010 to handle folder creation. If you don't have access to that, use WSPBuilder to create solution files which will be uploaded and deployed to each web front end in your farm. As ...


3

The Site Collection feature Office Publishing Infrastructure must be enabled first. It can only be enabled by someone with Site Collection Admin privledges. Once that is enabled, the site feature can be enabled.


3

It sounds like you want to use Feature Stapling to bind your feature to new sites.


3

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


3

Don't you need an Assembly node in your Elements.xml?


3

Found the answer: The problem really was that the exception was being thrown within the delegate. Hence the FeatureActivated just ran smoothly and the feature seemed activated. Fortunately SPLongOperation can be instantiated with a Page: new SPLongOperation(Page page) - problem is that in a Feature Receiver i don't have this.Page. I found the beautiful ...


3

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



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