Bug 5973 - "Failed to resolve type" while browsing assembly (with fix!)
Summary: "Failed to resolve type" while browsing assembly (with fix!)
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Assembly browser ()
Version: Trunk
Hardware: PC Linux
: Low normal
Target Milestone: ---
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2012-07-03 21:17 UTC by Steve
Modified: 2012-07-05 05:11 UTC (History)
1 user (show)

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


Attachments
Patch to fix problem (624 bytes, patch)
2012-07-03 21:17 UTC, Steve
Details


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 Developer Community or GitHub 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 Steve 2012-07-03 21:17:34 UTC
Created attachment 2150 [details]
Patch to fix problem

Quite often, while browsing an assembly, it'll fail with "Failed to resolve type".  One easy way to reproduce the problem is to open up Mono's System.Windows.Forms, and try to browse the top level of the Application class -- it'll fail to resolve the System.ComponentModel.EditorBrowsableState enum.

In any case, after digging through the code for a while, the fix was easy -- it's a bug in SimpleAssemblyResolver.InternalResolve().  After it reads as assembly, it doesn't double-check that the assembly's FullName matches the one it's looking for.

In the above example, it was looking for "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and instead found "System.ComponentModel.DataAnnotations, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", and put that in the cache.  Needless to say, hilarity ensues.

The enclosed patch fixes the problem.

There's another call to ReadAssembly() a few lines later, but I don't understand the code well enough to speculate on whether this fix is applicable there.
Comment 1 Mike Krüger 2012-07-05 05:11:03 UTC
Merged.

Thanks for the fix.