NHibernate.Caches.EnyimMemcached, protobuf-net.Enyim want conflicting versions of Enyim.Caching
I am trying to hook up NHibernate to use the Enyim.Memcached provider to cache it second level. Also, I want Enyim.Memcached to use protobuf-net as its serializer.
Looking at nuget and on the internet I can find pretty much every item I need:
NuGet:
-
protobuf-net.Enyim
-
protobuf-net
(dependency protobuf-net.Enyim) -
EnyimMemcached (Enyim.Caching)
v2.12 (dependency protobuf-net.Enyim)
web: ( http://sourceforge.net/projects/nhcontrib/files/NHibernate.Caches/ - I couldn't find a nuget package for NHibernate.Caches.EnyimMemcached)
-
NHibernate.Caches.EnyimMemcached
-
Enyim.Caching
v2.3
However, when I plug everything in, I get an error The located assembly manifest definition does not match the assembly reference.
. The problem is this:
-
NHibernate.Caches.EnyimMemcached
wantsEnyim.Caching
v2.3 -
protobuf-net.Enyim
wantsEnyim.Caching
v2.12
They don't play well. I tried to add assembly redirection but to no avail:
<dependentAssembly>
<assemblyIdentity name="Enyim.Caching" publicKeyToken="cec98615db04012e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.3.0.0" newVersion="2.3.0.0" />
</dependentAssembly>
The "latest" build of Enyim.Caching (via the EnyimMemcached package) only has v2.12. D'oh! 2.12 is more recent than 2.3. (Thanks for pointing that Mark!)
Any thoughts? Is there a NHibernate.Caches.EnyimMemcached nuget package that I am not aware of? Or protobuf-net.Enyim, which uses 2.3 instead of 2.12? I cannot imagine that I am the only one who tried to use this NHibernate-Enyim-Protobuf-net stack. And I'm surprised that assembly-bound redirection didn't fix the problem.
UPDATE: I will well agree to follow Mark's advice. I just downloaded the NHibernate.Caches.EnyimMemcached source and changed the link to Enyim.Caching from unsigned v2.3 assembly to 2.12 signed assembly. All the sauce!
source to share
"only has v2.12" - it helped me for a second, but 2.12 is much later than 2.3; 2.7 - January 2011; 2.12 - October 2012. I can't seem to get 2.3 at all (even with command line tools). There is no such thing as "only ... v2.12", i.e. at the time of writing, v2.12 is the most recent version.
The simplest thing I can suggest, however, is to try and build the protobuf transcoder by hand, directly referencing the version NHibernate is working with.
There seems to be some ... oddity surrounding the enyim tool; There are at least 2 different versions in the wild (with different strong names IIRC) - and they even have several different interfaces ( Int16
vs Int32
in several places, and Flag
vs Flags
, from memory), may, NHibernate uses the "other". I went with a build from nuget; but if it is "wrong" I am glad to overestimate it.
Edit:
I downloaded NHCH-3.2.0.GA-bin.zip from your link and used sn -T <path>
to verify the public key; this gives:
{path removed} \ Enyim.Caching.dll is not a strongly named assembly
Then I tried this with a version recently downloaded from nuget via Install-Package EnyimMemcached
which gives:
Public key token - cec98615db04012e
So, at some point between 2.3 and 2.12, he started using a strong name.
This means that these dlls will always have a fundamentally different identity and can never be interchangeable. Unfortunately, there is nothing I can do about it. If you cannot update NH, you will have to do a local build of the protobuf tool against a non-strong named DLL. If you're having trouble generating it related to a missing item Flags
, try changing your code locally to Flag
.
Personally, if it were me, adding, removing, or changing a public key token deserves a "major" version upgrade, that is, a move to 3.0; since this is fundamentally a violation of the changes.
source to share