Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
218 views
in Technique[技术] by (71.8m points)

.net - SharePoint features: How can I use wildcard assembly versioning?

I think this is likely to be a generic .NET assembly loading question, but in my specific case, I want my SharePoint Features to point to an assembly whose versioning is associated with the correct SVN revision number.

My assemblies are now versioned as mentioned in this article. I'd like to be able to just configure my SharePoint features to use the latest version of the assembly that's in the GAC.

<Feature Id="7b5d86e8-17dc-4943-8f4e-ad1068daf4f9" 
         Title="My happy feature" 
         Scope="Web" 
         Version="1.0.0.0" 
         Hidden="FALSE" 
         DefaultResourceFile="core" 
         ReceiverAssembly="HappyFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d772fbab82fe6896"
         ReceiverClass="HappyFeature.Receivers.HappyItemEventReceiver"
         xmlns="http://schemas.microsoft.com/sharepoint/">
</Feature>

When I do this, SharePoint of course cannot find the assembly because the strong name doesn't match up with the 1.0.0.0 version described in here. My current version in my assembly is 1.0.4479.26553, so I'd like my features to be able to automagically find similarly numbered assembly versions. How can I do this?

I somewhat naively tried something like this:

ReceiverAssembly="HappyFeature, Version=1.0.*, Culture=neutral, PublicKeyToken=d772fbab82fe6896"

and

ReceiverAssembly="HappyFeature, Version=1.0.*.*, Culture=neutral, PublicKeyToken=d772fbab82fe6896"

But when I try to deploy my solution as such, it still seems to be looking for a file with the 1.0.0.0 version:

Feature '7b5d86e8-17dc-4943-8f4e-ad1068daf4f9' could not be installed because the loading of event receiver assembly "HappyFeature, Version=1.0.., Culture=neutral, PublicKeyToken=d772fbab82fe6896" failed: System.IO.FileNotFoundException: Could not load file or assembly 'HappyFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d772fbab82fe6896' or one of its dependencies. The system cannot find the file specified. File name: 'HappyFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d772fbab82fe6896'

What's the proper way to coerce the framework to load my incremented-version feature assemblies?


EDIT: So, while I didn't actually solve the specific question I'd asked, Ryan's suggestion solved my practical problem of just being able to tag my assemblies with SVN-related information while retaining the ability to successfully load my assemblies in the SharePoint FeatureReceiver world.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

What you could do is keep the AssemblyVersion the same (at least whilst its a 'compatible major version') but use the same technique to put the SVN revision number into the AssemblyFileVersion property.

Then you won't have to keep updating Publisher Policy files.

KB556041 - How to use Assembly Version and Assembly File Version

Suppose you are building a framework assembly for your project which is used by lot of developers while building the application assemblies. If you release new version of assembly very frequently ... and if assemblies are strong named, Developers will have to change the reference every time you release new assembly ... A better option in such closed group and volatile scenarios would be to fix the 'Assembly Version' and change only the 'Assembly File Version'.

SO - What are the differences between AssemblyVersion and AssemblyFileVersion


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...