Cant build with F# dll for windows store

Hi, I have a problem with building my project for windows store after I added some libraries in F#.
The project builds and works nicely for android, but when I try to build for windows store (SDK 8.1), I get the following erros in console:

Type '[FSharp.Core]Microsoft.FSharp.Collections.Array2DModule+Copy@124' has an extra field 'array' of type 'T[,]' in the player and thus can't be serialized
UnityEditor.HostView:OnGUI()

Type '[FSharp.Core]Microsoft.FSharp.Collections.Array2DModule+Map@114' has an extra field 'array' of type 'T[,]' in the player and thus can't be serialized
UnityEditor.HostView:OnGUI()

Type '[FSharp.Core]Microsoft.FSharp.Collections.Array2DModule+MapIndexed@119' has an extra field 'array' of type 'T[,]' in the player and thus can't be serialized
UnityEditor.HostView:OnGUI()

Type '[FSharp.Core]Microsoft.FSharp.Collections.Array2DModule+Rebase@131' has an extra field 'array' of type 'T[,]' in the player and thus can't be serialized (expected 'b1' of type 'System.Int32')
UnityEditor.HostView:OnGUI()

Error building player because script class layout is incompatible between the editor and the player.

Then the build fails and stops.

The reference FSharp.Core.dll AssemblyVersion is 2.3.0.0. My dlls originally targeted .net 3.5, but in an attempt to resolve this issue I rebuilt them to target .net 2.0, with no luck.

I am fairly new to both .net and unity, so any advice is greatly appreciated.

EDIT:
I also tried more FSharp.Core.dll versions: 3.3.1.0, 3.78.3.1, 3.259.3.1, 2.3.0.0, 4.3.0.0, 4.3.1.0, 2.3.5.0, 2.3.5.1
…with no luck. Some of the versions give me different errors, which look ever worse.

I also tried building with the original (2.3.0.0) core for iOS, WebPlayer and WindowsPhone 8. The iOS and WebPlayer builds and runs smoothly. iOS also builds withoun any trouble, but Im not able to test whether the app actually works on any device.
Bulding for WinPhone 8 faild and throws this:

