Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I got a monitoring page where I show the version of all web parts, features etc.

If I use features with Event Receiver I can easily get the version. If the Feature has no event receiver I solved that by adding ReceiverAssembly="$SharePoint.Project.AssemblyFullName$" into the template.xml file.

This is the way I get the AssemblyFileversion of a solution

foreach (SPFeature feature in SPContext.Current.SiteFeatures)   
{
   string receiverAssembly = feature.Definition.ReceiverAssembly;
   object[] attributes = receiverAssembly.GetCustomAttributes(false);
   foreach (object attribute in attributes)
   {
      if (attribute is System.Reflection.AssemblyFileVersionAttribute)
      {
         return  ((System.Reflection.AssemblyFileVersionAttribute)attribute).Version;
      }
   }
}

All Fine. Now I got WebParts etc that have no Feature at all. If I create an object within one of that wsp manually I can get that information:

Log log = new Log();             
string toolVersion = GetAssemblyFileVersion(log.GetType().Assembly);      

("Log" is a class within a project without a feature)

So now I need the following: How do I get ALL WSPs without a feature and get the AssemblyFileVersion of that WSPs?

share|improve this question
    
maybe this link is helpful: novolocus.com/2011/05/18/assembly-versioning-in-sharepoint –  CodingSheep May 31 '12 at 13:09
    
That Link helped getting the AssemblyFileversion of the CURRENT object. What I already achieved (The "log"-Part above) –  Ole Albers May 31 '12 at 13:15

2 Answers 2

up vote 0 down vote accepted

Ole,

Depending on the complexity you can afford, one option might be to just plit open the WSPs in the solution store (or wherever you have them), extract the DLLs, and load them.

.b

share|improve this answer

A WSP could contain zero or more assemblies. Thus, not all WSPs would contain an assembly to get an AssemblyFileVersion from.

What I tend to do for those is just deploy a text file somewhere (like a subdirectory of Layouts) with version information in it.

Also, a WSP could contain multiple assemblies, and not all of those would necessarily be used directly by features (as you note).

The best that I can suggested is that you'd have to retrieve the actual WSP files for each Farm and Sandbox solution in the farm, unpack them, and look for .dll files, which sounds like a) a lot of work, and b) possibly tricky from a security standpoint.

Personally, I tend to simply output the assembly file version in an HTML comment in my web parts.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.