Bug 55862 - Bad Error With XAMLC And Incorrect TypeConverter
Summary: Bad Error With XAMLC And Incorrect TypeConverter
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Stephane Delcroix
URL:
Depends on:
Blocks:
 
Reported: 2017-05-01 16:42 UTC by Hines Vaughan III
Modified: 2017-06-10 19:11 UTC (History)
4 users (show)

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


Attachments
Solution Showing Bad IL Exception Message (173.79 KB, application/zip)
2017-05-01 16:42 UTC, Hines Vaughan III
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 Hines Vaughan III 2017-05-01 16:42:17 UTC
Created attachment 21903 [details]
Solution Showing Bad IL Exception Message

This is not necessarily a bug so maybe I should not be submitting it as a BUG report, if so I apologize, please let me know a better place to put this, if it deserves to be put somewhere else.

The following exception messages are generated when the incorrect ThicknessTypeConverter annotation was put on a custom Button control derived from the normal Xamarin Forms Button. Also of note, I am assigning a value to the IntThickness property within a Style that is declared in my App.xaml file. Obviously I should get an exception message but I wonder if it could be more helpful somehow, especially when XAMLC is turned on.

When XAMLC is turned ON I get the following exception message:

System.InvalidProgramException: Invalid IL code in XamlCConverterError.App:InitializeComponent (): IL_008e: box       0x02000003

When XAMLC is turned OFF I get the following exception message (this exception might be fine as is):

Xamarin.Forms.Xaml.XamlParseException: Position 8:6. Cannot assign property "Resources": Property does not exists, or is not assignable, or mismatching type between value and property


By incorrect 'ThicknessTypeConverter', I mean that I added a new property to my custom Button, which is of type 'IntThickness'. It is the same thing as Xamarin Forms' regular Thickness except... it takes in ints instead of doubles (mind blown, I know).

For my new 'IntThickness' class, I also created a new 'IntThicknessTypeConverter' which I planned to add as an annotation above my IntThickness class. The issue came when I accidentally specified the regular 'ThicknessTypeConverter' annotation above my 'IntThickness' class instead of using the correct 'IntThicknessTypeConverter'.


Because I just typed the word "Thickness" 20 times or so, I have attached a sample project that recreates the issue (most everything is contained in the App.xaml.cs file).


Tested on an iPhone 4s 8.4 simulator and an Android 7.1 Genymotion emulator.


Below is the full exception messages received when running the project on the iOS simulator (the messages themselves were not any different), let me know if you would like the native iOS stack traces or if you would like the stack traces when run on the Android emulator.

EXCEPTION WITH XAMLC TURNED ON --

System.InvalidProgramException: Invalid IL code in XamlCConverterError.App:InitializeComponent (): IL_008e: box       0x02000003
  at XamlCConverterError.App..ctor () [0x00008] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError\App.xaml.cs:12 
  at XamlCConverterError.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError.iOS\AppDelegate.cs:23 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String 
delegateClassName) [0x00038] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at XamlCConverterError.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError.iOS\Main.cs:14 
2017-05-01 11:17:28.440 XamlCConverterError.iOS[48854:2455695] Unhandled managed exception:
Invalid IL code in XamlCConverterError.App:InitializeComponent (): IL_008e: box       0x02000003

 (System.InvalidProgramException)
  at XamlCConverterError.App..ctor () [0x00008] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError\App.xaml.cs:12 
  at XamlCConverterError.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError.iOS\AppDelegate.cs:23 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intp
tr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at XamlCConverterError.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError.iOS\Main.cs:14

------------------------------------------------------------------------------------------------

EXCEPTION WITH XAMLC TURNED OFF --

Unhandled Exception:
Xamarin.Forms.Xaml.XamlParseException: Position 8:6. Cannot assign property "Resources": Property does not exists, or is not assignable, or mismatching type between value and property
  at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.SetPropertyValue (System.Object xamlelement, Xamarin.Forms.Xaml.XmlName propertyName, System.Object value, System.Object rootElement, Xamarin.Forms.Xaml.INode node, Xamarin.Forms.Xaml.HydratationContext context, System.Xml.IXmlLineInfo lineInfo) [0x000de] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\ApplyPropertiesVisitor.cs:310 
  at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, Xamarin.Forms.Xaml.INode parentNode) [0x000fc] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\ApplyPropertiesVisitor.cs:120 
  at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x000b1
] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\XamlNode.cs:175 
  at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00054] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\XamlNode.cs:223 
  at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydratationContext visitorContext) [0x0007a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\XamlLoader.cs:125 
  at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml) [0x00046] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\XamlLoader.cs:76 
  at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.Type callingType) [0x0002f] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\XamlLoader.cs:56 
  at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (TXaml view, System.Type callingType) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\ViewExtensio
ns.cs:36 
  at XamlCConverterError.App.InitializeComponent () [0x00001] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError\obj\Debug\XamlCConverterError.App.xaml.g.cs:20 
  at XamlCConverterError.App..ctor () [0x00008] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError\App.xaml.cs:12 
  at XamlCConverterError.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError.iOS\AppDelegate.cs:23 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String dele
