C# 必须是redis中具有公共无参数构造函数的非抽象类型

C# 必须是redis中具有公共无参数构造函数的非抽象类型,c#,redis,C#,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

保存对象时,出现以下错误:

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();
必须是具有公共无参数构造函数的非抽象类型,才能将其用作泛型类型或方法“ServiceStack.Redis.RedisClient.Store(T)”中的参数“T”
RedisClass.GetInstance().Store(msg);//这里出错
RedisClass.GetInstance().Save();

由于这是第三方的类,我无法编辑它。如何保存此对象?

能否围绕第三方对象创建一个包装器来调用其构造函数,然后存储包装器

例如


错误是由IBasicPersistenceProvider.Store()具有new()泛型约束引起的。相反,请尝试使用IBasicPersistenceProvider.Store():

RedisClass.GetInstance().As().Store(msg);
public class MyWrapper
{
    public ThirdPartyObject ThirdPartyInstance { get; set; }

    public MyWrapper()
    {
        ThirdPartyInstance = new ThirdPartyObject("Constructors");
    }
}