protobuf-net transcoder for EnyimMemcached problem

2019-02-18 17:10发布

问题:

Is the transcoder from protobuf-net to enyim cache deprecated? distributed caching with protobuff-net

Setting my Enyim config just like this app.config causes an error when I try to start the MemcachedClient() The same for using

transcoder type="ProtoBuf.Caching.Enyim.NetTranscoder"/

System.TypeInitializationException was unhandled by user code
HResult=-2146233036
Message=The type initializer for 'Enyim.Caching.MemcachedClient' threw an exception.
Source=Enyim.Caching
TypeName=Enyim.Caching.MemcachedClient
StackTrace:
   at Enyim.Caching.MemcachedClient..ctor()
   at Global.asax.cs:line 31
InnerException: System.Configuration.ConfigurationErrorsException
   HResult=-2146232062
   Message=The value of the property 'transcoder' cannot be parsed. The error is: Object reference   not set to an instance of an object. (\web.config line 207)
   Source=System.Configuration
   BareMessage=The value of the property 'transcoder' cannot be parsed. The error is: Object reference not set to an instance of an object.
   StackTrace:
        at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
        at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
        at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
        at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
        at System.Web.HttpContext.GetSection(String sectionName)
        at System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName)
        at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey)
        at System.Configuration.ConfigurationManager.GetSection(String sectionName)
        at Enyim.Caching.MemcachedClient..cctor() in MemcachedClient.cs:line 25
   InnerException: 

Both installed via nuget and using the latest version available.

回答1:

Yes (cough), of course that's there! Just see "protobuf-net.Enyim", i.e.

PM> Install-Package protobuf-net.Enyim

(or use the GUI client)

To initialize, you need to configure the transcoder to be an instance of ProtoBuf.Caching.Enyim.NetTranscoder (as per the original instructions). If you are doing this via configuration, note that the assembly for this type is now protobuf-net.Enyim. If I assume the configuration file uses standard notation, then that means you would need to specify (in the config):

<transcoder type="ProtoBuf.Caching.Enyim.NetTranscoder,protobuf-net.Enyim" />

Original answer:

The enyim transcoder is not currently in nuget; however - I will right now take it upon myself to resurrect that, by adding a separate NuGet package (reference EnyimMemcached and protobuf-net) that adds this back in.

Random question... any chance you can point me at a binary memcached download for testing?

One reason this has lagged is that when I first wrote the enyim transcoder, memcached was a simple "run this" - but last time I looked it had gone all "enterprisey", and I couldn't track down a simple package that just had the memcached server. If you can show me where that is now, I'll get it working this weekend.