我使用下面的代碼做Azure的緩存讀取蔚藍緩存數據,它工作正常...無法從不同的應用程序
[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.Seriali zation.SerializationException:未找到Assembly'AzureCaching1,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'。
我的課人是可序列化的。爲什麼我無法查詢緩存在AzureCaching1中的緩存?
請幫忙。謝謝