Bug 52738 - Project tries to load FSharp.Core.resources.dll
Summary: Project tries to load FSharp.Core.resources.dll
Status: NEEDINFO
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 7.1 (C9)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-02-24 11:48 UTC by Rob Lyndon
Modified: 2017-03-08 15:49 UTC (History)
3 users (show)

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


Attachments
Runtime error (116.28 KB, image/png)
2017-03-02 13:41 UTC, Jason Imison
Details
Runtime error (185.25 KB, image/png)
2017-03-02 16:20 UTC, Jason Imison
Details
Runtime error in action (130.09 KB, image/png)
2017-03-08 15:47 UTC, Rob Lyndon
Details
First instance of runtime error (177.11 KB, image/png)
2017-03-08 15:49 UTC, Rob Lyndon
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 for Bug 52738 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEEDINFO

Description Rob Lyndon 2017-02-24 11:48:01 UTC
After installing the latest version of Xamarin, my F# Android project no longer launches correctly.

Clone https://github.com/SpiegelSoft/Astrid, and set the startup project to Astrid.Mobile.Droid. Start the solution in Debug mode.

An error is thrown when an F# expression is loaded (causing FSharp.Core.dll to start deserialising the expression).

The error message is 

Could not load file or assembly '/storage/emulated/0/Android/data/Astrid.Mobile.Droid/files/.__override__/en-US/FSharp.Core.resources.dll' or one of its dependencies

and the call stack is

 	0x17 in System.Reflection.Assembly.LoadFrom	C#
 	0x2 in System.Reflection.Assembly.LoadFrom at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:532,4	C#
 	0xC7 in System.Reflection.Assembly.InternalGetSatelliteAssembly at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:511,5	C#
 	0x60 in System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/resources/manifestbasedresourcegroveler.cs:560,17	C#
 	0x3E in System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/resources/manifestbasedresourcegroveler.cs:89,17	C#
 	0xBA in System.Resources.ResourceManager.InternalGetResourceSet at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs:809,17	C#
 	0x8 in System.Resources.ResourceManager.InternalGetResourceSet at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs:753,13	C#
 	0x6E in System.Resources.ResourceManager.GetString at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs:1317,21	C#
 	0x10 in <StartupCode$FSharp-Core>.$Prim-types..cctor	C#
 	0x0 in Microsoft.FSharp.Core.LanguagePrimitives.get_Int32Comparer	C#
 	0x79 in Microsoft.FSharp.Core.LanguagePrimitives..cctor$cont@2358-3<int>	C#
 	0xEF in Microsoft.FSharp.Core.LanguagePrimitives.FastGenericComparerTable<int>..cctor	C#
 	0x2 in Microsoft.FSharp.Collections.FSharpMap<int,Microsoft.FSharp.Quotations.FSharpVar>..cctor	C#
 	0x6 in Microsoft.FSharp.Quotations.PatternsModule.deserialize	C#
 	0x76 in Microsoft.FSharp.Quotations.FSharpExpr.Deserialize40	C#
 	0xDF in XamarinForms.Reactive.FSharp.PageViewModel..ctor	C#

I suspect this is because the deserialiser is trying to find resources from the FSharp.Core.dll assembly. There is a related StackOverflow question at http://stackoverflow.com/questions/42428907/f-xamarin-forms-dll-loading-error-after-upgrading-fsharp-core-nuget-package
Comment 1 Rob Lyndon 2017-02-27 10:42:47 UTC
Hey guys -- any update on this? It is a complete showstopper for my project, and I'm working to a deadline. Are there any workarounds I can use while I'm waiting for a fix?
Comment 2 dean.ellis 2017-02-27 13:48:14 UTC
Hi Rob

I took a look at this today, I am having problems building the project locally. 

Firstly PCL Profile 75 does not appear to exist on Mac (I changed to 78) and the AndroidManifest.xml file is missing from the repo.  I aded my own manifestm but did you do any special modifications?
Comment 3 dean.ellis 2017-02-27 13:55:20 UTC
I get problems with the Maps, probably because the keys are missing.
Comment 4 Rob Lyndon 2017-02-27 15:57:59 UTC
Hi Dean -- can you do a pull please? I replaced Profile 75 with a duplicate of the same project using Profile 259.

AndroidManifest.xml is in my .gitignore. Here it is for now:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Astrid.Mobile.Droid" android:versionCode="1" android:versionName="1.0">
  <uses-sdk android:minSdkVersion="16" />
  <application android:label="Astrid.Mobile.Droid"></application>
</manifest>
Comment 5 dean.ellis 2017-02-27 16:14:37 UTC
I got the code building but I get the following at run time

"Method 'Android.Gms.Maps.MapView.get_Map' not found."

using the latest Stable xamarin.android.
Comment 6 Rob Lyndon 2017-02-27 16:19:05 UTC
That's listed as a separate bug: https://bugzilla.xamarin.com/show_bug.cgi?id=52625
Comment 7 Rob Lyndon 2017-02-27 16:20:01 UTC
So is this a Visual Studio problem?

