Bug 56974 - Using XamlCompilation() in App.xaml.cs causes MT2001 error
Summary: Using XamlCompilation() in App.xaml.cs causes MT2001 error
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.3.5
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 57530 ()
Depends on:
Blocks:
 
Reported: 2017-05-30 18:04 UTC by Derek Foulk
Modified: 2017-06-26 12:35 UTC (History)
4 users (show)

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


Attachments
Stack Trace (475.15 KB, text/plain)
2017-05-30 18:04 UTC, Derek Foulk
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 Derek Foulk 2017-05-30 18:04:12 UTC
Created attachment 22559 [details]
Stack Trace

My project has been compiling without error in 'Debug > iPhone', but when we attempted to compile in 'Release > iPhone' mode- compilation fails with the following error:

> /Users/dfoulk/Projects/OSCC-FF/OSCC-FF/OSCC-FF.iOS/MTOUCH: Error MT2001: Could not link assemblies. (MT2001) (OSCC_FF.iOS)

Please see attached for the trace log.

To recreate the issue:
1) Create a new Xamarin Forms project in Visual Studio
2) Update Xamarin.Forms to v2.3.5.233-pre1
3) Ensure that App.xaml.cs has this just before the namespace declaration: "[assembly: XamlCompilation(XamlCompilationOptions.Compile)]" (and remove any other instances of this line from other pages if applicable)
4) It may be necessary to enable (check) the 'iOS IPA Options > Build iTunes Package Archive (IPA)' option in the iOS project

Note: We are using a "Distribution" Signing Identity & an Enterprise Provisioning Profile (not sure if this affects the outcome).

We expected the app to compile without error, but it compiled with the above error.

(Build 2017-05-30 on macOS Sierra v10.12.5)

Our workaround: We had to remove the "[assembly: XamlCompilation(XamlCompilationOptions.Compile)]" line from our App.xaml.cs file to build our iOS app. This is not what we want to do as this negatively impacts the performance of our application!
Comment 1 Paul DiPietro [MSFT] 2017-05-30 21:59:14 UTC

*** This bug has been marked as a duplicate of bug 56281 ***
Comment 2 Derek Foulk 2017-06-01 16:32:40 UTC
It seems as though my issue may be different than bug 56281. Yes, the error is the same, but evidently it is a very generic error and can be caused by many things.

Thanks!
Comment 3 Derek Foulk 2017-06-01 16:41:38 UTC
Also, the bug that I was supposedly duplicating was also marked as a duplicate and was supposed to be fixed as of v2.3.4.247.

I am using Xamarin.Forms v2.3.5.233-pre1. That being said, my project was originally created with Xamarin.Forms v2.3.3.193.

Finally, this project was building just fine until 5/30. I'm not sure if I did any updates that day... Here is my current environment:

Microsoft Visual Studio Professional 2017 
Version 15.2 (26430.6) Release
VisualStudio.15.Release/15.2.0+26430.6
Microsoft .NET Framework
Version 4.6.01586

Installed Version: Professional

Visual Basic 2017   00370-20004-74785-AA463
Microsoft Visual Basic 2017

Visual C# 2017   00370-20004-74785-AA463
Microsoft Visual C# 2017

Visual C++ 2017   00370-20004-74785-AA463
Microsoft Visual C++ 2017

Visual F# 4.1   00370-20004-74785-AA463
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.6.00404.2
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30503.0
ASP.NET and Web Tools 2017

ASP.NET Web Frameworks and Tools 2017   5.2.50303.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30209.0
Azure App Service Tools v3.0.0

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.5000.0
Microsoft Azure Data Lake Tools for Visual Studio

CodeMaid   10.4.53
CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.

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

GitFlow.VS.Extension   1.0
Visual Studio extension that integrates GitFlow

GitHub.VisualStudio   2.2.0.11
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

JavaScript UWP Project System   2.0
JavaScript UWP 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.

KofePackagePackage Extension   1.0
KofePackagePackage Visual Studio Extension Detailed Info

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

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

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50131.1

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

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

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

SQL Server Data Tools   15.1.61702.140
Microsoft SQL Server Data Tools

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript   2.2.2.0
TypeScript tools for Visual Studio

Visual Studio Tools for Universal Windows Apps   15.0.26430.06
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin   4.5.0.443 (c871575)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.3.0.13 (448f54f)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   10.10.0.30 (30b6e87)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 4 Cody Beyer (MSFT) 2017-06-16 21:05:58 UTC
I was unable to reproduce this issue using the latest preview 2.3.5.239-pre3 running the latest Xamarin.Visual Studio 4.5.0.486

If this is still occuring for you, please provide a full test sample which reproduces the issue.

Thanks!
Comment 5 Derek Foulk 2017-06-19 17:13:07 UTC
Hi Cody, I don't use prerelease packages in my projects... It's just bit me in the rear before (using unstable packages). I guess I'll just wait for a stable release of 2.3.5. Thanks
Comment 6 Rolf Bjarne Kvinge [MSFT] 2017-06-26 12:35:05 UTC
*** Bug 57530 has been marked as a duplicate of this bug. ***