473,413 Members | 1,811 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,413 software developers and data experts.

CacheDependency creation fails on the 49th instantiation using a UNC directory

I am getting the following error when creating a new CacheDependency
object:
Failed to start monitoring changes to '\\server\share\dir49'
This error happens after 48 successful instantiations of
CacheDependency using the same fileserver.

I have an ASP.NET application that needs to display filecounts for 300
different directories on my fileserver. I have a loop where I get each
directory and determine the number of files. In order to make this more
efficient, I want to use the cache object to hold the filecount and
make this dependent on the directory which holds the files. When a file
is added or dropped, the cached item is removed, and I can rebuild it
on my next attempt at reading it.

This works well for the first 48 iterations in the loop. On the 49th
iteration I get the error above. Every directory is on the same drive
and they have identical security settings. If I process the directories
in a different order, it still fails on the 49th. It does not fail if
the files are on the local filesystem.

What is causing this? If I try to instantiate the CacheDependancy
objects again (on the next page request), they will succeed (not raise
any errors) but then not work, e.g. not clear the cache when the
directory changes. The first 48 continue to work as expected.

Example code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
Dim strRoot As String = "\\server\share" ' must have 50+
subdirectories to test this error
Dim strPath As String
Dim intCount As Integer = 0
For Each strPath In
System.IO.Directory.GetDirectories(strRoot)
Response.Write(intCount & " :" &
GetCachedFileCount(strPath) & "<br>")
intCount += 1
Next
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub

Private Function GetCachedFileCount(ByVal FullPath As String) As
Integer
Dim intFileCount As Integer
Dim dep As System.Web.Caching.CacheDependency
If Cache.Item(FullPath) Is Nothing AndAlso intCacheCount < 20
Then
If System.IO.Directory.Exists(FullPath) Then
intFileCount =
System.IO.Directory.GetFiles(FullPath).Length
Try
Response.Write(FullPath & "<br>")
dep = New
System.Web.Caching.CacheDependency(FullPath)
Cache.Insert(FullPath, intFileCount, dep)
Catch ex As Exception
Response.Write("Failed: " & ex.Message & "<br>")
End Try
Else
intFileCount = 0
End If
Else
intFileCount = Cache.Get(FullPath)
End If
Return intFileCount
End Function

Sep 21 '05 #1
0 1080

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

Similar topics

8
by: Anthony Munter | last post by:
I have a web application with impersonate=”true” in Web.config and on my own logon page I allow the user to either - specify a userid/password for the app to impersonate when calling legacy...
0
by: Nick | last post by:
I am getting the following error when creating a new CacheDependency object: Failed to start monitoring changes to '\\server\share\dir49' This error happens after 48 successful instantiations of...
2
by: daniel | last post by:
Hi, I am developing an application that requires me to set up file system watchers on directories on a network drive, as well as set up CacheDependencies in the same location for my...
3
by: Dave | last post by:
Using ASP.Net 2.0 on Vista with IIS6, if I set a CacheDependency on a file into a Cache entry that I insert and then delete a subdirectory in the same directory that the file is located in then my...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.