How to update SPItemEventReceiver assembly version for a list in SharePoint?

心已入冬 提交于 2019-12-06 08:59:18

Maybe you can encapsulate the logic that is prone to change into a separate assembly, that is referenced and used by your event handler. This way, the event handler itself won't change have to change, you would only deploy the updated "logic" assembly to the GAC or bin directory(ies) appropriately.

HTH, jt

I am not sure what you want with the upgrade, whether you want the new event handler to be applied to old lists or just for new lists.

For upgrading just new lists you could put the assembly information in a separate file, read that file in your FeatureActivated method, and apply the new values. When upgrading all you need to do is to update the separate config file and any new activation will use the new values and version numbers.

If you need to upgrade old event handlers you could do a similar procedure, but add the new feature receiver before you delete the old. If you do this in the same method the time between adding the new handler and removing the old will be minimal and the chance of anyone adding an item at that exact time is close to zero. If you want to go all the way to zero, you can hide the list or have an additional ItemUpdated event handler that checks to see if an upgrade is in progress and if so halts the update.

So, in short: For new lists, read assembly config from external file For old lists, add upgraded assembly info just before removing the old handler.

.b

I only use assembly versioning if there's a need for both (old and new) versions of the assembly to be executed. I never needed this on an event receiver. Therefore, I don't change the assembly version for event receivers.

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