views:

452

answers:

3

All,

I'm working on a SharePoint project, but this isn't a SharePoint-specific question per-se. I have an assembly I've deployed to a SharePoint farm, and I'd like to verify whether my "newest version" is sitting in the GAC, or if an older version from late yesterday is sitting there instead. This is a test farm, so yes, we are revving versions constantly.

Without doing anything crazy like changing the assembly version itself every time I compile*, is there some assembly property I can check (or set at compile-time)?

*I should clarify, in SharePoint projects we hardcode the assembly's full name in multiple places (including XML files), so changing the assembly version is a less savory option than you might think.

+5  A: 

Assembly Version is the intended mechanism for this, but you could roll your own by comparing an MD5 hash of the GAC assembly with the MD5 of your latest version.

Ed Guiness
Should have thought of MD5 hash, it sounds obvious now :), thanks
Peter Seale
Assembly version has to stay the same unless you want to get into a chain of assembly binding redirection (the 'correct' way but a total PITA). Look at AssemblyFileVersion to save yourself a headache.
Ryan
+4  A: 

You could use AssemblyFileVersion attribute. From the docs, the AssemblyFileVersion

Instructs a complier to use a specific version number for the Win32 file version resource. The Win32 file version is not required to be the same as the assembly's version number.

Rob Windsor
+3  A: 

You might also want to look at assembly binding redirection. Basically you can put a few settings in the web.config or app.config to tell your app (SharePoint in this case) to use a specific version number:

More info: http://msdn.microsoft.com/en-us/library/7wd6ex19(VS.71).aspx

It may not be the solution for this case, but it might prove useful in the future. I particularly found it useful when dealing with custom SharePoint solutions.

Lloyd Cotten