I don't think FSharp.Core.resources.dll exists.
Comment 8 Rob Lyndon 2017-02-27 16:28:42 UTC
Running from Visual Studio, I get the same issue:

Could not load file or assembly '/storage/emulated/0/Android/data/Astrid.Mobile.Droid/files/.__override__/en-GB/FSharp.Core.resources.dll' or one of its dependencies
Comment 9 dean.ellis 2017-02-27 16:53:00 UTC
I think this is a F# problem. the Nuget package for FSharp.Core does not seem to include FSharp.Core.resources.dll.
Comment 10 Rob Lyndon 2017-02-27 17:06:32 UTC
So looking at the call stack -- InternalGetSatelliteAssembly -- it seems that it is interpreting FSharp.Core.dll incorrectly, and assuming that it needs to load the satellite assembly FSharp.Core.resources.dll, which doesn't exist.

When I first hit this issue, I looked for FSharp.Core.resources.dll online, and all I could find was a set of phishing websites. That assembly clearly doesn't exist anywhere.
Comment 11 dean.ellis 2017-02-28 09:54:36 UTC
@Rob

How did you work around Bug 52625, because I can't get past that issue to investigate the other one.
Comment 12 Rob Lyndon 2017-02-28 11:30:35 UTC
I didn't. This bug prevents me from getting that far, because it crashes on the first instantiation of DashboardViewModel.

I'm running Visual Studio (2015 and 2017RC) on Windows 10.

Android SDK Tools 25.2.5
Android SDK Platform-Tools 25.0.3
Android SDK Build-Tools 25.0.2

I've also got Build-Tools 25.0.1 and 23.0.3. I'll remove those and see if that changes anything.
Comment 13 Rob Lyndon 2017-02-28 11:52:18 UTC
Removing the two extraneous Build-Tools packages didn't help.
Comment 14 Rob Lyndon 2017-02-28 15:58:57 UTC
I've reinstalled as many packages as possible -- still getting exactly the same behaviour.

Could not load file or assembly '/storage/emulated/0/Android/data/com.astrid/files/.__override__/en-GB/FSharp.Core.resources.dll' or one of its dependencies
Comment 15 Rob Lyndon 2017-03-01 12:20:01 UTC
I'm looking through the source code as https://referencesource.microsoft.com/#mscorlib/system/resources/manifestbasedresourcegroveler.cs.

It is as I suspected: GetSatelliteAssemblyName() is adding ".resources" to the DLL name. I need to work out why it's being called for FSharp.Core.dll.
Comment 16 Rob Lyndon 2017-03-01 18:20:13 UTC
@Dean

I've been researching this a lot. Note the 

.__override__/en-US/

segment in the error message. It is trying to look for resources in FSharp.Core.dll; it also explains why the build is working for you but not for me. If you are set up on a Mac, all of your settings will be en-US.

I have tried setting my emulator to en-GB, but I still get the same kind of error: the language primitives are still trying to load *.resources.dll assemblies that don't exist.

I don't understand how any of this could have happened. Two weeks ago I had a working project. Now I have two completely show-stopping bugs, and it's costing me unprecedented amounts of time. 

Further research: In the PageViewModel base class (which is from a Nuget package owned by me), I changed

    member val MessageSent = this.WhenAnyValue(toLinq <@ fun vm -> vm.Message @>).ObserveOn(RxApp.MainThreadScheduler).Where(fun m -> m <> noMessage) with get

to

    member __.MessageSent 
        with get() = this.WhenAnyValue(toLinq <@ fun vm -> vm.Message @>).ObserveOn(RxApp.MainThreadScheduler).Where(fun m -> m <> noMessage)

as it was the creation of the expression <@ fun vm -> vm.Message @> that caused the initial error. This caused the same error to get thrown from a different location in the codebase, with a similar stack trace:

 	0x17 in System.Reflection.Assembly.LoadFrom	C#
 	0x2 in System.Reflection.Assembly.LoadFrom at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:532,4	C#
 	0xC7 in System.Reflection.Assembly.InternalGetSatelliteAssembly at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:511,5	C#
 	0x60 in System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/resources/manifestbasedresourcegroveler.cs:560,17	C#
 	0x3E in System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/resources/manifestbasedresourcegroveler.cs:89,17	C#
 	0xBA in System.Resources.ResourceManager.InternalGetResourceSet at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs:809,17	C#
 	0x8 in System.Resources.ResourceManager.InternalGetResourceSet at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs:753,13	C#
 	0x6E in System.Resources.ResourceManager.GetString at /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs:1317,21	C#
 	0x10 in <StartupCode$FSharp-Core>.$Prim-types..cctor	C#
 	0x0 in Microsoft.FSharp.Core.LanguagePrimitives.HashCompare.get_fsEqualityComparerNoHashingPER	C#
 	0x2 in Microsoft.FSharp.Core.LanguagePrimitives.HashCompare.GenericEqualityIntrinsic<System.Type>	C#
