This project has moved. For the latest updates, please go here.
1
Vote

Closed exception file when using ElevatedTrustDriver

description

Look at this post:
https://sterling.codeplex.com/discussions/448461

We get the same error in that post, and we changed sterling source code. please look at comments.
public BinaryWriter GetWriter(string path)
{
      BinaryWriter binaryWriter = null;
      try
      {
           Monitor.Enter(_writerMutex);
           binaryWriter = new BinaryWriter(File.Open(path, FileMode.Create, FileAccess.Write));
           return binaryWriter;
      }
     catch(Exception ex)
     {
           throw new SterlingElevatedTrustException(ex);
     }
     finally
     {
          /* We remove this code, I just post this issue to confirm this issue is exist, our solution is correct? please sterling team advise, thanks.
          if (binaryWriter != null)
                 binaryWriter.Close();

         */ 

          Monitor.Exit(_writerMutex);
     }
}

comments

petermorlion wrote Sep 27, 2013 at 10:47 AM

I find this strange, as I'm using SterlingDB in an application that is being actively used and don't have this problem. But I am using the IsolatedStorageDriver, and I guess you are using the ElevatedTrustDriver? The Iso driver doesn't do that, and I'm not sure why the FileSystemDriver does.

If it works for you, I'd say go with it, but you'd probably have to see that you close the writer somewhere. I currently don't have the time to invest in Sterling anymore, and the core team (I helped out) are now making Sterling v2 (on GitHub).