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.
Created attachment 11330 [details]
Failing source code
I have a code that analyses .NET DLLs with Cecil. One of this DLL is Xwt, containing a struct Xwt.Size with ValueSerializerAttribute defined.
I have bisected Mono and verified that commit 830bf66a13ea18dd8c6f67203d9a70b20349f1d6 breaks my logic - Resolve returns null. Before this commit everything works fine (and this commit description seems relevant).
As my test case requires Xwt.dll (compiled by me with the same Mono, tested many versions), I post both analyzer code and an archive with it.
I have tried to extract a simpler case from this DLL, but failed, anything simpler works for me.
Steps to reproduce the problem:
1. Compile Program.cs in Debug or Release (Cecil library is fetched by NuGet)
2. Go to Debug/Release directory
List of analyzed types and attributes in form similar to:
Xwt.PasswordEntry: 1 attributes
Xwt.PasswordEntry/WidgetBackendHost: 0 attributes
Xwt.PreviewTextInputEventArgs: 0 attributes
Xwt.Widget: 1 attributes
A beginning of this list, ending with NRE (thrown from code):
Xwt.Point: 0 attributes
Xwt.Size: 2 attributes
System.NullReferenceException: Resolve returned null!
at test31.MainClass.Main (System.String args) [...]
Created attachment 11331 [details]
The project with failing DLL
I believe I have found the actual issue.
The Xwt library was compiled against framework 4.0, and the app - 4.5.
ValueSerializerAttribute was moved from System.Xaml to System between this version.
So, TypeRef in Xwt.dll pointed to System.Xaml.dll, but Cecil opened the file from the current GAC - 4.5. Of course, there was no such type found, so Resolve failed.
It works on Windows/.NET, so I believe this is mono-specific code (BaseAssemblyResolver.GetAssemblyInGac is platform-specific).
Created attachment 11504 [details]
Updated, much simpler test case
This does not reference Xwt, but a simple library with attribute. The library is compiled against framework 4.0, the app - 4.5.
Fixed in master