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
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.
I have a library that contains resources. When the class is called from the application the layout id's and widget id's are incorrect.
In the library I have an activity that calls SetContentView(Resource.Layout.login). Instead of the correct layout being displayed the layout it is displaying is the layout that corresponds to the number defined in the application's Resource.Designer.cs (CustomerDetail).
In the Library I have:
public static int login = 2130903059;
In the application I have:
public const int CustomerDetail = 2130903059;
public const int login = 2130903110;
If I change the code to SetContentView(2130903110) then it works.
Clearly a disjoint in the compiler in determining what the value should be.
I don't see a work around and I need this ASAP as this proper library functionality is mandatory for the project that I'm in the middle of.
Of further note when debugging, SetContentView(Resource.Layout.login) is showing 2130903110 in quick watch because it is getting confused between Library.Resource.Layout and Application.Resource.Layout. i.e. quick watch is showing Application.Resource.Layout instead of Library.Resource.Layout.
I was able to figure it out. I needed to call Resource.UpdateIdValues() in the constructor of my main activity. Is there no way that this could be done automatically?
Oops! You're right, thanks for pointing it out. I totally forgot to add resource ID initializer code as in each resource designer's static constructor. It is fixed in our codebase and will be included in the next major release.
Until the fix arrives, please add call to Android.Runtime.ResourceIdManager.UpdateIdValues() somewhere around your app bootstrap (I added this method exactly for this purpose).