You need to override the WarningHandler() and WarningHandlerExt() methods with the correct signature:
public class DisableErrorHandler : TiffErrorHandler
{
public override void WarningHandler(Tiff tif, string method, string format, params object[] args)
{
// do nothing, ie, do not write warnings to console
}
public override void WarningHandlerExt(Tiff tif, object clientData, string method, string format, params object[] args)
{
// do nothing ie, do not write warnings to console
}
}
By having the correct method signature and method names the override keyword is required. Once you override the methods successfully, then setting the error handler to your new methods will work correctly:
Tiff.SetErrorHandler(new DisableErrorHandler());
// now no warnings will be sent to console
using (Tiff tiff = Tiff.Open(fn, "r"))
{ .....
Notice we have only overridden the warning handlers. You could of course override the error handlers as well. Reference:
https://bitmiracle.github.io/libtiff.net/help/api/BitMiracle.LibTiff.Classic.TiffErrorHandler.html