473,799 Members | 2,900 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

windows service not working for everyone.

63 New Member
Hi I have already posted this question before.I got a work around but doesn't seem reasonable.

I developed a windows service and I installed it in our server.everybod y in the office has access to a folder in the server.anybody can put a file in that shared folder and the service has to pick it up. but it does not pickup for everyone. it just picks up for some users. and the strange thing is it pickes up for rest of the users also but ocassionally.

Iam not getting how to make it work consistantly. any ideas on this issue.

does it have to work under admin account. if so what should i do for that.

please help!
Ayush
Sep 15 '08
30 3616
balabaster
797 Recognized Expert Contributor
its very wierd but sometimes I am getting this error


An unhandled exception of type 'System.IO.IOEx ception' occurred in mscorlib.dll

Additional information: The process cannot access the file 'C:\W080716.TXT ' because it is being used by another process.

W080716.TXT' file is not open anywhere.
Does your own application open this file anywhere and not dispose of connections to it? I sometimes see this if I've forgotten a:

sw.close()
sw.dispose()

On the streamwriter that's accessing the file...
Sep 15 '08 #21
ayush patel
63 New Member
no everytime i opened a StreamWriter I have closed it.
Sep 15 '08 #22
balabaster
797 Recognized Expert Contributor
no everytime i opened a StreamWriter I have closed it.
Sorry man, then without seeing your code, I've eliminated everything I can think of.
Sep 15 '08 #23
ayush patel
63 New Member
hmm.. i know thanks for trying anyway. I will post my solution if i find any.
Ayush
Sep 15 '08 #24
PRR
750 Recognized Expert Contributor
"System.Tim ers" is better option...
what i had suggested was that you should try to pause... when the watcher event is called....
Also try and optimized the buffer size:
FileSystemWatch er..InternalBuf ferSize Property .. the default is around 4K which can handle around 400 request per second... (if i am not wrong)..

I would suggest you do this:
1.First Pause on
Expand|Select|Wrap|Line Numbers
  1. private static void OnChanged(object source, FileSystemEventArgs e)
  2.         {
  3.             Thread.Sleep(1000);
  4.             // This is enable the file to be tranfered before your code goes off..
  5.  
  6.         }
  7.  
2. Instead Of writing all processin in OnChanged... Try doin this: inside onchanged ... write to Database the file name and processing status as "False"
3. Periodically run a function using timers to do processin on the file... this way if too many files are put up... then your service wont be creating large number of threads...
4. For testing purpose ... put your code in console program and check... Finally you can transfer to a windows service..
Sep 16 '08 #25
ayush patel
63 New Member
Hi,

I thought the problem may be as you said before: ownership of file is not available to watcher as soon as file is created.so I used Thread.Sleep(10 00);I also increased the buffersize of filewatcher. but still the service throws an error that the file that i just copied into the folder is not available. it is not recognizing the file atall.

this service is not used very frequently so there is no problem of processing many files at once.only one file is loaded that too may be 3 times a week.

do you have any idea why does it say

An unhandled exception of type 'System.IO.File NotFoundExcepti on' occurred in mscorlib.dll

Additional information: Could not find file 'C:\W080805.TXT '.
Ayush
Sep 16 '08 #26
balabaster
797 Recognized Expert Contributor
I wonder if the network share may be an issue? What is intriguing is that the FileSystemWatch er flags the file as having been created, but that System.IO.FileE xists returns false...

Did you try wrapping the copy in:
VB:
Expand|Select|Wrap|Line Numbers
  1. If System.IO.FileExists(e.FullPath) Then
  2. ...
  3. End If
Sep 16 '08 #27
PRR
750 Recognized Expert Contributor

I thought the problem may be as you said before: ownership of file is not available to watcher as soon as file is created.so I used Thread.Sleep(10 00);I also increased the buffersize of filewatcher. but still the service throws an error that the file that i just copied into the folder is not available. it is not recognizing the file atall.

this service is not used very frequently so there is no problem of processing many files at once.only one file is loaded that too may be 3 times a week.

do you have any idea why does it say

An unhandled exception of type 'System.IO.File NotFoundExcepti on' occurred in mscorlib.dll

