I just recently struggled with this, and wanted to update this with a solution I got to work. I pulled down the latest code and built it myself so I could make changes if needed. In the SupportClass.cs file, starting at line 481 there is some code that verifies a file buffer has been flushed using unmanaged code.
if (OS.IsWindows)
{
if (!FlushFileBuffers(fileStream.Handle))
throw new System.IO.IOException();
}
else if (OS.IsUnix)
{
if (fsync(fileStream.Handle) != IntPtr.Zero)
throw new System.IO.IOException();
}
else
{
throw new NotImplementedException();
}
I commented out these lines and rebuilt the library and was able to run in medium trust. I ran locally in medium trust, as well as putting together a simple test app deployed to GoDaddy. I m not sure what the implications are of removing these lines. They appear to be duplicating the behavior of the fileStream.Flush()
call that precedes this block, but I m not sure.