[Mono-devel-list] Access violation after exiting a mono app with an open StreamWriter (latest builds)

Andrew Gleave Andrew.Gleave at ifgmgt.com
Mon Apr 25 09:45:00 EDT 2005


Hi,
    We have an app that uses a StreamWriter to write logging and
debugging info to a file.  If I terminate the app (Ctrl -c) when it is
running, then re-launch it, I get an access violation/ sharing violation
when the StreamWriter is created.  I can't seem to remember this being
an issue, before the IO layer became daemon-less.  This only affects
recent builds and our RedHat 9 box running 1.1.7 is fine.  However,
Debian running Revision 43534 is broken. And I know it affects Mac OS X
also.  I have included some sample code, and if needed I can file a bug
report.
 
Thanks
 
Andrew Gleave
 
Software Engineer
 
Exception:
 
Unhandled Exception: System.IO.IOException: Sharing violation on path
TestApp.log
in <0x0032a> System.IO.FileStream:.ctor (System.String name, FileMode
mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean
isAsync, Boolean anonymous)
in <0x0001f> System.IO.FileStream:.ctor (System.String name, FileMode
mode, FileAccess access, FileShare share)
in (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor
(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
in <0x000e1> System.IO.StreamWriter:.ctor (System.String path, Boolean
append, System.Text.Encoding encoding, Int32 bufferSize)
in (wrapper remoting-invoke-with-check) System.IO.StreamWriter:.ctor
(string,bool,System.Text.Encoding,int)
in <0x0004a> ConsoleApplication4.Class1:Main (System.String[] args)

 
Source:
 
using System;

using System.IO;

namespace AccessViolation

{

class AccessViolationDemo

{

[STAThread]

static void Main(string[] args)

{

StreamWriter writer = null;

string command = string.Empty;

try

{

writer = new StreamWriter("TestApp.log", true,
System.Text.Encoding.UTF8, 4096);

writer.AutoFlush = true;

writer.WriteLine("{0} - Started App. Polling for input...",
DateTime.Now);

while(command != "quit")

command = Console.ReadLine().ToLower(); 

}

finally

{

writer.Close();

writer = null;

}

}

}

}


The information contained in this E-mail is confidential. It may also be legally privileged. It is intended only for the stated addressee(s) and access to it by any other person is unauthorised. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this E-mail. Such unauthorised use may be unlawful. If you have received this E-mail in error, please inform us immediately and delete it and all copies from your system.

Due to the fact that this E-mail could become corrupted or altered during transmission, any advice which it contains should not be relied upon unless subsequently confirmed by fax or letter signed by or on behalf of this company.

E-mails do not constitute compliance with any time limits or deadlines. 

#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared 
by NetIQ MailMarshal
#####################################################################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050425/9a71ca0e/attachment.html 


More information about the Mono-devel-list mailing list