문제

I'm trying to wire up NHibernate to use the Enyim.Memcached provider for its second-level caching. Additionally, I want Enyim.Memcached to use the protobuf-net as its serializer.

Looking at nuget and the web, I can find pretty much all the pieces I need:

nuget:

  • protobuf-net.Enyim
  • protobuf-net (dependency of protobuf-net.Enyim)
  • EnyimMemcached (Enyim.Caching) v2.12 (dependency of 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 wire everything up, I get a The located assembly's manifest definition does not match the assembly reference. error. The issue appears to be:

  • NHibernate.Caches.EnyimMemcached wants Enyim.Caching v2.3
  • protobuf-net.Enyim wants Enyim.Caching v2.12

They don't play nice. I tried adding an assembly redirect, 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" Enyim.Caching assembly (via the EnyimMemcached package) only has v2.12. D'oh! 2.12 is more recent than 2.3. (Thanks for pointing that out Marc!)

Any thoughts? Is there a NHibernate.Caches.EnyimMemcached nuget package I don't know about? Or a protobuf-net.Enyim that uses 2.3 instead of 2.12? I can't imagine I'm the only one that has tried to use this NHibernate-Enyim-Protobuf-net stack. And I'm surprised the assembly binding redirect didn't fix the issue.

UPDATE: I'm good to go after following Marc's advice. I simply downloaded the source of NHibernate.Caches.EnyimMemcached and changed its Enyim.Caching reference from the unsigned v2.3 assembly to the signed 2.12 assembly. Everything's gravy!

도움이 되었습니까?

해결책

"only has v2.12" - this tripped me for a second there, but 2.12 is much more recent than 2.3; 2.7 is Jan 2011; 2.12 is Oct 2012. I don't seem to be able to get 2.3 at all (even via the command-line tools). There is no such thing as "only ... v2.12", ecause at the time of writing, v2.12 is the most recent version.

The simplest thing I can suggest, though, is to try building the protobuf transcoder manually, directly referencing whichever version it is that NHibernate works with.

There seems to be some... oddness surrounding the enyim tool; there are at least 2 different versions in the wild (with different strong names IIRC) - and they even have slightly different interfaces (Int16 vs Int32 in a few places, and Flag vs Flags, from memory). It could be that NHibernate is using the "other" one. I went with the build from nuget; but - if this is the "wrong" one, I'm happy to re-evaluate that.

Edit:

I downloaded NHCH-3.2.0.GA-bin.zip from your link, and used sn -T <path> to check the public key; this gives:

{path removed}\Enyim.Caching.dll does not represent a strongly named assembly

I then tried this with the version freshly downloaded from nuget via Install-Package EnyimMemcached, which gives:

Public key token is cec98615db04012e

So basically, at some point between 2.3 and 2.12, it has started using a strong name.

This means that these dlls will always have fundamentally different identity and can never be interchangeable. I can't do anything about that, sadly. If you can't update NH, then you will have to do a local build of the protobuf tool against the non-strong-named dll. If you get problems building it relating to a missing member Flags, try changing the code locally to Flag.

Personally, if it had been me, adding, removing or changing the public key token is worthy of a "major" revision update - i.e. going to 3.0; since that is fundamentally a breaking change.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top