H,
I am using the Windows Azure AppFabri Caching.
I have two project in asp.ne t .
One to put data in cache and 2nd to read that cache. These Two project are running on 2 different systems.
I have 4 dll included in these projects.
Poject 1: To insert data in cache is using the following code:Data is saving to cache successfully
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.ApplicationServer.Caching;
public partial class Default2 : System.Web.UI.Page
{
public class Employee
{
public string Name { get; set; }
public decimal Salary { get; set; }
Now I am reading the cache in another project that is running on another system.
Code is given below:
default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.ApplicationServer.Caching;
An error is generating on the line _cache.Get(key)
The deserializer cannot load the type to deserialize because type 'System.Collections.Generic.List`1[[_Default2+Employee, App_Web_4xzswv4j, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]' could not be found in assembly 'mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'. Check that the type being serialized has the same contract as the type being deserialized and the same assembly is used.
Why this error is coming?
How can Can I uses Classes as List collection to add/read in Cache.
dalvirsaini
Member
46 Points
50 Posts
How to use classes as List Collection in Azure AppFabri Caching
Jul 21, 2011 12:06 PM|LINK
H,
I am using the Windows Azure AppFabri Caching.
I have two project in asp.ne t .
One to put data in cache and 2nd to read that cache. These Two project are running on 2 different systems.
I have 4 dll included in these projects.
Microsoft.WindowsFabric.Common.dll
Microsoft.WindowsFabric.Data.Common.dll
Microsoft.ApplicationServer.Caching.Client.dll
Microsoft.ApplicationServer.Caching.Core.dll
Poject 1: To insert data in cache is using the following code:Data is saving to cache successfully
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.ApplicationServer.Caching;
public partial class Default2 : System.Web.UI.Page
{
public class Employee
{
public string Name { get; set; }
public decimal Salary { get; set; }
}
protected static DataCacheFactory _factory = null;
protected static DataCache _cache = null;
protected void Page_Load(object sender, EventArgs e)
{
PutDataIntoCache();
}
protected void PutDataIntoCache()
{
List<Employee> emp = new List<Employee>();
try
{
emp.Add(new Employee { Name = "James", Salary = 20000 });
PutCacheItem("55", emp);
}
catch (Exception ex)
{
}
}
protected void PutCacheItem(string key, object value)
{
try
{
_cache = GetDefaultCache();
_cache.Put(key, value);
}
catch (Exception ex)
{
}
}
protected static DataCache GetDefaultCache()
{
_factory = new DataCacheFactory();
_cache = _factory.GetDefaultCache();
return _cache;
}
}
Now I am reading the cache in another project that is running on another system.
Code is given below:
default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.ApplicationServer.Caching;
public partial class Default2 : System.Web.UI.Page
{
protected static DataCacheFactory _factory = null;
protected static DataCache _cache = null;
protected void Page_Load(object sender, EventArgs e)
{
GetDataFromCache();
}
protected void GetDataFromCache()
{
_cache = GetDefaultCache();
string key = "55";
var item = _cache.Get(key);// Error is generation here
}
protected static DataCache GetDefaultCache()
{
_factory = new DataCacheFactory();
_cache = _factory.GetDefaultCache();
return _cache;
}
}
An error is generating on the line _cache.Get(key)
The deserializer cannot load the type to deserialize because type 'System.Collections.Generic.List`1[[_Default2+Employee, App_Web_4xzswv4j, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]' could not be found in assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Check that the type being serialized has the same contract as the type being deserialized and the same assembly is used.
Why this error is coming?
How can Can I uses Classes as List collection to add/read in Cache.
alstephen
Participant
1544 Points
513 Posts
Re: How to use classes as List Collection in Azure AppFabri Caching
Jul 21, 2011 01:38 PM|LINK
maybe this can help you:
http://msdn.microsoft.com/en-us/gg457898