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

w3wp.exe process locks files for a few seconds

Hi All,

We have a gallery component that allows us to upload images.
An Edit Image Entry user control allows the user to update an image, by
replacing the current one.

Oddly, after replacing an image, if the user tries to replace again
within a few seconds - he gets the following error message:

The process cannot access the file "...X.gif" because it is being used
by another process.

If we wait for over 20 seconds or so, this doesn't happen.

Also, once we get this error, the file then stays locked untill the
w3wp.exe process is killed (or debugging is stopped).

Help!

Thanks,
Uri
CodeOasis.com

Nov 19 '05 #1
8 5110
Sounds like the upload completes and passes the file write off to the file
system, which has not yet completed actually repacing the file - even though
the instruction to start has has completed. I dont think there would be
anyhting you can do about it other than make some informative error
handling. You might try checking that the file can be opened exclusively
before you try and overwrite it or seeing if you can stall the asp page
concluding by getting areturn value from the file write.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

<ut*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi All,

We have a gallery component that allows us to upload images.
An Edit Image Entry user control allows the user to update an image, by
replacing the current one.

Oddly, after replacing an image, if the user tries to replace again
within a few seconds - he gets the following error message:

The process cannot access the file "...X.gif" because it is being used
by another process.

If we wait for over 20 seconds or so, this doesn't happen.

Also, once we get this error, the file then stays locked untill the
w3wp.exe process is killed (or debugging is stopped).

Help!

Thanks,
Uri
CodeOasis.com

Nov 19 '05 #2
Hi John,

In the two methods that I've tried using to write the file, there is no
return value that I can wait for. The methods were:
1) HtmlInputFile's .PostedFile.SaveAs(...)
2) Creating a FileStream object and using its write method. In this
case, I did wait for the InputStream to finish reading (uploading) the
file and give me a return value.
Both solutions did not help...
I am also disposing of all related objects, BTW.

I find it very strange that the file system would keep a lock on a file
for so long after all handles have been detroyed.
Naturally, I am taking care of showing a more subtle error message to
the user. Moreover, this scenario is not expected to happen often.

However, I would like to get to the bottom of this - to know what's the
cause. I hate 'turning a blind eye' to this sort of thing, as it tends
to come back and 'bite you in the ass'...

Thanks!

Nov 19 '05 #3
Just shooting in the dark...
If it is a timing issue, maybe the same code that saves the file to disk
could also immediately try to access the file after the write. (This could be
something as simple as querying the FileSystemInfo. ) Doing this in the same
code may give the system enough time to complete anything that is causing it
to hang.

Are there a lot of files in the directory? A large directory could put a
greater burden on the file system. This could be requiring more time to
complete background operations.

"ut*****@gmail.com" wrote:
Hi John,

In the two methods that I've tried using to write the file, there is no
return value that I can wait for. The methods were:
1) HtmlInputFile's .PostedFile.SaveAs(...)
2) Creating a FileStream object and using its write method. In this
case, I did wait for the InputStream to finish reading (uploading) the
file and give me a return value.
Both solutions did not help...
I am also disposing of all related objects, BTW.

I find it very strange that the file system would keep a lock on a file
for so long after all handles have been detroyed.
Naturally, I am taking care of showing a more subtle error message to
the user. Moreover, this scenario is not expected to happen often.

However, I would like to get to the bottom of this - to know what's the
cause. I hate 'turning a blind eye' to this sort of thing, as it tends
to come back and 'bite you in the ass'...

Thanks!

Nov 19 '05 #4
Is the file accessed through HTTP before or after being uploaded ? AFAIK
when you access a file through HTTP, IIS lock the file for a "short" period
(I would say 60 s by default ?).

If you are in this case, you could likely stream the file to the browser to
avoid HTTP access...

Patrice


--

<ut*****@gmail.com> a écrit dans le message de
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi John,

In the two methods that I've tried using to write the file, there is no
return value that I can wait for. The methods were:
1) HtmlInputFile's .PostedFile.SaveAs(...)
2) Creating a FileStream object and using its write method. In this
case, I did wait for the InputStream to finish reading (uploading) the
file and give me a return value.
Both solutions did not help...
I am also disposing of all related objects, BTW.

I find it very strange that the file system would keep a lock on a file
for so long after all handles have been detroyed.
Naturally, I am taking care of showing a more subtle error message to
the user. Moreover, this scenario is not expected to happen often.

However, I would like to get to the bottom of this - to know what's the
cause. I hate 'turning a blind eye' to this sort of thing, as it tends
to come back and 'bite you in the ass'...

