Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enyim.Caching.SerializationException #5

Open
luismx opened this issue Dec 10, 2019 · 2 comments
Open

Enyim.Caching.SerializationException #5

luismx opened this issue Dec 10, 2019 · 2 comments

Comments

@luismx
Copy link

luismx commented Dec 10, 2019

I'm not able to run the basic implementation, the next exception appears:
Enyim.Caching.SerializationException: 'Exception 'Type '<>f__AnonymousType0`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' in Assembly 'MemCached2App1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.' while serializing '{ hello = world }'. See inner exception for details.'

This exception was originally thrown at this call stack:
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(System.Type) in FormatterServices.cs
System.Runtime.Serialization.FormatterServices.GetSerializableMembers.AnonymousMethod__5_0(System.Runtime.Serialization.MemberHolder) in FormatterServices.cs
System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue>.GetOrAdd(TKey, System.Func<TKey, TValue>) in ConcurrentDictionary.cs
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(System.Type, System.Runtime.Serialization.StreamingContext) in FormatterServices.cs
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() in BinaryObjectInfo.cs
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(object, System.Runtime.Serialization.ISurrogateSelector, System.Runtime.Serialization.StreamingContext, System.Runtime.Serialization.Formatters.Binary.SerObjectInfoInit, System.Runtime.Serialization.IFormatterConverter, System.Runtime.Serialization.Formatters.Binary.ObjectWriter, System.Runtime.Serialization.SerializationBinder) in BinaryObjectInfo.cs
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(object, System.Runtime.Serialization.Formatters.Binary.BinaryFormatterWriter, bool) in BinaryObjectWriter.cs
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(System.IO.Stream, object, bool) in BinaryFormatter.cs
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(System.IO.Stream, object) in BinaryFormatter.cs
Enyim.Caching.Memcached.BinaryItemFormatter.DoSerialize(Enyim.Caching.SequenceBuilder, object)
...
[Call Stack Truncated]

Using the .Net Core 3.0, VS 2019

@blackorzar
Copy link

Hello, I got the same error when trying to setup the library on ASP.Net Core project of Web API type, including the library in a Controller.
In Startup.cs I added:

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMemcached("localhost");
            services.AddControllers();            
        }

In the Controller I added:

        [HttpGet]
        public async Task<IActionResult> GetAsync()
        {
            var client = _memcachedCluster.GetClient();
            await client.SetAsync("hello", new { hello = "world" });
            return Ok(new { hello = "world" });
        }

@Fabman08
Copy link

Same error also for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants