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 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.
Mono's Windows.Forms simply adds info for Group regardless if it's null or not, ie:
info.AddValue ("Group", group);
Microsoft.NET will crash if it encounters a null Group, since it expects it to not be null if present (tries to access .Name).
Created attachment 1493 [details]
The patch I've applied to my local build to correct the problem
Could you please come up with a unit test, or at least a test case for this? I tried to come up with one, but I can't manage to serialize a ListViewItem. I get an exception that says it can't serialize the Font property, because it has no parameterless constructor.
Here's my code so far:
[Test] // Xamarin bug 3840
public void TestNullGroupSerialization ()
ListViewItem item = new ListViewItem ();
item.Group = null;
XmlSerializer ser = new XmlSerializer(item.GetType()); // Does not work
StringBuilder sb = new StringBuilder();
StringWriter writer = new StringWriter(sb);
I'm not sure if you could create an adequate test for this since the problem is Mono is serializing ListViewItem in a way that causes MS.NET to crash when deserializing when running a Mono compiled executable.
You can trigger the problem by simply creating a new WinForms project, adding a ListView, adding an item to that ListView, compiling that project under Mono, then run the resulting executable under MS.NET.
Created attachment 2052 [details]
I followed your instructions, but it worked for me. I created the WinForms project with ListView and ListViewItem, built it on Linux with Mono (.NET 3.5 profile), in Debug and Release mode, then tried the executables on Windows + .NET, and they worked with no issues.
Here's my WinForms project.
Created attachment 2054 [details]
Test case (modified)
Ahh, sorry, I fixed this in my local build awhile ago that I forgot the exact details, so I reproduced the problem.
ListView.Items become serialized as part of resources (.resx) when the form is Localizable (so the strings in the ListView.Items are localizable).
Attached is the modified version of your test case, which reproduces the crash, the only thing I did was change Localizable on the form to True and save.
Alright, I've pushed your patch (commit b9d24579836115a452ca148a8ee8e82f4085f03b). Thanks!