Base solution for your next web application
Open Closed

Unable find assembly EntityFrameworkDynamicProxies-Abp.Zero #1846


User avatar
0
rajanbhayana created

We have a subscription with aspnetZERO but not able to post there.

We have a project on version .7.7.2

We wanted to enable redis caching as we have a distributed environment. I read in one of your comment that there was some issue in abp.rediscache .7.7.2 and we should move to .7.8.x version We did that and updatde preinitialize in web module as below and we got no build error.

using Abp.Runtime.Caching;

namespace DC4.Web { /// <summary> /// Web module of the application. /// This is the most top and entrance module that dependens on others. /// </summary> [DependsOn( typeof(AbpWebMvcModule), typeof(DC4DataModule), typeof(DC4ApplicationModule), typeof(DC4WebApiModule), typeof(AbpRedisCacheModule))]

........................................

IocManager.Register<ICacheManager, AbpRedisCacheManager>();

After build, when i load the page, i get the following error.

ERROR 2016-10-21 09:46:58,322 [6 ] DC4.Web.Controllers.AccountController - System.Runtime.Serialization.SerializationException: Unable to find assembly 'EntityFrameworkDynamicProxies-Abp.Zero, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name) at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at Abp.RedisCache.RedisImpl.SerializeUtil.Deserialize(Byte[] data) at Abp.RedisCache.AbpRedisCache.GetOrDefault(String key) at Abp.Runtime.Caching.CacheBase.GetOrDefaultAsync(String key) at Abp.Runtime.Caching.CacheBase.<GetAsync>d__1.MoveNext()

i even tried this in dbcontext constructor but it did not work.

Configuration.ProxyCreationEnabled = false;

Please help. Thanks.


7 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    First of all, it's not a good idea to store entities in the redis cache. Because entities can always have serialization problems (related to lazy loading, proxying or navigation properties). Even if you serialize and cache it, there may be other problems after getting it from the cache (because it will be out of dbcontext). These problems are not directly related to ABP framework.

    So, create a DTO-like cache item which is marked as [Serializable] and contains only needed properties. Then map your entity to that cache item and store it.

    BTW, your ABP version is very old. Consider to upgrade to ABP v1.0 when you have time.

    Have a nice day.

  • User Avatar
    0
    rajanbhayana created

    we cant upgrade to version 1

    how do we solve this error in a distributed environment without moving abp cache to redis??

    500 Error! Impersonation token is invalid or expired!???

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You dont have to upgrade to ABP 1.0, it was just a suggestion. The solution of your problem is:

    First of all, it's not a good idea to store entities in the redis cache. Because entities can always have serialization problems (related to lazy loading, proxying or navigation properties). Even if you serialize and cache it, there may be other problems after getting it from the cache (because it will be out of dbcontext). These problems are not directly related to ABP framework.

    So, create a DTO-like cache item which is marked as [Serializable] and contains only needed properties. Then map your entity to that cache item and store it.

  • User Avatar
    0
    rajanbhayana created

    sorry not getting this.

    the issue is here in abp code when i debug.

    var cacheItem = await _cacheManager.GetImpersonationCache().GetOrDefaultAsync(tokenId); if (cacheItem == null) { throw new UserFriendlyException(L("ImpersonationTokenErrorMessage")); }

    when i check GetImpersonationCache(), it is returning ImpersonationCacheItem which is already marked as serialized. so not sure what to change here. public static ITypedCache<string, ImpersonationCacheItem> GetImpersonationCache(this ICacheManager cacheManager) { return cacheManager.GetCache<string, ImpersonationCacheItem>(ImpersonationCacheItem.CacheName); }

    I thought the issue was the abp cache here is not distributed like redis but local, and sometimes when request was going to another server in load balancer where cache was not stored for this user session, we got null token in between request and moving this to redis would have solved this.

    so i tired to move abp cache to redis and i am getting the error in post#1. so how to get around this?

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Actually it uses cache manager and when you replace redis, it will use the redis. Are you using single redis cache server and did you properly configured your application to use this single redis cache server (see configuration: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Caching#redis-cache-integration">http://www.aspnetboilerplate.com/Pages/ ... ntegration</a>)?

  • User Avatar
    0
    rajanbhayana created

    please see the notes above. thats how we setup redis for cache manager.

    but we get the error when loading page as per post#1 how to fix that?

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Since your ABP version is too old, it's hard for me to reproduce the problem. When we enable redis cache in our project, we have no such a problem. How can I repeat the problem? Did you make s special config, or just using Abp and Abp.Zero and enabled redis cache.