Bug 45113 - Can't run a C# android app using an FSharp 4.0 Library
Summary: Can't run a C# android app using an FSharp 4.0 Library
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 7.0 (C8)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
Depends on:
Reported: 2016-10-06 13:33 UTC by Yann ROBIN
Modified: 2016-10-07 18:31 UTC (History)
2 users (show)

Tags: fsharp android
Is this bug a regression?: Yes
Last known good build: XATriaged

repro project (24.25 KB, application/x-zip-compressed)
2016-10-06 13:33 UTC, Yann ROBIN

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:

Description Yann ROBIN 2016-10-06 13:33:34 UTC
Created attachment 17905 [details]
repro project


In my project I have a FSharp 4.0 Library. May main application is a C# project.
I referenced the F# project from my C# app.

When I run part of code from the F# Library I get a missing method exception.
The missing method is part of FSharp.Core 4.0. It seems that the App is using an older version FSharp.Core.

When looking at the build output, the FSharp.Core 4.0 is in the obj and bin folder.
This only happen at Debug. When using the release mode, it works.

This a severe regression with cycle 8. As this used to work in previous release.
Also we need cycle 8 for the fix with Samsung S6 and S7.

I have two developers who can’t work right now because of this.
Comment 1 Jon Goldberger [MSFT] 2016-10-07 02:05:43 UTC
I was able to reproduce this issue in Visual Studio (Sample works as expected in Xamarin Studio)

It appears to be an issue with the Shared Runtime not using F# 4.0. If I disable the "Use Shared Runtime" option in the TestAppF Project Properties then the app runs as expected with no MissingMethodException and the F# function returns the expected result. 

## Workaround

Disable the "Use Shared Runtime" option. 

## Environment:

Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01586

Installed Version: Enterprise

Architecture and Modeling Tools   00322-80000-00000-AA208
Microsoft Architecture and Modeling Tools
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

Microsoft Visual Studio Tools for Applications 2015   00322-80000-00000-AA208
Microsoft Visual Studio Tools for Applications 2015

Visual Basic 2015   00322-80000-00000-AA208
Microsoft Visual Basic 2015

Visual C# 2015   00322-80000-00000-AA208
Microsoft Visual C# 2015

Visual C++ 2015   00322-80000-00000-AA208
Microsoft Visual C++ 2015

Visual F# 2015   00322-80000-00000-AA208
Microsoft Visual F# 2015

Windows Phone SDK 8.0 - ENU   00322-80000-00000-AA208
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   7.8.00927.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015.1   14.1.20907.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.5   14.0.20810.0
Azure App Service Tools v2.9.5

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

Command Bus, Event Stream and Async Manager   Merq
Provides ICommandBus, IEventStream and IAsyncManager MEF services for loosely coupled Visual Studio extension components communication and integration.

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

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

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

Microsoft Azure Hive Query Language Service   2.1.0000.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.40923.2

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.1700.281
Microsoft SQL Server Analysis Services Designer 
Version 13.0.1700.281

SQL Server Data Tools   14.0.60923.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.1700.281
Microsoft SQL Server Reporting Services Designers 
Version 13.0.1700.281

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript tools for Visual Studio

Visual Studio Tools for Universal Windows Apps   14.0.25527.01
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 (3b7df6f)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (96c7ba6)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS (ad1cd42)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 2 Jon Goldberger [MSFT] 2016-10-07 02:15:54 UTC
Thinking maybe it was an issue of the Shared Runtime not being updated if it was on the device already without F# 4 support, I deleted the Shared Runtime from the testing device (VS Emulator) but the issue remained.
Comment 3 dean.ellis 2016-10-07 10:41:13 UTC
Shared runtime is probably using the bundled FSharp versionn (which is known to be old). But the app is using the Nuget version of FSharp.
Comment 4 dean.ellis 2016-10-07 13:45:02 UTC
This was fixed in xamarin-android/master/df41af04 by removing the FSharp.Core from the SharedRuntime.

Should be in the next major release.
In the meantime the workaround is to not use the SharedRuntime.
Comment 5 Yann ROBIN 2016-10-07 14:27:44 UTC

When will be the next major release ? I need this quickly.

Comment 6 dean.ellis 2016-10-07 15:02:46 UTC
I'm not sure when C9 will be shipping to stable. But it should be in Alpha in the next few weeks (along with all the "Alpha" caveats). 

In the mean time the safest bet is to disable Shared Runtime in your project settings as Jon mentioned.
Comment 7 Yann ROBIN 2016-10-07 15:33:24 UTC
Disabling Shared runtime is ok for today, but every minute is money. And disabling shared runtime disable fast deployement.
So I don't want to have to use it every day.

I did not purchase a licence for a slow product. I need fast feedback cycle. Also i'm not using another channel than stable, as I don't want any more problem with xamarin.

Could you please provide a hotfix for cycle 8.