Rebex .NET components 2012 R3: Task-based asynchronous API & .NET 4.5 'await' support

  |   Lukas Pokorny

With the release of .NET 4.5 and Visual Studio 2012, the time has come for a major upgrade of Rebex components API. We tried to maintain backward compatibility when possible, but if you used asynchronous methods or events, you might have to change your code slightly when upgrading to this release. Please check out our 2012 R3 upgrade guide for details.

So what's new in this version?

Task-based asynchronous methods

The major change is the addition of new Task-based asynchronous methods to .NET 4.0/4.5 variant of our components. This brings our API up-to-date with the current trends and makes it possible to utilize the new await keyword available in .NET 4.5 and Visual Studio 2012. Finally, asynchronous programming became easy and seamless. Check out some of the updated samples to see this in action!

Events now using SynchronizationContext

Previously, events raised by asynchronous methods were running in a background thread, making them hard to use in GUI applications. Now, events are raised using the SynchronizationContext captured when the asynchronous method was started, which basically means the events will run on application's GUI thread, making it possible to update application's controls directly from the event code.

Simplified Connect methods

We simplified even the most common task - connecting to a server. All you have to supply to the Connect method of Ftp, Imap, Pop3 or Smtp object is the server hostname and an SslMode. The Connect method automatically chooses the port according to the communication protocol and the specified SSL mode.

Simplified custom certificate validation