Thanks!

Nov 19 '05 #5
Thanks Brad,

I have tried your approach and unfortunately it produced no effect.
To your question: there are very few files in the directory at this
point (less than 10) - so I doubt that this could be a factor.
Also - what background operations could there be? We're waiting for
everything to complete, and then destroying the handles...

Uri.

Nov 19 '05 #6
Hi Patrice,

I'm affraid I don't know what you mean by 'streaming' the file to the
browser. I'm using regular access as an <img> tag. The upload takes
place using an HtmlInputFile control, which I assume uses HTTP to
transfer the file.

I've researched a little about this (shocking) lock that IIS places on
files. I've even used a registry setting to try to disable it, but that
didn't work.
To disable the caching, I've used the steps described for IIS4 in:
http://support.microsoft.com/default...EN-US;q191742& -
namely: enter a DWORD value in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\InetInfo\Parameters
called DisableMemoryCache with a value of 1.
I don't know if this didn't help because I'm using IIS 6, or because my
problem is not related to this locking (although it sounds quite
right).

Thanks,
Uri.

Nov 19 '05 #7
I meant calling an ASPX page that uses "Response.WriteFile" to output the
file to the browser. This way the file is not served directly by IIS.

For the upload you upload the *content* of the file using HTTP but this is
your code that creates the final file, not IIS...

Another culprit could be index server or an antivirus software maybe ? You
may want to try the filemon utility (from http://www.sysinternals.com/). It
should hopefully allow to find out what exactly locks this file before
trying a solution...

Good luck.

Patrice

--

"tagger" <ut*****@gmail.com> a écrit dans le message de
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi Patrice,

I'm affraid I don't know what you mean by 'streaming' the file to the
browser. I'm using regular access as an <img> tag. The upload takes
place using an HtmlInputFile control, which I assume uses HTTP to
transfer the file.

I've researched a little about this (shocking) lock that IIS places on
files. I've even used a registry setting to try to disable it, but that
didn't work.
To disable the caching, I've used the steps described for IIS4 in:
http://support.microsoft.com/default...EN-US;q191742& -
namely: enter a DWORD value in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\InetInfo\Parameters
called DisableMemoryCache with a value of 1.
I don't know if this didn't help because I'm using IIS 6, or because my
problem is not related to this locking (although it sounds quite
right).

Thanks,
Uri.

Nov 19 '05 #8
Hi All,

Well, Patrice's last advice finally nailed it!

I used one of the excellent tools on sysinternals.com (procexp.exe)
while tracing through the code, and found the culprit: ME!

At some point in the program, I had opened a Bitmap object just to get
the height and width of the image, and forgot to dispose of this
object. This had kept an open handle on the file, and wouldn't let me
try to overwrite it...

Thanks to everyone for your help, and thanks to Patrice for providing
the eventual remedy.

Uri.

Nov 19 '05 #9

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

Similar topics

3
by: Helge | last post by:
I'm developing a web site with asp.net, mainly vb on a Windows 2003 server. Quite often the web site stops responding for 15-20 seconds. A web page that usually take 2 seconds to produce takes...
77
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the...
4
by: Prince Kumar | last post by:
I joined a company recently and they have a java program which hangs (does nothing) after a while. This is no way consistent. It could succeed quite a few times and can fail a few other times....
15
by: z. f. | last post by:
Hi, i have an ASP.NET project that is using a (Class Library Project) VB.NET DLL. for some reason after running some pages on the web server, and trying to compile the Class Library DLL, it...
3
by: Tod Birdsall | last post by:
Hi All, The organization I am working for has created a new corporate website that used Microsoft's Pet Shop website as their coding model, and dynamically served up content, but cached each...
5
by: mcollier | last post by:
I am experiencing high CPU utilization with my ASP.NET application. The w3wp.exe process uses 75%-80% CPU for about 10 seconds. I notice this when the application first starts up, which I can...
4
by: AN | last post by:
Greetings, We make an ASP.NET web application and we host it for our customers. We have provisioned hardware and hope to be able to service around 200 customers on this hardware. The web...
1
by: Propertyshowrooms | last post by:
Hi all, I know this is probably an easy problem to fix, or at least I hope so, but for the life of me I can't figure out why the Private Bytes in my w3wp.exe process just keeps climbing until the...
2
by: violeta123 | last post by:
I am stuck! Please help It might be difficult to explain the problem via email, but I will try. I have a Win 2003 Enterprise server running with the only purpose of a membership web site...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.