Tag Info

Hot answers tagged

10

From your code it would seem that you are trying to set a web-application property from a site collection scoped feature. If you are using SharePoint 2010, I can assume that you are experiencing the effect of the new "RemoteAdministratorAccessDenied" security setting, which among the others by default block any attempt to alter a web app property from a ...


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


6

As EStruyf said, you can change the deployment configuration and debug the code for your Feature Event Receivers. But, you can also attach the event receivers after making sure List is created, so put this code after your list is created. public class Feature1EventReceiver : SPFeatureReceiver { public override void ...


5

Don't do it, you will break your farm. Also, you'll leave it completely unsupported and the next service pack or cumulative update will probably just replace it. What is it you need to do? There'll be a better, supported method for what you want to do without renaming out-of-the-box system files. Edit your question and provide some more information, I'll be ...


4

There an easier way to do this using the SharePoint API: SPWeb web = SPContext.Current.Web; PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web); publishingWeb.CustomMasterUrl = "/_catalogs/masterpage/mycustom.master"; publishingWeb.CustomMasterUrl.SetInherit(true, true); publishingWeb.Update();


4

Short answer: you can't. And why would you create the database using a feature? If you are creating an installer anyway, create the DB there using a db create script or a custom seetup action. As for storing the DB connectionstring and or DB credentials: Use the SecureStore Service Application. See this article for information on how to configure 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

Assuming the feature is at site collection level and your "Site Pages" library is in root web: public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPSite sitecollection = properties.Feature.Parent as SPSite; SPWeb web = site.RootWeb; SPList list = web.Lists["Site Pages"]; ...


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

I would recommend to use the first method - Create the Form in SPD, save it in .aspx and include it in a List definition feature. Benefits Creating the form in SPD and doing the modifications required are pretty much easy. For eg.- Adding a list view web part or modifying an XSLT would be quiet easier in SPD. Now, adding .aspx in a list definition in VS ...


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


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


2

I ran into something similar. The problem is that the InfoPath Form Template is under the element's sub-folder. You need to put the .xsn file in the same folder as Feature.xml. I could not find a way to do this using the SharePoint Project template in Visual Studio 2010. So I used a WSPBuilder project instead.


2

I would try not calling site.RootWeb repeatedly like that. Sometimes in the SharePoint API calling a property like that (e.g. SPList.DefaultView ) actually returns a different object each time. Thus, your call to update is on a different object to the one you updated. I do wonder if that is happening here. Instead, use a variable and pass that around: ...


2

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


2

Take a look at this blog. In the section marked SharePoint Exception Handling: If you only catch and log the exception without throwing the SPException then the feature will complete the requested feature activation or de-activation (which ever the user is currently requesting) instead of aborting the feature activation or de-activation.


2

FeatureActivated is an asynchronous event that happens after the feature was activated. I know of no way to change the activation status except deactivating (SPFeature.Remove(id)) the feature programmatically, but not sure thats what you want...


2

If you are providing "custom.aspx" through your custom solution/feature the most logical place for doing backup of that file is by using SPFeatureReceiver.FeatureDeactivating method. So when you deactivate your feature backup is created and when you again activate it the new file will be provisioned. If you are using modules or if you are providing ...


2

I have tried this code snippet (from console application): using(SPSite site = new SPSite("http://mycoolsite")) { using(SPWeb web = site.OpenWeb()) { SPList list = web.Lists["My List"]; SPField fldTitle = list.Fields["Title"]; fldTitle.Required = false; fldTitle.Title = "New title"; ...


2

Also the dlls are deployed in GAC , so make sure change the settings. Follow this article http://www.sharepointnutsandbolts.com/2007/03/how-to-debug-sharepoint-feature.html


2

I am assuming that the feature is web application scoped. Are you activating the feature through the browser (central admin)? Try activating it from powershell/stsadm instead. I have always found that if i try to modify the web.config, from the process that is using the web.config, things seem to go bad. function New-WebConfigMod { param( ...


2

The WebProvisioned method of the SPWebEventReceiver does not fire when a site collection is created. This is confirmed by the WebProvisioned Method MSDN page. Depending of what your custom code does, it is best to use feature stapling either scoped to Site or Web against the site template you are using.


2

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


2

if you setup workflow manually you should do these steps: Open List settings Tab on ribbon Click on arrow under workflow settings Click on Add workflow Choose your workflow from the list Setup workflow settings


2

You could use SystemUpdate instead of ProcessBatchData. False should mean modified date doesn't change: SPListItem item = ???; item["myField"] = "my value"; item.SystemUpdate(false); Of course, this means you have to update each item one at a time instead of the batch process which may lead to performance issues. See also, how to temporarily disable ...


2

The 3rd option is InfoPath - if you're in such a position in which you can enable the SharePoint -> InfoPath integration features. Especially useful if forms will later be maintained by staff who are more familiar with Word or Office as the UI will be very familiar to them.


2

The ReceiverAssembly should be the Fullname of the assembly FeatureBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx If developing using SharePoint templages in Visual Studio 2010 use $SharePoint.Project.AssemblyFullName$


2

Use the -Force option with -globalassemblycache deployment


2

It seems that your feature is not web application scoped.



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