Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / October 2003

Tip: Looking for answers? Try searching our database.

File locked by another process when cached with CacheDependency

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith - 01 Oct 2003 22:29 GMT
Hi.

I've developed an ASP.NET web service that uses an xml file to store
configuration settings. I'm creating a cache dependency based on the xml
file and its schema, like this...

XmlDocument doc = new XmlDocument();
{ ........ }
string [] filePaths = { filePath, schemaPath };
CacheDependency dep = new CacheDependency(filePaths);
Context.Cache.Insert(key, doc, dep);

The problem is the files are being locked by another process. I'm assuming
they're locked by the aspnet_wp process, because if I run iisreset, the
files are free until the next time the web service is called.

I'd like to be able to update the files without having to reset the server
each time. I'd expect the cached item would then be cleared from cache, so I
can reload it with the newer version of the xml document.

The documentation for HttpContext.Cache says this is possible, but it's not
working.

Thanks in advance.

-|<eith.
MSFT - 02 Oct 2003 09:06 GMT
Hi Keith,

Each application domain has its own Cache object. If your XML file was
cached by an app, you must remove it from cache so that it can be reused,
like:

HttpContext.Cache.remove("key1")

Luke
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Keith - 02 Oct 2003 19:27 GMT
I found the answer to my problem. I wasn't closing my XmlValidatingReader
object. Duh! Thanks for your help Luke.

-|<eith

------------------------------------------
string filePath = Server.MapPath("ParamConfig.xml");
string schemaPath = Server.MapPath("ParamConfig.xsd");
// open, validate and cache config file.
XmlTextReader xtr = new XmlTextReader(filePath);
XmlValidatingReader xvr = new XmlValidatingReader(xtr);
XmlTextReader sxtr = new XmlTextReader(schemaPath);
xvr.Schemas.Add(null, sxtr);
doc = new XmlDocument();
doc.Load(xvr);

// THIS LINE SOLVED THE PROBLEM
xvr.Close();

string [] filePaths = { filePath, schemaPath };
CacheDependency dep = new CacheDependency(filePaths);
Context.Cache.Insert(key, doc, dep);
------------------------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.