![](/img/trans.png)
[英]'MvxWpfSetup<App>' must be a non-abstract type with a public parameterless constructor
[英]must be a non-abstract type with a public parameterless constructor in redis
保存對象時,出現以下錯誤:
must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'ServiceStack.Redis.RedisClient.Store<T>(T)
RedisClass.GetInstance().Store(msg); // Error here
RedisClass.GetInstance().Save();
由於這是第三方的課程,因此我無法對其進行編輯。 如何保存該對象?
您能否圍繞第三方對象創建包裝器以調用其構造函數,然后存儲包裝器?
例如
public class MyWrapper
{
public ThirdPartyObject ThirdPartyInstance { get; set; }
public MyWrapper()
{
ThirdPartyInstance = new ThirdPartyObject("Constructors");
}
}
該錯誤是由IBasicPersistenceProvider.Store <T>()具有new()通用約束引起的。 而是嘗試使用IBasicPersistenceProvider <T> .Store():
RedisClass.GetInstance().As<ThirdPartyClass>().Store(msg);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.