G
Guest
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 System.Web.Caching.Cache. When
i set up the file watchers and then create the cache dependency i receive an
Exception (AccessViolationError - Attempted to read or write protected
memory). I have included a the stack trace from the exception at the end of
this post. This only occurs when i am creating a large number of file
watchers ( i have found the the for my PC i can only create 48!). The
following is a sample application i built which consistantly throws the
exception( note that when i copy the directory structe from the network drive
to a local drive the function works flawlessly ).
List<FileSystemWatcher> watchers = new List<FileSystemWatcher>();
foreach( string directory in Directory.GetDirectories(
@"\\itchy\imagelink\Books\V3Books" ) )
{
FileSystemWatcher watcher = new FileSystemWatcher( directory );
watcher.Deleted += new FileSystemEventHandler( watcher_Deleted );
watcher.Created += new FileSystemEventHandler( watcher_Created );
watcher.Renamed += new RenamedEventHandler( watcher_Renamed );
watcher.Changed += new FileSystemEventHandler( watcher_Changed );
watcher.EnableRaisingEvents = true;
watchers.Add( watcher );
}
CacheDependency depencency2 = new CacheDependency(
@"\\itchy\imagelink\Books\V3Books\man.lst" );
Partial Stack Trace:
at System.Web.UnsafeNativeMethods.RaiseFileMonitoringEventlogEvent(String
eventInfo, String path, String appVirtualPath, Int32 hr)
at System.Web.FileChangesMonitor.CreateFileMonitoringException(Int32 hr,
String path)
at System.Web.DirMonCompletion..ctor(DirectoryMonitor dirMon, String dir,
Boolean watchSubtree, UInt32 notifyFilter)
at System.Web.DirectoryMonitor.StartMonitoring()
at System.Web.DirectoryMonitor.StartMonitoringFile(String file,
FileChangeEventHandler callback, String alias)
at System.Web.FileChangesMonitor.StartMonitoringPath(String alias,
FileChangeEventHandler callback, FileAttributesData& fad)
at System.Web.Caching.CacheDependency.Init(Boolean isPublic, String[]
filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime
utcStart)
at System.Web.Caching.CacheDependency..ctor(String filename, DateTime start)
at System.Web.Caching.CacheDependency..ctor(String filename)
at WindowsApplication4.Form1.LoadTargetFolder() in
D:\MyProjects\WindowsApplication4\WindowsApplication4\Form1.cs:line 52
at WindowsApplication4.Program.Main() in
D:\MyProjects\WindowsApplication4\WindowsApplication4\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Thanks,
Daniel
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 System.Web.Caching.Cache. When
i set up the file watchers and then create the cache dependency i receive an
Exception (AccessViolationError - Attempted to read or write protected
memory). I have included a the stack trace from the exception at the end of
this post. This only occurs when i am creating a large number of file
watchers ( i have found the the for my PC i can only create 48!). The
following is a sample application i built which consistantly throws the
exception( note that when i copy the directory structe from the network drive
to a local drive the function works flawlessly ).
List<FileSystemWatcher> watchers = new List<FileSystemWatcher>();
foreach( string directory in Directory.GetDirectories(
@"\\itchy\imagelink\Books\V3Books" ) )
{
FileSystemWatcher watcher = new FileSystemWatcher( directory );
watcher.Deleted += new FileSystemEventHandler( watcher_Deleted );
watcher.Created += new FileSystemEventHandler( watcher_Created );
watcher.Renamed += new RenamedEventHandler( watcher_Renamed );
watcher.Changed += new FileSystemEventHandler( watcher_Changed );
watcher.EnableRaisingEvents = true;
watchers.Add( watcher );
}
CacheDependency depencency2 = new CacheDependency(
@"\\itchy\imagelink\Books\V3Books\man.lst" );
Partial Stack Trace:
at System.Web.UnsafeNativeMethods.RaiseFileMonitoringEventlogEvent(String
eventInfo, String path, String appVirtualPath, Int32 hr)
at System.Web.FileChangesMonitor.CreateFileMonitoringException(Int32 hr,
String path)
at System.Web.DirMonCompletion..ctor(DirectoryMonitor dirMon, String dir,
Boolean watchSubtree, UInt32 notifyFilter)
at System.Web.DirectoryMonitor.StartMonitoring()
at System.Web.DirectoryMonitor.StartMonitoringFile(String file,
FileChangeEventHandler callback, String alias)
at System.Web.FileChangesMonitor.StartMonitoringPath(String alias,
FileChangeEventHandler callback, FileAttributesData& fad)
at System.Web.Caching.CacheDependency.Init(Boolean isPublic, String[]
filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime
utcStart)
at System.Web.Caching.CacheDependency..ctor(String filename, DateTime start)
at System.Web.Caching.CacheDependency..ctor(String filename)
at WindowsApplication4.Form1.LoadTargetFolder() in
D:\MyProjects\WindowsApplication4\WindowsApplication4\Form1.cs:line 52
at WindowsApplication4.Program.Main() in
D:\MyProjects\WindowsApplication4\WindowsApplication4\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Thanks,
Daniel