Whilst developing web parts our team came across some interesting phenomenon, mainly that if you version your web parts using standard .Net assemblyVersion then upgrades work fine as Sharepoint would automatically upgrade the internally held dwp files for every occurrence of the web part you may have in Sharepoint.

 

This is fine moving forward, a little unnerving perhaps but fine.  What we did discover is that if you had to roll-back that version then too late you can’t as in an uninstall scenario the dwp’s are not updated.

 

We wondered why you would need to update dwp’s in Sharepoint at all if you GAC things and use version redirection or policy files.  But this is the way it works.

 

A colleague researched this more thoroughly than I’m describing here (Dan Woolstencroft) but after a lot of searching and an email conversation with Tariq, we came to the conclusion that we should not version web parts. We leave the version at Version 1.0.0.0.

 

This leaves you with a dilemma what is the version number of your part.  I came up with a way to do this, it’s not perfect as only those who can view the tool pane for that web part can see the version number, but however the only people who need to know are those who can see the tool pane.

 

I created a ToolPart to display an attribute of WebPartVersion, Here is the code, it has a few parts to it and is part of my web part base  so the code listed is for inclusion in the WebPartBase Project but you should be able to adapt it easily if you don’t want it like this.

 

The code was pulled from here and placed in a later post with more functionality and tested it can be found in this post

http://blog.binaryjam.com/PermaLink,guid,fa61431f-ecb8-4696-91dc-62a9c0454715.aspx

 

 

Advertisements