FS2024 TypeProvider使用PCL项目时出现静态链接错误 [英] FS2024 Static linking error when PCL project use by TypeProvider

查看:73
本文介绍了FS2024 TypeProvider使用PCL项目时出现静态链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它正在尝试为Xamarin.Forms创建TypeProvider,但受到FS2024错误的困扰.

It's trying to make a TypeProvider for Xamarin.Forms, but has been plagued by FS2024 error.

  • 从Xamarin.Forms的XAML解析自己的库
  • 将x:Name分配给Propertis

`F#

type MainPage = Moonmile.XamarinFormsTypeProvider.XAML<"MainPage.xaml">
// made btn1 and text1 propertis

type MainPageEx(target:MainPage) =
    let mutable count = 0
    do
        // When set event to btn.Clicked, happen FS2024 error.
        // If this event is comment out, it success build.
        target.btn1.Clicked.Add( fun e ->
            count <- count + 1
            target.btn1.Text <- "Clicked " + count.ToString())
    // Property is success
    member this.CurrentPage
        with get() = target.CurrentPage

在引用属性时,请构建&操作正常即可. 但是Xamarin.Forms的内部类(如Button.Clicked),如果尝试访问,则是构建错误.

When you are referring to a property, build & operation you can normally. But the internal class of Xamarin.Forms like Button.Clicked, If you try to access to, it is the build error.

错误的示例代码 https://github.com/moonmile/SimpleEventTypeProvider

为XamarinFormsTypeProvider编写代码 github.com/moonmile/XamarinFormsTypeProvider

Making code for XamarinFormsTypeProvider github.com/moonmile/XamarinFormsTypeProvider

也许我怀疑不一致,并且正在本机TypeProvider和Xamrin.Forms.Core PCL的生成过程中发生.

Maybe, I suspect inconsistencies and is happening in the part of the generation of a Native TypeProvider and Xamrin.Forms.Core a PCL.

F# Compiler for F# 3.1 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License my error!!!
isMscorlib: true
name: "System.Runtime"
PrimaryAssembly.DotNetCore.Name: "System.Runtime"
PrimaryAssembly.Mscorlib.Name: "mscorlib"

parameter error FS2024: Static linking may not use assembly that targets different profile.

是为了操作它们正常工作的属性,也许是对MVVM. 对接我正在尝试实现一种分配给Button.Clicked事件的方法 如可能的话,如代码隐藏的建筑物中所示.

It's to operate the property they work properly, and to MVVM perhaps. Butt I am trying to implement a way to be assigned to Button.Clicked events as shown in the codebehide-like buildings if possible.

会有解决方法吗?

就WPF中的XAML而言,这样的方法看起来如何运作良好. github.com/fsprojects/FsXaml

In the case of XAML in WPF, How can such seems to work well. github.com/fsprojects/FsXaml

推荐答案

不能肯定此答案是正确的,但它至少可以帮助您指出正确的方向.

This answer isn't guaranteed to be correct, but it should help at least point you in the right direction.

要做的第一件事是确保安装了最新的Visual F#Tools Build,因为这将添加与PCL配置文件兼容的FSharp.Core(您可以在此处找到:( C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ FSharp.NETPortable \ 2.3.5.0 "和" C:\ Program Files(x86)\ Reference Assemblys \ Microsoft \ FSharp.NETPortable \ 2.3.5.1 ).

The first thing to do is to make sure that you have installed the latest Visual F# Tools Build, as this adds the FSharp.Core that is compatible with the PCL profiles (You can find it here: (https://visualfsharp.codeplex.com/). Once that is installed, you will want to reference either the Profile78, or Profile259 FSharp.Core.dll (On my machine, these are found at: "C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp.NETPortable\2.3.5.0", and "C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp.NETPortable\2.3.5.1" respectively).

安装完成后,接下来要做的就是确保PCL项目的项目文件中包含以下内容(这告诉MSBuild/xBuild项目是PCL库,而它们是F#项目):

Once you have that installed, the next thing to do is make sure that your PCL projects have the following in their project files (This tells MSBuild / xBuild that the projects are PCL libraries, and that they are F# Projects):

<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{F2A71F9B-5D33-465A-A702-920D77279786}</ProjectTypeGuids>

完成后,您将需要选择Profile78或Profile259(我建议使用78,因为当前的Xamarin.Forms nuget包不支持259).

Once that is done, you will need to select either Profile78, or Profile259 (I would recommend 78, as the current Xamarin.Forms nuget package doesn't support 259).

完成后,您应该能够构建和运行,并且应该摆脱错误.

Once that is done, then you should be able to build and run and it should get rid of the error.

这篇关于FS2024 TypeProvider使用PCL项目时出现静态链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