gateClassName) [0x00038] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at XamlCConverterError.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError.iOS\Main.cs:14 
2017-05-01 11:14:26.691 XamlCConverterError.iOS[48553:2449061] Unhandled managed exception:
Position 8:6. Cannot assign property "Resources": Property does not exists, or is not assignable, or mismatching type between value and property (Xamarin.Forms.Xaml.XamlParseException)
  at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.SetPropertyValue (System.Object xamlelement, Xamarin.Forms.Xaml.XmlName propertyName, System.Object value, System.Object rootElement, Xamarin.Forms.Xaml.INode node, Xamarin.Forms.Xaml.HydratationContext context, System.Xml.IXmlLineInfo lineInfo) [0x000de] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\ApplyPropertiesVisitor.cs:310 
  at Xamarin.Forms.Xaml.ApplyPropertiesVisitor
.Visit (Xamarin.Forms.Xaml.ElementNode node, Xamarin.Forms.Xaml.INode parentNode) [0x000fc] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\ApplyPropertiesVisitor.cs:120 
  at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x000b1] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\XamlNode.cs:175 
  at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00054] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\XamlNode.cs:223 
  at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydratationContext visitorContext) [0x0007a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\XamlLoader.cs:125 
  at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml) [0x00046] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\XamlLoader.cs:76 
  at Xamarin.Forms.Xaml.XamlLoa
der.Load (System.Object view, System.Type callingType) [0x0002f] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\XamlLoader.cs:56 
  at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (TXaml view, System.Type callingType) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Xaml\ViewExtensions.cs:36 
  at XamlCConverterError.App.InitializeComponent () [0x00001] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError\obj\Debug\XamlCConverterError.App.xaml.g.cs:20 
  at XamlCConverterError.App..ctor () [0x00008] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError\App.xaml.cs:12 
  at XamlCConverterError.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError.iOS\AppDelegate.cs:23 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intpt
r)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4466/a04678c2/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at XamlCConverterError.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\me\Documents\XamlCConverterError\XamlCConverterError\XamlCConverterError.iOS\Main.cs:14



Visual Studio 2015 Version Stuff (all updated to latest):

Microsoft Visual Studio Professional 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01055

Installed Version: Professional

LightSwitch for Visual Studio 2015   00322-40000-00000-AA625
Microsoft LightSwitch for Visual Studio 2015

Microsoft Visual Studio Tools for Applications 2015   00322-40000-00000-AA625
Microsoft Visual Studio Tools for Applications 2015

Visual Basic 2015   00322-40000-00000-AA625
Microsoft Visual Basic 2015

Visual C# 2015   00322-40000-00000-AA625
Microsoft Visual C# 2015

Visual C++ 2015   00322-40000-00000-AA625
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - ENU   00322-40000-00000-AA625
Windows Phone SDK 8.0 - ENU

ActiveReports 10   10.2.8028.0
The first report writer for Microsoft .NET

ASP.NET and Web Tools 2015.1   14.1.21111.0
ASP.NET and Web Tools 2015.1

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Azure App Service Tools v2.9.6   14.0.21111.0
Azure App Service Tools v2.9.6

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.2.2100.0
Microsoft Azure Data Lake Tools for Visual Studio

Common Azure Tools   1.8
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GitHub.VisualStudio   2.2.0.10
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JetBrains ReSharper Ultimate 2017.1.2    Build 108.0.20170428.75743
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2017 JetBrains, Inc.

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft .NET Core Tools (Preview 2)   14.1.21111.0
Microsoft .NET Core Tools (Preview 2)

Microsoft Azure Hive Query Language Service   2.2.2100.0
Language service for Hive query

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2015 - v2.9.41104.6

Mono Debugging for Visual Studio   Mono.Debugging.VisualStudio
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   3.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Analysis Services   13.0.1701.8
Microsoft SQL Server Analysis Services Designer 
Version 13.0.1701.8

SQL Server Data Tools   14.0.61021.0
Microsoft SQL Server Data Tools

SQL Server Integration Services   
Microsoft SQL Server Integration Services Designer
Version 13.0.1601.5

SQL Server Reporting Services   13.0.1701.8
Microsoft SQL Server Reporting Services Designers 
Version 13.0.1701.8

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

Trailing Whitespace Visualizer   2.5.83
Keeps your code files clean by making it easier than ever to identify and remove any trailing whitespace

TypeScript   1.8.36.0
TypeScript tools for Visual Studio

Visual Studio Spell Check Everywhere   VSSpellCheckEverywhere
An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Spell Checker   VSSpellChecker
An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows.
https://GitHub.com/EWSoftware/VSSpellChecker

Xamarin   4.4.0.34 (3f99c5a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.2.0.7 (b16fb82)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.8.0.174 (7656cc6)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 1 Stephane Delcroix 2017-05-08 08:18:42 UTC
Thanks for reporting this. A bug is fine. XamlC shouldn't generate bad IL, but instead validate and throw at compilation time.
Comment 2 Samantha Houts [MSFT] 2017-05-09 18:04:24 UTC
https://github.com/xamarin/Xamarin.Forms/pull/909
Comment 3 Hines Vaughan III 2017-05-09 18:26:54 UTC
Y'all are awesome! Thank you very much for such a quick fix on this.
Comment 4 Stephane Delcroix 2017-06-10 19:11:28 UTC
this will be fixed in 3.0-pre1