C# 用户代码未处理参数null异常

C# 用户代码未处理参数null异常,c#,C#,我得到以下错误 用户代码未处理参数null异常。 值不能为null。 参数名称:value 在下面代码的粗体处 public static void InsertIntoCache(string cacheKey, object value) { HttpRuntime.Cache.Insert(cacheKey, value, null, DateTime.Now.Add(new TimeSpan(0, CacheDuration, 0)), **Cache.NoSlidingExpi

我得到以下错误

用户代码未处理参数null异常。 值不能为null。 参数名称:value

在下面代码的粗体处

public static void InsertIntoCache(string cacheKey, object value)
{
    HttpRuntime.Cache.Insert(cacheKey, value, null, DateTime.Now.Add(new TimeSpan(0, CacheDuration, 0)), **Cache.NoSlidingExpiration**, CacheItemPriority.Default,null);
}

请在这方面帮助我。

缓存.Insert()的方法签名是(取自):

错误告诉您,
,它是
.Insert()
方法中的第二个参数,不能为空。这意味着调用您的方法时使用null作为第二个参数,如:

InsertIntoCache("some_key", null);  // this will throw an exception.
基本上,不能将“null”缓存为值。如果向下滚动到“Exceptions”(异常),则说明Insert()将在以下情况下引发
ArgumentNullException

键或值参数是空引用


很确定它不可能在你指的地方<代码>缓存由ASP.NET运行时设置,属性是
日期时间
的枚举值。您的变量
是否等于
空值
InsertIntoCache("some_key", null);  // this will throw an exception.