[Mono-list] different filestream behavior of mono and .net

Jörg Würzer joerg.wuerzer@ixos.de
Mon, 16 Jun 2003 11:05:21 +0200

hello mono community,

i'm porting some com classes to win/.net in our company. therefore im
porting them so, they work with mono and .net. now i've noticed some
differences in behavior between mono and .net.

system: redhat 8, mono 0.24-2 (rpm install).

following code compiled with .net doesn't run under mono/linux but under

// -->
using System;
using System.IO;

namespace FileStreamTest
	class Class1
		static void Main(string[] args)
			FileStream fs = new
FileStream("test",FileMode.Append); //here is the difference
			StreamWriter sw = new StreamWriter(fs);
// <--

under win/.net this code works fine, but under linux/mono following error
message below returns.

** (process:1983): WARNING **: Shared memory sanity check failed.

** (process:1983): WARNING **: Failed to attach shared memory! Falling back
to non-shared handles

Unhandled Exception: System.ArgumentException: Append streams can not be
in <0x00258> 00 System.IO.FileStream:.ctor
in <0x00045> 00 System.IO.FileStream:.ctor (string,System.IO.FileMode)
in <0x0003a> 00 FileStreamTest.Class1:Main (string[])

so I explicitly must define FileAccess.Write in my FileStream object
creation. See below.

// -->
FileStream fs = new FileStream("test",FileMode.Append,FileAccess.Write);
// <--

this doesn't matter if known, but it's a different behavior.

have a nice day, Joerg Wuerzer