473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Cache_dependency_used_more_that_once Exception when adding to .NET cache

Hi,

I'm trying to add an object to the .NET cache using a CacheDependency
and I get the following exception :

System.InvalidOperationException: Cache_dependency_used_more_that_once
at System.Web.Caching.CacheEntry.MonitorDependencyCha nges()
at System.Web.Caching.CacheSingle.UpdateCache(CacheKe y cacheKey,
CacheEntry newEntry, Boolean replace, CacheItemRemovedReason
removedReason, Object& valueOld)
at System.Web.Caching.CacheMultiple.UpdateCache(Cache Key cacheKey,
CacheEntry newEntry, Boolean replace, CacheItemRemovedReason
removedReason, Object& valueOld)
at System.Web.Caching.CacheInternal.DoInsert(Boolean isPublic,
String key, Object value, CacheDependency dependencies, DateTime
utcAbsoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority
priority, CacheItemRemovedCallback onRemoveCallback, Boolean replace)
at System.Web.Caching.Cache.Insert(String key, Object value,
CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan
slidingExpiration, CacheItemPriority priority,
CacheItemRemovedCallback onRemoveCallback)

I've not seen this error before...and I couldn't find reference to
this error message either on Google or MSDN.
Does anyone know what could cause the
"Cache_dependency_used_more_that_once" exception to happen.

Thanks
Mahesh

Feb 16 '07 #1
2 2403
Decompiled:

internal void MonitorDependencyChanges()
{
CacheDependency dependency1 = this._dependency;
if ((dependency1 != null) && (this.State ==
CacheEntry.EntryState.AddedToCache))
{
if (!dependency1.Use())
{
throw new
InvalidOperationException(SR.GetString("Cache_depe ndency_used_more_that_once"));
}
dependency1.SetCacheDependencyChanged(this);
}
}

In other words, it is trying to use the dependency but it is alread in use
(probably from another part of your code is my guess).
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"ma***********@gmail.com" wrote:
Hi,

I'm trying to add an object to the .NET cache using a CacheDependency
and I get the following exception :

System.InvalidOperationException: Cache_dependency_used_more_that_once
at System.Web.Caching.CacheEntry.MonitorDependencyCha nges()
at System.Web.Caching.CacheSingle.UpdateCache(CacheKe y cacheKey,
CacheEntry newEntry, Boolean replace, CacheItemRemovedReason
removedReason, Object& valueOld)
at System.Web.Caching.CacheMultiple.UpdateCache(Cache Key cacheKey,
CacheEntry newEntry, Boolean replace, CacheItemRemovedReason
removedReason, Object& valueOld)
at System.Web.Caching.CacheInternal.DoInsert(Boolean isPublic,
String key, Object value, CacheDependency dependencies, DateTime
utcAbsoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority
priority, CacheItemRemovedCallback onRemoveCallback, Boolean replace)
at System.Web.Caching.Cache.Insert(String key, Object value,
CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan
slidingExpiration, CacheItemPriority priority,
CacheItemRemovedCallback onRemoveCallback)

I've not seen this error before...and I couldn't find reference to
this error message either on Google or MSDN.
Does anyone know what could cause the
"Cache_dependency_used_more_that_once" exception to happen.

Thanks
Mahesh

Feb 16 '07 #2
Hi Peter,

Thanks for the reply! I was doing the following :

_cache.Insert("dep","dependency");

string[] depKey = {"dep"};
CacheDependency cdep = new CacheDependency(null,depKey);

_cache.Insert("1","one",cdep,...);
_cache.Insert("2","two",cdep,..);

I thought we could use the same CacheDependency object for more than
one keys; seems like we cannot (btw it would be interesting to know
why it was designed this way)
The code worked after I changed to this...

_cache.Insert("dep","dependency");
string[] depKey = {"dep"};

CacheDependency cdep1 = new CacheDependency(null,depKey);
_cache.Insert("1","one",cdep1,...);

CacheDependency cdep2 = new CacheDependency(null,depKey);
_cache.Insert("2","two",cdep2,..);

Thanks again for your help.

-Mahesh

On Feb 16, 1:10 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
Decompiled:

internal void MonitorDependencyChanges()
{
CacheDependency dependency1 = this._dependency;
if ((dependency1 != null) && (this.State ==
CacheEntry.EntryState.AddedToCache))
{
if (!dependency1.Use())
{
throw new
InvalidOperationException(SR.GetString("Cache_depe ndency_used_more_that_once"));
}
dependency1.SetCacheDependencyChanged(this);
}

}

In other words, it is trying to use the dependency but it is alread in use
(probably from another part of your code is my guess).
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"mahesh.pra...@gmail.com" wrote:
Hi,
I'm trying to add an object to the .NET cache using a CacheDependency
and I get the following exception :
System.InvalidOperationException: Cache_dependency_used_more_that_once
at System.Web.Caching.CacheEntry.MonitorDependencyCha nges()
at System.Web.Caching.CacheSingle.UpdateCache(CacheKe y cacheKey,
CacheEntry newEntry, Boolean replace, CacheItemRemovedReason
removedReason, Object& valueOld)
at System.Web.Caching.CacheMultiple.UpdateCache(Cache Key cacheKey,
CacheEntry newEntry, Boolean replace, CacheItemRemovedReason
removedReason, Object& valueOld)
at System.Web.Caching.CacheInternal.DoInsert(Boolean isPublic,
String key, Object value, CacheDependency dependencies, DateTime
utcAbsoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority
priority, CacheItemRemovedCallback onRemoveCallback, Boolean replace)
at System.Web.Caching.Cache.Insert(String key, Object value,
CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan
slidingExpiration, CacheItemPriority priority,
CacheItemRemovedCallback onRemoveCallback)
I've not seen this error before...and I couldn't find reference to
this error message either on Google or MSDN.
Does anyone know what could cause the
"Cache_dependency_used_more_that_once" exception to happen.
Thanks
Mahesh

Feb 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: peter greaves | last post by:
hi everyone i am having a bad time with an entity resolver. my application uses a resolver to locally-cache the nested schemas that the basic xsd includes to a local directory. however i am...
7
by: Douglas Peterson | last post by:
Take a look at this code, it looks funny as its written to be as short as possible: -- code -- struct Base { ~Base() { *((char*)0) = 0; } }; struct Derived : public Base
1
by: leodippolito | last post by:
Hello, I have these entities in my ASP.NET application: - data access layer (DATA) - custom exception class (EXCEPTION) - cache management class (CACHE) They're all built into different...
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
0
by: =?Utf-8?B?YmlqYXk=?= | last post by:
The type initializer for 'Microsoft.ApplicationBlocks.Cache.CacheService' threw an exception. We migrated our windows application from 1.1 to 2.0. The debug and Release mode of the application...
4
by: =?Utf-8?B?YmlqYXk=?= | last post by:
We migrated our windows application from 1.1 to 2.0. The debug and Release mode of the application work fine with some tweaking. But when the setup project is migrated to 2.0 the installation gives...
4
by: MikeB | last post by:
Hello All, I am trying to cache a menu that I dynamically build out and I do not want to have to build it out each time the page loads. Here is how I am doing it however, it doesnt work. Can...
1
by: ceestand | last post by:
I am having a weird (to me at least) problem retrieving a copy of an item in the Cache. I do something like this: DataTable ToBeInserted = FunctionThatReturnsDataTable();...
10
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... We've been trying to migrate our asp.net apps off older, underpowered hardware to newer, bigger boxes but when we do, we see our databases start to melt. When I started to look into it,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.