Additional information: Could not find file 'C:\W080805.TXT '.
Ayush
wow... now i m run out of ideas ... try testing it from another pc.... one more thing post your code where exception occurs and also the full exception message and stacktrace
i will go through ur post again .. n find something .. that will be 2moro.. meanwhile give as much info as possible ... so that we can trace the error...

as u have mentioned u r not using "C:\W080805.TXT "...still wats d content of it...
Sep 16 '08 #28
ayush patel
63 New Member
after a lot of work i found a work around not a solution though.i used Thread.Sleep(60 00); and also i placed FileWatch_Creat ed code in if loop saying if any file exists then read it else go to FileWatch_Creat ed again.

because as i increase the time in thread.sleep the service was getting delayed. so now till the service finds a file it will remain in the if else loop. it wont be a infinite loop since it is going to find a file eventually. there is a creation of file that is why it has entered into FileWatch_Creat ed event.

i dont think this is the best method but it worked.
Thanks to all who helped.

Ayush
Sep 16 '08 #29
balabaster
797 Recognized Expert Contributor
after a lot of work i found a work around not a solution though.i used Thread.Sleep(60 00); and also i placed FileWatch_Creat ed code in if loop saying if any file exists then read it else go to FileWatch_Creat ed again.

because as i increase the time in thread.sleep the service was getting delayed. so now till the service finds a file it will remain in the if else loop. it wont be a infinite loop since it is going to find a file eventually. there is a creation of file that is why it has entered into FileWatch_Creat ed event.

i dont think this is the best method but it worked.
Thanks to all who helped.

Ayush
Sorry you couldn't find a more ideal solution - it does seem like a bit of a hack to do it that way. But at least you have something until you find a way to resolve the issue properly...
Sep 16 '08 #30

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2248
by: Andrei Prodan | last post by:
Hi everyone, I have a small piece of code which uses GetObject function and it is working fine in a windows application developed under .NET In a windows service application, the GetObject function returns an error: "Cannot create ActiveX component" Does anyone knows why ??
4
5926
by: Simon Niederberger | last post by:
Hi I need to create a MessageQueue in my C# service (running as SYSTEM). Users will have no permissions on this queue, so I can't look if messages are present. When setting MessageQueue.SetPermissions, I have the problem of knowing the Windows Group Name. I'd like to set Full Control to either Users or Everyone (doesn't really matter), but the service might run under English (Users, Everyone) or German Windows (Benutzer, Jeder). On a...
4
2237
by: Tim Golden | last post by:
Tim Golden enlightened us with: > > Well, I'm with you. I'm sure a lot of people will chime in to point > > out just how flexible and useful and productive Linux is as a > > workstation, but every time I try to use it -- and I make an honest > > effort -- I end up back in Windows > I'm curious, what do you mean with "it" in the part "every time I try > to use it"? Fair question. I have, over the years, installed and used Gentoo,
4
15897
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group : microsoft.public.dotnet.languages.csharp URL :...
7
3925
by: Simon Harvey | last post by:
Hi everyone, I need to make a service that monitors a directory for changes in the files contained within it. I have two questions: 1. I'm going to be using a FileSystemWatcher object to do the monitoring - but do I need to somehow involve another thread to allow the service to do other stuff as well, or is another thread created automatically when the FileSystemMonitor object is created?
0
1308
by: pithhelmet | last post by:
Hello everyone - I need to create a windows service that will watch for a specific dialog, and when found, send a keypress to the dialog. I have the service working, but when it tries to find the window (dialog) it always comes back with zero. Now - in my test application (not service) it runs fine....
0
2670
by: artsohc | last post by:
Hey Everyone, this is my first time posting so go easy on me. I am trying to hook up music-on-hold at the office I work at. I got all the music loaded and I got Windows Media Player working while the phones are on hold, but now I am trying to write a script that will allow Windows Media Player to run as a service so I can make it auto-start with out needing a user logged in on the computer. Also it would allow the music-on-hold to work if we...
1
2002
by: icecroft | last post by:
Hello everyone! We're running a windows service application and it gets this error: "the service did not respond to the start or control request in a timely fashion". It works in most machines but for these 2 other machines (from our consultant & client), one is running on WinXP and the other is Windows Server 2003, the application doesn't seem to run. In addition to this, the WinServer2003 machine logs this error in the System event...
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10252
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.