Error building Player: Exception: Failed to run serialization weaver with command line "Temp\StagingArea\Data\Managed\FSharp.Core.dll" -pdb -verbose -unity-engine=Temp\StagingArea\Data\Managed\UnityEngine.dll "Temp\StagingArea\TempSerializationWeaver".[Temp\StagingArea\Data\Managed\FSharp.Core.dll]
Symbols will be read from Temp\StagingArea\Data\Managed\UnityEngine.pdb
Weaving assembly C:\Users\TesarStepan\Documents\GitHub\BodylightUnity\Radapp\Temp\StagingArea\Data\Managed\FSharp.Core.dll
No symbols for Temp\StagingArea\Data\Managed\FSharp.Core.dll
 + Microsoft.FSharp.Core.Unit
 + Microsoft.FSharp.Core.SealedAttribute
 + Microsoft.FSharp.Core.AbstractClassAttribute
 + Microsoft.FSharp.Core.EqualityConditionalOnAttribute
 + Microsoft.FSharp.Core.ComparisonConditionalOnAttribute
 + Microsoft.FSharp.Core.AllowNullLiteralAttribute
 + Microsoft.FSharp.Core.VolatileFieldAttribute
 + Microsoft.FSharp.Core.DefaultAugmentationAttribute
 + Microsoft.FSharp.Core.CLIEventAttribute
 + Microsoft.FSharp.Core.CLIMutableAttribute
 + Microsoft.FSharp.Core.AutoSerializableAttribute
 + Microsoft.FSharp.Core.DefaultValueAttribute
 + Microsoft.FSharp.Core.EntryPointAttribute
 + Microsoft.FSharp.Core.ReferenceEqualityAttribute
 + Microsoft.FSharp.Core.StructuralComparisonAttribute
 + Microsoft.FSharp.Core.StructuralEqualityAttribute
 + Microsoft.FSharp.Core.NoEqualityAttribute
 + Microsoft.FSharp.Core.CustomEqualityAttribute
 + Microsoft.FSharp.Core.CustomComparisonAttribute
 + Microsoft.FSharp.Core.NoComparisonAttribute
 + Microsoft.FSharp.Core.ReflectedDefinitionAttribute
 + Microsoft.FSharp.Core.CompiledNameAttribute
 + Microsoft.FSharp.Core.StructAttribute
 + Microsoft.FSharp.Core.MeasureAttribute
 + Microsoft.FSharp.Core.MeasureAnnotatedAbbreviationAttribute
 + Microsoft.FSharp.Core.InterfaceAttribute
 + Microsoft.FSharp.Core.ClassAttribute
 + Microsoft.FSharp.Core.LiteralAttribute
 + Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute
 + Microsoft.FSharp.Core.CompilationMappingAttribute
 + Microsoft.FSharp.Core.CompilationSourceNameAttribute
 + Microsoft.FSharp.Core.CompilationRepresentationAttribute
 + Microsoft.FSharp.Core.ExperimentalAttribute
 + Microsoft.FSharp.Core.CompilationArgumentCountsAttribute
 + Microsoft.FSharp.Core.CustomOperationAttribute
 + Microsoft.FSharp.Core.ProjectionParameterAttribute
 + Microsoft.FSharp.Core.StructuredFormatDisplayAttribute
 + Microsoft.FSharp.Core.CompilerMessageAttribute
 + Microsoft.FSharp.Core.UnverifiableAttribute
 + Microsoft.FSharp.Core.NoDynamicInvocationAttribute
 + Microsoft.FSharp.Core.OptionalArgumentAttribute
 + Microsoft.FSharp.Core.GeneralizableValueAttribute
 + Microsoft.FSharp.Core.RequiresExplicitTypeArgumentsAttribute
 + Microsoft.FSharp.Core.RequireQualifiedAccessAttribute
 + Microsoft.FSharp.Core.AutoOpenAttribute
 + Microsoft.FSharp.Core.PrivateEnvironment
 + Microsoft.FSharp.Core.MatchFailureException
 + Microsoft.FSharp.Core.FSharpTypeFunc
 + Microsoft.FSharp.Core.FuncConvert
 + Microsoft.FSharp.Collections.MapDebugViewKeyValuePair
 + Microsoft.FSharp.Reflection.UnionCaseInfo
 + Microsoft.FSharp.Reflection.FSharpType
 + Microsoft.FSharp.Reflection.FSharpValue
 + Microsoft.FSharp.Math.BigNat
 + Microsoft.FSharp.Text.StructuredPrintfImpl.Joint/_Unbreakable
 + Microsoft.FSharp.Text.StructuredPrintfImpl.Joint/Breakable
 + Microsoft.FSharp.Text.StructuredPrintfImpl.Joint/Broken
 + Microsoft.FSharp.Text.StructuredPrintfImpl.Joint
 + Microsoft.FSharp.Text.StructuredPrintfImpl.Layout/Leaf
 + Microsoft.FSharp.Text.StructuredPrintfImpl.Layout/Node
 + Microsoft.FSharp.Text.StructuredPrintfImpl.Layout/Attr
 + Microsoft.FSharp.Text.StructuredPrintfImpl.Layout
System.NullReferenceException: Odkaz na objekt nen� nastaven na instanci objektu.
   v Unity.CecilTools.Extensions.TypeReferenceExtensions.IsEnum(TypeReference type)
   v Unity.SerializationLogic.UnitySerializationLogic.IsNonSerialized(TypeReference typeDeclaration)
   v Unity.Serialization.Weaver.MethodEmitterBase.EmitMethodBody()
   v Unity.Serialization.Weaver.SerializationWeaver.AddSerializeMethod()
   v Unity.Serialization.Weaver.SerializationWeaver.Weave()
   v usw.Weaver.WeaveAssembly(String assemblyPath, AssemblyDefinition unityEngineAssemblyDefinition)
   v usw.Weaver.Weave()
   v usw.Program.RunProgram(ConversionOptions options)
   v usw.Program.Main(String[] args)

So everything works fine on all platforms except those windows-related.
What the hell am I missing?

I made a project that reproduces the bug:

Just try to build for Windows Store.

To me it seems that this error comes from including the Fsharp.Core.dll to Unity project and not about the actual Project source code.

At last I build f#+unity project for windows store. Here how i do:

  • Create a unity project
  • Create a f# with unity as a target
    framework
  • Create a simple MonoBehaviour to move
    objects with CharacterController
  • Add dll to unity project
  • ----until here it is same as you do :slight_smile:
  • you can build all platform except
    windows store with this
  • if you want do build for windows
    store, delete all generated assert
    with you f# library, expect
    projectname.dll (yes delete
    FSharp.Core.dll too!!!)
  • add f# portable core dll from here
    “C:\Program Files (x86)\Reference
    Assemblies\Microsoft\FSharp.NETPortable\3.47.4.0”
  • build and run unity with target
    windows store :).