Bug 26796 - Static Reference in XAML results in XamlParseException
Summary: Static Reference in XAML results in XamlParseException
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.3
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-05 21:35 UTC by Kamil
Modified: 2015-02-25 04:58 UTC (History)
4 users (show)

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


Attachments
Simple Repro (384.82 KB, application/zip)
2015-02-05 21:35 UTC, Kamil
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 ANSWERED

Description Kamil 2015-02-05 21:35:23 UTC
Created attachment 9675 [details]
Simple Repro

I'm seeing XamlParseException's when using a Static reference to a constant / static property.  Oddly, if I add set a variable to constant in the code behind, the exception does not occur.

Simple repro solution attached.
Comment 1 Udham Singh 2015-02-06 05:50:09 UTC
I have checked this issue with sample app and able to reproduce the reported behaviour. Please refer the screencast : http://www.screencast.com/t/QL8ixQ7rs1

Application Output : https://gist.github.com/Udham1/ec027437a6c2cf423249
Build Output : https://gist.github.com/Udham1/1b75ffeefc23491e7f32
Ide Log : https://gist.github.com/Udham1/021df62b62ae3fc75fc8

Environment Info : 

Xamarin.Forms : 1.3.3.6321-pre2

=== Xamarin Studio ===

Version 5.7.1 (build 17)
Installation UUID: ce927b2a-2c07-44c5-b186-09cfdafba6dc
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: 8.6.1.24 (Business Edition)
Hash: 1ee873c
Branch: 
Build date: 2015-01-31 17:42:21-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/xamarin76/Desktop/android-sdk-macosx
	Supported Android versions:
		1.6    (API level 4)
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.Mac ===

Version: 1.12.0.4 (Business Edition)

=== Build Information ===

Release ID: 507010017
Git revision: 0bc7d3550b6b088ac25b08dcf7bbe73bcc8658b3
Build date: 2015-02-03 19:43:29-05
Xamarin addins: f7b7d34419c9ec24501bfa7c658e80a6305613e0

=== 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
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 2 Jason Smith [MSFT] 2015-02-25 04:58:10 UTC
You need to mark your ViewModels with the [Preserve] attribute so that the linker does not molest them. This is because there are not roots to the object in any other way so the linker thinks it is safe to link them away.