[Mono-aspnet-list] mvc3 FileCacheProvider Serialize Error reporting

Robert Jordan robertj at gmx.net
Fri Jan 11 14:01:50 UTC 2013


Hi,

The exception is thrown because you're storing non-serializable
objects into the Items property of CacheItem.

Robert

On 11.01.2013 06:09, kevinokay wrote:
> In mvc3,i use FileCacheProvider  to cache page
> FileCacheProvider Set code:
>
>          public override void Set(string key, object entry, DateTime
> utcExpiry)
>          {
>              CacheItem item = new CacheItem(entry, utcExpiry);
>              string path = ConvertKeyToPath(key);
>
>              try
>              {
>                  using (FileStream file = File.OpenWrite(path))
>                  {
>                      BinaryFormatter formatter = new BinaryFormatter();
>                      formatter.Serialize(file, item );
>                  }
>              }
>              catch (Exception E)
>              {
>
> File.AppendAllText(HttpContext.Current.Server.MapPath("1og.txt"),
> E.Message);
>              }
>          }
>
> but catched report error
> Type System.Web.Caching.CachedRawResponse is not marked as Serializable.
>
>
> cacheitem code:
>
>      [Serializable]
>      public class CacheItem
>      {
>          public DateTime ExpiryDate;
>          public object Item;
>
>          public CacheItem(object entry, DateTime utcExpiry)
>          {
>              Item = entry;
>              ExpiryDate = utcExpiry;
>          }
>      }
>
> I am running mono 2.10.8 complied from source on a CENTOS ..
>
> Hope you can help..
>
> Thanks
>
>
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/mvc3-FileCacheProvider-Serialize-Error-reporting-tp4658080.html
> Sent from the Mono - ASP.NET mailing list archive at Nabble.com.
>




More information about the Mono-aspnet-list mailing list