Hi Val,
Thanks for your answers - they were very helpful.
Unfortunately I'm still getting the unhandled exception that kills the IIS worker process. I'm seeing this problem on a Windows Web Server 2008 R2 64-bit test server as well as the Windows 7 development machine.
I've tested this with the latest 5.5.111.0 version of MapSuite WMS.There are two errors logged in the Windows Event Log when the problem occurs:
An unhandled exception occurred and the process was terminated.
Application ID: /LM/W3SVC/3/ROOT
Process ID: 3480
Exception: System.IO.IOException
Message: The process cannot access the file 'D:\MapCache\UK\288374.897460938\50854\51209.png' because it is being used by another process.
StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.WriteAllBytes(String path, Byte[] bytes)
at ThinkGeo.MapSuite.Core.FileBitmapTileCache.SaveTileCore(Tile tile)
at ThinkGeo.MapSuite.Core.TileCache.SaveTiles(Bitmap bitmap, RectangleShape bitmapExtent)
at ohM=.0BM=.CBQ=(Object CRQ=)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart(Object obj)
Faulting application name: w3wp.exe, version: 7.5.7600.16385, time stamp: 0x4a5bd0eb
Faulting module name: KERNELBASE.dll, version: 6.1.7600.16850, time stamp: 0x4e211da1
Exception code: 0xe0434f4d
Fault offset: 0x000000000000a88d
Faulting process id: 0xd98
Faulting application start time: 0x01ccf87d9319487e
Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: 049094e6-6473-11e1-b0cb-0022196b2869
I only see the problem when using caching, which I'm doing with the following code inside my overriding GetMapCore() function:
if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["EnableCaching"]) && ConfigurationManager.AppSettings["EnableCaching"].Equals("True", StringComparison.InvariantCultureIgnoreCase))
{
if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["CacheDirectory"]) && Directory.Exists(ConfigurationManager.AppSettings["CacheDirectory"]))
{
FileBitmapTileCache tileCache = new FileBitmapTileCache();
tileCache.CacheDirectory = ConfigurationManager.AppSettings["CacheDirectory"];
tileCache.CacheId = groups;
tileCache.ImageFormat = TileImageFormat.Png;
tileCache.TileAccessMode = TileAccessMode.ReadAdd;
customMapConfiguration.TileCache = tileCache;
}
}
As I mentioned, the problem seems to occur most often when rapidly panning around the map, e.g. quickly pan right and then left, or zoom out and immediately back in. My suspicion is that a subsequent request for a particular tile is coming in from the client before an earlier request has finished writing the file out to disk. This subsequent read isn't able to complete successfully because the writing process still has a lock on the file.
I assume the objects that write out the cache files are being Dispose()ed as soon as possible, but even if they are I would have thought this particular issue could easily be caught with an exception handler inside your ThinkGeo.MapSuite.Core.FileBitmapTileCache.SaveTileCore() function to prevent it from killing IIS.
Best regards,
Gary
P.S. I've ensured that there's no other processes running, e.g. Antivirus, that might be trying to access the file at the same time.