Feature Event Handler called multiple times for Farm level feature - sharepoint 2007

妖精的绣舞 提交于 2019-12-10 23:16:00

问题


I've a farm scoped feature which has an event handler. The feature is activated by default on installation. After I installed the feature I found that the FeatureActivated event has been raised mutiple times (I've three web apps in total excluding central admin and it is called three times).

Because of this the feature deployment is extremely slow (as I'm doing some webconfig modifications for each web application).

Any ideas?


回答1:


I have had a similar problem in the past. I created a static flag in the FeatureReceiver that indicates if it has triggered before.

Dirty, but effective.




回答2:


If you make it a farm scoped feature, then the first install we be easier, sure, but then in 6 months when you create another web application, the settings wont be applied automatically and likely forgotten.

If though, you make it a web application scoped feature with the property ActivateOnDefault="TRUE" in your feature definition, then the feature will be activated in all new web applications when they are created.

http://msdn.microsoft.com/en-us/library/ms436075.aspx

And i hope you are using SPWebConfigModification to make the web.config changes, otherwise if you add new servers to the farm, then the web.config mods wont be applied either.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebconfigmodification.aspx




回答3:


Do you need these web.config changes for all the web apps ? Including central admin ?

The first change I would do is to make it a Web Application scoped feature and selectively activate on required web application.

Also, do not make it Activate by default on installation. If you are deploying through script, have a separate command for activation. That way, you can easily debug if the bottleneck is in deployment or activation.



来源:https://stackoverflow.com/questions/4646646/feature-event-handler-called-multiple-times-for-farm-level-feature-sharepoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!