我正在使用以下代码进行天蓝色缓存,它工作正常......
[Serializable]
public class Person
{
public string First { set; get; }
public string Last { set; get; }
}
[TestClass]
public class AzureCachingTests1
{
private static DataCacheFactory _factory;
[TestInitialize]
public void Setup()
{
_factory = new DataCacheFactory(new DataCacheFactoryConfiguration("mycache"));
}
[TestMethod]
public void TestMethod1()
{
DataCache cache = _factory.GetDefaultCache();
var person = new Person { First = "Jane", Last = "doe" };
const string key = "mykey";
cache.Put(key, person, TimeSpan.FromMinutes(10));
var data = (Person)cache.Get(key);
Assert.AreEqual("Jane", data.First);
}
}
现在在 Visual Studio 的另一个实例中,我运行以下代码...
[TestClass]
public class AzureCachingTests
{
private static DataCacheFactory _factory;
[TestInitialize]
public void Setup()
{
_factory = new DataCacheFactory(new DataCacheFactoryConfiguration("mycache"));
}
[TestMethod]
public void TestMethod1()
{
DataCache cache = _factory.GetDefaultCache();
const string key = "mykey";
var data = (Person) cache.Get(key); <----- Error here... <--------
Assert.AreEqual("Jane", data.First);
}
}
[Serializable]
public class Person
{
public string First { set; get; }
public string Last { set; get; }
}
这一次,我收到以下错误...
测试方法 AzureCaching.AzureCachingTests.TestMethod1 抛出异常:System.Runtime.Serialization.SerializationException:未找到程序集 'AzureCaching1,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null'。
我的班级 Person 是可序列化的。为什么我无法在 AzureCaching 中查询我缓存在 AzureCaching1 中的缓存?
请帮忙。谢谢