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

VB.NET Service and StreamWriter - File In Use Error

I'm writing a service in VB.NET. Reference the following code:

Dim oStreamWriter As StreamWriter
....
....
....
oStreamWriter = File.CreateText(TempLogFile)
If Err.Number <> 0 Then
EventLog.WriteEntry("LogService", "Error Creating Log File: " & _
TempLogFile & vbCrLf & _
"Error Code: " & Err.Number.ToString & vbCrLf & _
"Description: " & Err.Description.ToString, & _
EventLogEntryType.Error, 1004)
EventLog.WriteEntry("LogService", "Service Terminating", & _
EventLogEntryType.Error, 1004)
End
End If
oStreamWriter.WriteLine(buffer)
If Err.Number <> 0 Then
EventLog.WriteEntry("LogService", "Error Writing Log File Header
Row: " & _
ThisLogFile & vbCrLf & _
"Error Code: " & Err.Number.ToString & vbCrLf & _
"Description: " & Err.Description.ToString, & _
EventLogEntryType.Error, 1005)
EventLog.WriteEntry("LogService", "Service Terminating", & _
EventLogEntryType.Error, 1005)
End
End If
buffer = ""
--------------------------------------------------------------
Event Log Data Follows:
Event ID: 1004
Error Creating Log File: C:\WINNT\Temp\20040714_Security.log
Error Code: 57
Description: The process cannot access the file
"C:\WINNT\Temp\20040714_Security.log" because it is being used by
another process.
--------------------------------------------------------------

I've configured the Virus scanning to not scan C:\WINNT\Temp thinking
this was causing the issue, but was not. The Event ID traces to the
error check right after File.CreateText. The file does get create (0
byte file) in the folder specified. Service is configured to run as
an identity currently with Local Admin rights also. When testing on
Windows XP development box, works fine. Testing on W2K Server results
in the above error.

Using: MDE 2003 Version 7.1.3008
.NET Framework 1.1 Version 1.1.4322
Nov 20 '05 #1
0 2029

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

Similar topics

2
by: Bonnett | last post by:
I have made a simple console application that creates a webpage from my playlist, then uploads it to my webhost. I decided to convert it to a windows service and use the FileSystemWatcher to...
1
by: redneon | last post by:
I'm trying to write a web service which, when run, writes a line to a file on the web server. I've created one under IIS and the method I'm calling looks like this... public string...
3
by: W Akthar | last post by:
Hi I am trying to create a windows service which queries SQL Server on timed intervals and depending on the results send appointments to Outlook. The problem lies when I try to create an...
1
by: DraguVaso | last post by:
Hi, I want to create a Service that Reads and Write Files, and Insert and Select Data from a Sql Server Database. I did a little test with a small Service that I wanted to write something to...
4
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
7
by: GD | last post by:
Hi, I am trying to call a webservice from a windows service application. It works only if I launch the windows service app from VS.Net 2005 (Worked around from Main()) or from a winform test...
5
by: BLUE | last post by:
I insert a string in cache in a property set and I retrieve that string in the get. I retrieve my string with Read web method and I insert it with Write web method: to try cache I do Read,...
2
by: Andez | last post by:
I've wrote a windows service that performs simple functions within our application. To ensure safe running of the service - if it errors we want to know where when how - it logs to a text file - in...
0
by: iprogrammer | last post by:
i have a problem when i try to run my windows service ..which is "Error 1053: The service did not respond to the start or control request in a timely fashion" >after this i cannot anything with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.