We added a new ValidatingCertificate event to Ftp, Imap, Pop3 and Smtp. It makes it much easier to write custom certificate validation routines - all you have to do is add an event handler which either calls e.Accept() or e.Reject().

 Complete list of changes:

  • All: Added .NET 4.x-style task-based asynchronous methods to objects previously using .NET 1.x-style Begin/End asynchronous pattern.
  • All: Asynchronous method events are raised using the current synchronization context for the asynchronous operation.
  • All: Added options to force the old-style event behavior (not using the current synchronization context).
  • All: Added Rebex.Legacy namespace to .NET 4.x builds to allow compiling code that uses old-style asynchronous methods.
  • All: Fixed P/Invokes in NTLM/Kerberos code.
  • All: AddRange method added to file item collections.
  • All: FIPS 140-2 compliant mode enhancements.
  • All: Fixed certificate validation issue on Windows XP and Windows Server 2003.
  • All: Added Certificate.Thumbprint property.
  • All: Fixed a bug in certificate chain building routine that caused it to ignore additional stores in some cases.
  • All: Fixed bugs in DIGEST-MD5 authentication that caused it to fail with some servers (SMTP, POP3, IMAP).
  • All: Mail address writer quotes address parts if needed.
  • FTP: Added Ftp.Settings.As400ListingDateFormat property to make it possible to specify AS/400 listing date format.
  • FTP: Added Ftp.Settings.UploadCommand to make it possible to specify a different upload command to be used instead of STOR.
  • FTP: Removed deprecated Ftp.SetTransferType and Ftp.Logoff methods.
  • FTP: Removed unused FtpBatchTransferOperation.FileDataBlockProcessed value.
  • FTP: FtpException.Response is now set for some OperationFailure errors as well.
  • FTP: Ftp.DirectoryExists/FileExists methods enhanced to support more servers.
  • FTP: Added a support for "cdir" field on MLST command results (fixed NullReferenceException in GetFileDateTime method with some FTP servers).
  • FTP: Added Ftp.Settings.UseLegacyPaths flag to enable old-style path reporting in multi-file operation events.
  • FTP: Fixed ActionOnExistingFiles.ResumeIfPossible behaviour to skip existing files if already transferred.
  • FTP: Multi-file operation events always report absolute paths.
  • FTP: Enhanced source path checking in multi-file operations.
  • FTP: Fixed a bug in AS/400 listing parser that caused the last modified datetime to be parsed incorrectly.
  • FTP: Added simplified Connect method overload with SslMode argument.
  • FTP: FtpBatchTransferException object was made redundant (its properties were moved to FtpException).
  • FTP: Added Ftp.Settings.RestoreDateTime property to make it possible to restore source date/time on target.
  • FTP: Fixed argument checks in GetUploadStream/GetDownloadStream methods.
  • FTP: Added Rename value to ActionOnExistingFiles enum (used in Upload/Download methods).
  • FTP: Events Traversing, TransferProgressChanged, DeleteProgressChanged and ProblemDetected added into Ftp to make it possible to get notified about significant actions and to be able to react to a problem in multi-file operations.
  • FTP: Added Ftp.Settings.SslReuseSessions option to make it possible to disable TLS/SSL session reusing for data transfers.
  • IMAP: Added OAUTH2 authentication support.
  • IMAP: Enhanced message structure parser to ignore invalid entities reported by some servers.
  • IMAP: Added simplified Connect method overloads with SslMode argument.
  • IMAP: Enhanced text part detection in IMAP message structure parser.
  • MIME: Added a new MailMessage.Sign(IEnumerable ) overload.
  • MIME: Enhanced TNEF/winmail.dat parser to support embedded messages.
  • MIME: Charset names always use lowercase letters now.
  • MIME: Added Settings property to Imap, Pop3 and Smtp objects.
  • MIME: Fixed a bug that caused an 'attachment' content-disposition to be used for resources in some cases.
  • MIME: Added support for non-MIME PKCS #7 signed attachments.
  • MIME: Added workaround to MSG parser to handle transport message headers with no line ending.
  • MIME: MimeOptions.OnlyParseHeaders now makes it possible to load headers with no CRLF ending.
  • MIME: Fixed padding of multi-value fields in TNEF/winmail.dat parser.
  • MIME: Enhanced embedded image support for TNEF/winmail.dat messages.
  • MSG: Enhanced MSG parser to handle subject values with invalid characters.
  • MSG: Fixed a bug in MSG message saving routines occasionally caused MailMessage.Save to fail when called on several MailMessage instances at the same time from multiple threads.
  • Networking: NetworkSessionException is now the base class for all network protocol exceptions.
  • Networking: Task-based asynchronous methods added to IFtp interface.
  • Networking: Removed several Socket.Available calls, resulting in higher speed and Windows Azure compatibility.
  • Networking: Events Traversing, TransferProgressChanged, DeleteProgressChanged and ProblemDetected added into IFtp to make it possible to get notified about significant actions and to be able to react to a problem in multi-file operations.
  • POP3: Multi-line response logging added.
  • POP3: Added workaround for QuarkMail server which only supports ClearText authentication.
  • POP3: Added simplified Connect method overloads with SslMode argument.
  • SCP: Added connected-check to Scp object methods.
  • SCP: Changed default SCP upload packet size from 32KB to 8KB (the former size was too big for some servers).
  • SCP: Added workaround for SCP in OpenSSH 4.x that doesn't accept quoted paths.
  • Security: Fixed a bug in TransformFinalBlock method of Rebex.Security.Cryptography ciphers that caused interoperability issues with CryptoStream.
  • Security: Fixed PKCS #7 padding check in built-in ciphers.
  • Security: Added EncodingTools class that adds support for all the charsets needed on all platforms.
  • Security: Added auto-detection of a bug in unpatched .NET 3.5's AesCryptoServiceProvider object.
  • Security: Implicit ObjectIdentifier(string) constructor added.
  • Security: Fixed CryptoHelper.CreateAlgorithm to return CSP version of SHA-2 hash algorithms when available.
  • Security: Fixed CertificateFinder property behavior to keep old certificates if no certificates are found by the new finder.
  • Security: Server certificate verification routine now allows certificats with ' *.domain.net' names to be used for 'domain.net' in addition to ' *.domain.net'.
  • Security: Fixed a bug in private key decryption routine which failed with keys encrypted with PKCS #12 key derivation algorithm.
  • SFTP: Added Sftp.Settings.RestoreDateTime property to make it possible to restore source date/time on target.
  • SFTP: Removed unused SftpBatchTransferOperation.FileDataBlockProcessed value.
  • SFTP: Changed Sftp.PutFile(..., string, long, long) behavior to truncate remote path when zero remote offset is specified (corresponds to Sftp.PutFile(..., string) behavior). Added Sftp.Settings.DisablePutFileZeroOffsetTruncate option to force old behavior.
  • SFTP: Fixed ActionOnExistingFiles.ResumeIfPossible behaviour to skip existing files if already transferred.
  • SFTP: Multi-file operation events always report absolute paths.
  • SFTP: Enhanced source path checking in multi-file operations.
  • SFTP: Fixed argument checks in GetStream/GetUploadStream/GetDownloadStream methods.
  • SFTP: Added Rename value to ActionOnExistingFiles enum (used in Upload/Download methods).
  • SFTP: Events Traversing, TransferProgressChanged, DeleteProgressChanged and ProblemDetected added into Sftp to make it possible to get notified about significant actions and to be able to react to a problem in multi-file operations.
  • SMTP: Added FIPS 140-2 compliant mode in which only FIPS-approved modules are used.
  • SMTP: Fixed Smtp.Send methods to throw SmtpException instead of ArgumentException when supplied MailMessage has missing info needed for sending.
  • SMTP: Added OAUTH2 authentication support.
  • SMTP: Support for sending messages using .NET's SMTP delivery engine added to to SmtpConfiguration-based Smtp.Send method (useful in medium trust environments).
  • SMTP: Added simplified Connect method overloads with SslMode argument.
  • SSH: Better error message for unsuccessful keboard-interactive fallback workaround.
  • SSH: Enhanced "Invalid decoder state" error reporting.
  • SSH: Added support for diffie-hellman-group-exchange-sha256 key exchange algorithm.
  • SSH: Added SshPublicKey class, SshSession.ServerKey property and FingerprintCheck.ServerKey property (to make it possible to determine server host key in addition to fingerprint).
  • SSL: Fixed a bug in server-side TLS/SSL that caused it to fail when session resuming was enabled.
  • SSL: Fixed TlsException serialization that failed for some errors.
  • SSL: Fixed a bug that caused problems with TLS/SSL in FIPS-only mode.
  • Terminal: Added VT52 terminal emulation support.
  • Terminal: Added LightBackColor value into BlinkingText enum.
  • Terminal: Added support for 'CSI 1 m' sequence.
  • Terminal: Fixed a bug that occasionally caused an exception to be thrown when scrolling using the scrollbar.
  • Terminal: Fixed socket error handling in client-side keyboard and mouse methods.
  • Terminal: Enhanced TerminalControl responsiveness under heavy load.
  • Terminal: Compatibility enhancement for the Shell class in ShellMode.Prompt.
  • Terminal: Added support for 'insertion replacement mode' ('CSI 4 h')
  • Time: Daytime.SynchronizeSystemClock and Time.SynchronizeSystemClock uses TCP in default. Added overloaded methods with useTcp argument.
  • Time: Daytime protocol response parser enhanced to be compatible with more servers.
  • ZIP: Added FIPS 140-2 compliant mode in which only FIPS-approved modules are used.
  • ZIP: Support for setting file datetimes on .NET Compact Framework.
  • ZIP: Fixed Legacy.FileSet indexer to return added paths in unchanged form.
  • ZIP: Asynchronous methods support .NET 4.x-style task-based asynchronous pattern in addition to .NET 2/3.x-style event-based pattern.
  • ZIP: Added Rename value to ActionOnExistingFiles enum (used in Add/Extract methods).
  • ZIP: Added Zip.Options.RestoreDateTime property (enhances existing RestoreFileDates option).