Bug 3375 - System.Security.Cryptography.HashAlgorithm.Dispose not present in .NET 4
Summary: System.Security.Cryptography.HashAlgorithm.Dispose not present in .NET 4
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-02-10 10:02 UTC by Simon Chisholm
Modified: 2012-03-23 08:25 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Simon Chisholm 2012-02-10 10:02:49 UTC
As title.  For 2.10.5 and 2.10.6 at least, the .NET 4.0 System.Security assembly doesn't contain a Dispose() method in its HashAlgorithm class.

HashAlgorithm.cs does contain the code, guarded by a #if NET_4_0 check but the code hasn't been included in the build output.
Comment 1 Sebastien Pouliot 2012-03-22 20:58:04 UTC
The HashAlgorithm type is in mscorlib.dll (not System.Security.dll) and does not publicly expose Dispose because this, like a lot of 4.0 changes, are only available in Mono 2.11+ (or if you build from source).

note: it's not in the source code for HashAlgorithm.cs in the 'mono-2-10' branch - you're probably looking at the source code for 'master'.

I'll backport 940bdeca94be89d2423165e741165a4832b8e724 (it occurs in several types, not just HashAlgorithm) to mono-2-10 for future releases. In the mean time a workaround is to cast to IDisposable before calling Dispose, e.g. 
   (hash as IDisposable).Dispose();
Comment 2 Sebastien Pouliot 2012-03-23 08:25:37 UTC
backported in mono-2-10 : 6e7c741e825596b8cbaf00787d0c49eccf246a7c