472,962 Members | 2,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,962 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 1997

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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.