Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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 for Bug 4484 on
GitHub or Developer Community if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
While porting unit tests from Windows (which pass) for the application I'm porting, I came across this one:
public void RemoveAllProductCertificates()
var store = GetProductCertificateStore();
foreach (var certificate in store.Certificates)
This is mainly used in our unit testing teardown/setup, etc. When store.Remove is called, the exception is thrown. Here's the callstack:
TearDown : System.InvalidOperationException : List has changed.
at System.Collections.ArrayList+SimpleEnumerator.MoveNext () [0x00066]
at System.Security.Cryptography.X509Certificates.X509Certificate2Enumerator.MoveNext () [0x00000]
at MyNamespace.RemoveAllProductCertificates () [0x00061]
The Certificates property simply returns a list which can't be modified in a foreach. The Windows api simply wraps other api's so there isn't an internal collection being modified when calling .Remove in the foreach.
Steps to reproduce:
1) Run the above code in a test (backup your store first!)
The code should behave as it does in Windows
A System.InvalidOperationException is thrown
Mono JIT compiler version 2.11.1 (master/ec75771 Wed Apr 11 14:13:09 EDT 2012)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
store.RemoveRange(store.Certificates) will also throw the exception.
The code below works fine.
var certs = new X509Certificate2Collection(store.Certificates);