Edit: FYI for future readers, this issue has been fixed as of version 2.3.606.0 of BitMiracle's LibTiff.NET.
I'm using BitMiracle's LibTiff.NET (version 2.3.605.0 and below) in my C# library (compiled at .NET 3.5 | x86) and keep getting this exception when I call ReadDirectory
: System.ObjectDisposedException: Cannot write to a closed TextWriter
I realize that this seems to indicate that I have already disposed of my image before making the call...but I have not specifically done so. Is this a bug in the library or am I really missing something here?
Here is my code:
public static bool IsTiffBiTonal(String tiffFilePath)
{
VerifyFileExistence(tiffFilePath);
using (Tiff tiff = Tiff.Open(tiffFilePath, "r"))
{
do
{
if (tiff.GetField(TiffTag.BITSPERSAMPLE)[0].ToInt() == 1)
{
continue;
}
return false;
}
while (tiff.ReadDirectory()); //Error occurs here
}
return true;
}
EDIT: Ok, I have more information after some further testing, this is only happening when I'm running my unit tests! Don't know why that would change anything though.