Search code examples
c#sharepoint-2010solid-principles

SharePoint deploy reusable code


I just inherited a SharePoint project that I want to refactor and take all the common/reusable code and place it in a seperate project within the solution. The solution already has several projects, and almost all of the projects have dependencies between one or more other projects in the solution.

I want all of the depencies (SPMetal classes, static methods, utils, etc) to be put into one project so that there is only one reference needed for common code (and no code clones)

I refactored the project, and now I am trying to deploy this code to the SharePoint server (Both my local dev server through VS2012 and to the production server through WSPs). I initially tried to add the Common.dll in all of the other project's "Additional Assemblies" list (in the Package file), but this has caused all of the WSPs to fail deployment with the following error:

Cannot add the specified assembly to the global assembly cache

This is because the Common.dll is in use by the owstimer and some other services and can't be removed.

My next thought was to deploy the code as a feature and then make all of the other features dependent upon it, however, I don't know how to do this. Is there any way to have a feature that only contains classes?

Is there a better way to make common code available to multiple SharePoint projects?


Solution

  • Based on error it looks like you did not strongly signed the "Common.dll" assembly. As result it can't be installed in the GAC.