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.
Created attachment 9875 [details]
See sample in the attachments.
Check AssemblyAttributesViewController.cs. The ViewDidLoad method is calling GetCustomAttributes(..) on the executing assembly.
When using Link all assemblies, the Assembly Attributes in the AssemblyInfo.cs are linked away, so this method return no information about the attributes in AssemblyInfo.cs. When I switch to Link SDK only, it returns all attributes defined in AssemblyInfo.cs
When using Link all assemblies, preserve all assembly attributes.
Version: 22.214.171.124 (Business Edition)
Build date: 2015-01-08 13:39:32-0500
I have checked this issue with the help of sample app and instructions given in bug and able to reproduce the reported behaviour. Please refer the screencast : http://www.screencast.com/t/m4vjPfDBTF
Ide Log : https://gist.github.com/Udham1/e2bcb063099c733de7e4
System Log : https://gist.github.com/Udham1/8124eceaf799a9033832
Environment Info :
=== Xamarin Studio ===
Version 5.7.2 (build 1)
Installation UUID: ce927b2a-2c07-44c5-b186-09cfdafba6dc
Mono 3.12.0 ((detached/de2f33f)
GTK+ 2.24.23 (Raleigh theme)
Package version: 312000076
=== Apple Developer Tools ===
Xcode 6.1.1 (6611)
=== Xamarin.iOS ===
Version: 126.96.36.199 (Business Edition)
Build date: 2015-02-15 22:17:46-0500
=== Build Information ===
Release ID: 507020001
Git revision: 103486e2547553077836a5ba20a973487b983830
Build date: 2015-02-13 11:56:36-05
Xamarin addins: 8dd5b934e86ef0595c022dd3930fd40e3376ab4c
=== Operating System ===
Mac OS X 10.9.5
Darwin Xamarin76s-Mac-mini.local 13.4.0 Darwin Kernel Version 13.4.0
Sun Aug 17 19:50:11 PDT 2014
Yes, this is by design. The linker remove several attributes that are not required by the runtime for execution. For projects with several assemblies that makes a significant size difference in the final bundle size.
When you use "Link all" this same logic is applied to every assembly (unless it's marked [assembly:Preserve] or if `--linkskip=XXX` is used). When you use "Link SDK" hen the logic is only applied to the assemblies shipped by Xamarin.iOS.
Note that, in general, things like the application version number is read from the bundle itself so it will match what Apple shows in the appstore.
I'm using a shared AssemblyInfo across different platforms.
How can I preserve this attributes manually? --linkskip=mscorlib is not what I want. When I enable Link SDK only it adds more than 10MB to my app size, so using Linking All is necessary.
What assembly do you read the custom attributes from ?
Let's say it's `X.dll` then you can add `--linkskip=X` and this specific assembly (not the others) won't be modified by the managed linker (and will have all the attributes).
Using `--linkskip=mscorlib` would be one of the worse cases, but it's unlikely that it's those attributes you need (or "Link SDK" would not work for you, as it process mscorlib.dll).
I read from Assembly.GetExecutingAssembly();
In the testcase is this 'AssemblyAttributes, Version=188.8.131.52748, Culture=neutral, PublicKeyToken=null'
Lets say, I want the sample app with 'Link all assemblies'. How can I preserve the attributes defined in the AssemblyInfo.cs so I can use them in the app?
I can use --linkskip=AssemblyAttributes, but the code in my application is not linked away when I don't use it...
If it's a shared AssemblyInfo then you should be able to use any assembly (pick the smallest one for the smallest impact on size) to gather the attributes.
> var assembly = typeof (type.from.the.small.assembly).Assembly.Get GetCustomAttributes (...);
No, it's not a shared assembly. It is a shared AssemblyInfo.cs file across different projects, like iOS and Android with default information about the company, version number of the product.