Comment 17 Rob Lyndon 2017-03-01 18:21:44 UTC
Is there anyone available who can try and reproduce this issue from a Windows environment? I can share my AndroidManifest.xml by email if necessary (I just don't want to share my Google keys in a public repository).
Comment 18 Jason Imison 2017-03-02 09:04:50 UTC
Hi @Rob - email me at jaimison@microsoft.com . I'll take a look at this today.
Comment 19 Jason Imison 2017-03-02 13:12:07 UTC
I can't investigate this because of Bug 52625 either.

I get the following error on compiling :-

			Target _LinkAssembliesShrink:
/Library/Frameworks/Xamarin.Android.framework/Versions/7.1.99-46/lib/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Error executing task LinkAssemblies: error XA2006: Could not resolve reference to 'Android.Gms.Maps.GoogleMap Android.Gms.Maps.MapView::get_Map()' (defined in assembly 'Xamarin.Forms.Maps.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.GooglePlayServices.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded.
Comment 20 Rob Lyndon 2017-03-02 13:13:51 UTC
Does it build if you turn the linker off?
Comment 21 Rob Lyndon 2017-03-02 13:15:43 UTC
Also, rolling back to Xamarin.GooglePlayServices.Maps, 29.0.0.1 should be a workaround for Bug 52625.
Comment 22 Jason Imison 2017-03-02 13:41:07 UTC
Created attachment 20085 [details]
Runtime error

Switching Xamarin.GooglePlayServices.Maps to version 29.0.0.1 allowed it to build, but now I get a MissingMethodException at runtime.

Note I'm using OSX here... I just wanted to see if I could get it to run at all.
Comment 23 Rob Lyndon 2017-03-02 13:55:01 UTC
If you're getting as far as the map loading at runtime, you're getting further than me.

Out of interest, do you get as far if you change your Mac's locale to en-GB?
Comment 24 Jason Imison 2017-03-02 13:56:26 UTC
It is set to en-GB already :)
Comment 25 Rob Lyndon 2017-03-02 14:01:55 UTC
Interesting. Quite a few Macs are set to en-US, even when they're sold here. Or maybe I'm thinking of Safari.

Any change if you set your locale to en-US?
Comment 26 Jason Imison 2017-03-02 14:06:46 UTC
Doesn't make any difference... not sure if I need to restart XS and the emulator first.

I just noticed that locale was en-US on the emulator.. I switched that to en-GB and it didn't make any difference either.
Comment 27 Rob Lyndon 2017-03-02 14:12:48 UTC
It must be something to do with my setup. Would it be possible to test this on Visual Studio with a PC?
Comment 28 Jason Imison 2017-03-02 14:27:32 UTC
If I can get the Android emulator running inside VMWare I can try it out.. otherwise I'll need to install Windows via bootcamp which will take me a while longer :S
Comment 29 Rob Lyndon 2017-03-02 14:32:38 UTC
OK -- maybe we can set up a TeamViewer session if it's too hard to repro...
Comment 30 Jason Imison 2017-03-02 14:40:15 UTC
We could do that - but I'm not sure that would be any use. I need to be able to repro on my machine in order to fix the problem
Comment 31 Jason Imison 2017-03-02 16:20:06 UTC
Created attachment 20091 [details]
Runtime error

Same story on Windows. MissingMethodException at runtime.
Comment 32 Rob Lyndon 2017-03-03 11:06:28 UTC
If you're getting that far the dll load error isn't happening for you.

I'll reinstall Visual Studio and Xamarin and see if that clears the problem.

I've published a workaround for the maps runtime error on Nuget. See Bug 52625 for details.
Comment 33 Rob Lyndon 2017-03-03 11:06:45 UTC
If you're getting that far the dll load error isn't happening for you.

I'll reinstall Visual Studio and Xamarin and see if that clears the problem.

I've published a workaround for the maps runtime error on Nuget. See Bug 52625 for details.
Comment 34 Rob Lyndon 2017-03-04 01:08:46 UTC
Reinstalled Visual Studio -- still the same behaviour.
Comment 35 Rob Lyndon 2017-03-05 12:41:24 UTC
Having reinstalled Visual Studio again, the problem now appears to be resolved.
Comment 36 Rob Lyndon 2017-03-08 13:48:25 UTC
I've installed Visual Studio 2017, and this is happening again, though this time it isn't a show-stopper: I can continue through the exception, but Android Resources can't be read.
Comment 37 Rob Lyndon 2017-03-08 15:47:23 UTC
Created attachment 20211 [details]
Runtime error in action

In Visual Studio 2017, this error is not fatal, but I can't ignore it. I have to continue through it every time.
Comment 38 Rob Lyndon 2017-03-08 15:49:42 UTC
Created attachment 20212 [details]
First instance of runtime error

This is the first instance of the error, triggered by the use of an F# expression in the base class.