Advertisement

09.08.2008 at 02:37PM PDT, ID: 23713657
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

.NET Sharing Violation when writing files

Asked by wfssupport in .Net Editors & IDEs, Microsoft Visual Basic.Net, .NET Framework 2.x

Tags: ,

I'm  having a problem writing to a log file using vb.NET. The write only occurs in one public function in a Module. I've re-written my file write logic several different ways but still get the random sharing violations. I've also switching logging from the network drive to the local tmp folder but still get the error.

Method #1
  File.AppendAllText(LogPath, TexttoWrite)

Method #2
  Using sw As New StreamWriter(LogPath, True)
    sw.Write(TexttoWrite)
  End Using

Method #3
  Using fs As New FileStream(LogPath, FileMode.OpenOrCreate, FileAccess.Write)
    Using sw As New StreamWriter(fs)
      sw.Write(TexttoWrite)
    End Using
  End Using

I ran FileMon to see what is going on and I see the problem being two OPEN requests in a row:

4:19:35 PM      prowin32.exe:2432      OPEN      C:\tmp\DCMstn18\SENT03_18.log      SUCCESS      Options: OpenIf Sequential  Access: 00120196      
4:19:35 PM      prowin32.exe:2432      OPEN      C:\tmp\DCMstn18\SENT03_18.log      SHARING VIOLATION      Options: OpenIf Sequential  Access: 00120196      


But it also works fine 90% of the time:

4:19:35 PM      prowin32.exe:2432      OPEN      C:\tmp\DCMstn18\SENT03_18.log      SUCCESS      Options: OpenIf Sequential  Access: 00120196      
4:19:35 PM      prowin32.exe:2432      QUERY INFORMATION      C:\tmp\DCMstn18\SENT03_18.log      SUCCESS      Length: 109380      
4:19:35 PM      prowin32.exe:2432      WRITE       C:\tmp\DCMstn18\SENT03_18.log      SUCCESS      Offset: 109380 Length: 138      
4:19:35 PM      prowin32.exe:2432      CLOSE      C:\tmp\DCMstn18\SENT03_18.log      SUCCESS            
4:19:35 PM      prowin32.exe:2432      OPEN      C:\tmp\DCMstn18\SENT03_18.log      SUCCESS      Options: OpenIf Sequential  Access: 00120196      
4:19:35 PM      prowin32.exe:2432      QUERY INFORMATION      C:\tmp\DCMstn18\SENT03_18.log      SUCCESS      Length: 109518      
4:19:35 PM      prowin32.exe:2432      WRITE       C:\tmp\DCMstn18\SENT03_18.log      SUCCESS      Offset: 109518 Length: 138      
4:19:35 PM      prowin32.exe:2432      CLOSE      C:\tmp\DCMstn18\SENT03_18.log      SUCCESS            

Any tips would be appreciated, this one really has me stumped. Thanks.

 Start Free Trial
 
 
[+][-]09.08.2008 at 02:46PM PDT, ID: 22421984

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.08.2008 at 02:57PM PDT, ID: 22422069

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .Net Editors & IDEs, Microsoft Visual Basic.Net, .NET Framework 2.x
Tags: VB.NET, The process cannot access the file "xxx.xxx" because it is in use by another process
Sign Up Now!
Solution Provided By: gregoryyoung
Participating Experts: 2
Solution Grade: B
 
 
[+][-]09.08.2008 at 04:01PM PDT, ID: 22422389

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.08.2008 at 04:20PM PDT, ID: 22422489

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.09.2008 at 07:25AM PDT, ID: 22427679

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.09.2008 at 08:24AM PDT, ID: 22428394

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628