【问题标题】:Xamarin.Forms - XamlCompilation MissingMethodExceptionXamarin.Forms - XamlCompilation MissingMethodException
【发布时间】:2017-03-09 19:01:34
【问题描述】:

我想提高 Xamarin.Forms UWP 应用程序的性能,因为它在发布模式下非常慢(选中“.NET 本机”)。所以我在 PCL 项目的汇编级别应用 XAMLC:

[assembly: XamlCompilation (XamlCompilationOptions.Compile)]
namespace MyApp
{
}

但使用此属性我收到运行时错误:

"方法未找到:'无效 Xamarin.Forms.Xaml.Internals.SimpleValueTargetProvider..ctor(System.Object[])'。"

据此:

https://github.com/xamarin/Xamarin.Forms/blob/master/docs/Xamarin.Forms.Xaml/Xamarin.Forms.Xaml.Internals/SimpleValueTargetProvider.xml

SimpleValueTargetProvider 类有 2 个版本:

  • 1.5.0.0 - 带有一个参数 System.Object[] 的构造函数
  • 2.0.0.0 - 具有 2 个参数 System.Object[] 和 System.Object 的构造函数

我使用 Xamarin.Forms 2.3.3.163-pre3,所以我在我的项目中使用了第二个版本(当我导航到 Xamarin.Forms.Xaml.Internals 中的 SimpleValueTargetProvider 时,我可以看到带有 2 个参数的构造函数)。我的理解是,显然“某物”仍在调用 SimpleValueTargetProvider 1.5.0.0,但我不知道它是什么。

我删除了所有第三方组件,但没有帮助。我使用 fusion log 来了解发生了什么,但这就是我所得到的(老实说,我不知道这是否与我所面临的问题有关):

> *** Assembly Binder Log Entry  (10/26/2016 @ 9:09:42 PM) ***
> 
> The operation failed. Bind result: hr = 0x80070002. The system cannot
> find the file specified.
> 
> Assembly manager loaded from: 
> C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under
> executable  C:\Program Files (x86)\Microsoft Visual
> Studio\VS15Preview\Common7\IDE\devenv.exe
> --- A detailed error log follows. 
> 
> === Pre-bind state information === LOG: DisplayName = XamlDesignerFaultInjection  (Partial) WRN: Partial binding information
> was supplied for an assembly: WRN: Assembly Name:
> XamlDesignerFaultInjection | Domain ID: 1 WRN: A partial bind occurs
> when only part of the assembly display name is provided. WRN: This
> might result in the binder loading an incorrect assembly. WRN: It is
> recommended to provide a fully specified textual identity for the
> assembly, WRN: that consists of the simple name, version, culture, and
> public key token. WRN: See whitepaper
> http://go.microsoft.com/fwlink/?LinkId=109270 for more information and
> common solutions to this issue. LOG: Appbase = file:///C:/Program
> Files (x86)/Microsoft Visual Studio/VS15Preview/Common7/IDE/ LOG:
> Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base =
> NULL LOG: AppName = devenv.exe Calling assembly : (Unknown).
> === LOG: This bind starts in default load context. LOG: Using application configuration file:
> C:\Users\blaze\AppData\Local\Microsoft\VisualStudio\15.0_2f751565\devenv.exe.config
> LOG: Using host configuration file:  LOG: Using machine configuration
> file from
> C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
> LOG: Policy not being applied to reference at this time (private,
> custom, partial, or location-based assembly bind). LOG: Attempting
> download of new URL file:///C:/Program Files (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/XamlDesignerFaultInjection.DLL. LOG:
> Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/XamlDesignerFaultInjection/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PublicAssemblies/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PublicAssemblies/XamlDesignerFaultInjection/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/XamlDesignerFaultInjection/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/XamlDesignerFaultInjection/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Platform/Debugger/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Platform/Debugger/XamlDesignerFaultInjection/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/XamlDesignerFaultInjection/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/DataCollectors/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/DataCollectors/XamlDesignerFaultInjection/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/DataCollectors/x86/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/DataCollectors/x86/XamlDesignerFaultInjection/XamlDesignerFaultInjection.DLL.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/XamlDesignerFaultInjection.EXE. LOG:
> Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/XamlDesignerFaultInjection/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PublicAssemblies/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PublicAssemblies/XamlDesignerFaultInjection/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/XamlDesignerFaultInjection/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/XamlDesignerFaultInjection/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Platform/Debugger/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Platform/Debugger/XamlDesignerFaultInjection/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/XamlDesignerFaultInjection/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/DataCollectors/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/DataCollectors/XamlDesignerFaultInjection/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/DataCollectors/x86/XamlDesignerFaultInjection.EXE.
> LOG: Attempting download of new URL file:///C:/Program Files
> (x86)/Microsoft Visual
> Studio/VS15Preview/Common7/IDE/PrivateAssemblies/DataCollectors/x86/XamlDesignerFaultInjection/XamlDesignerFaultInjection.EXE.
> LOG: All probing URLs attempted and failed.

这是 Xamarin.Forms 或 XamlCTask 中的错误吗?有没有人遇到过这个问题或知道如何解决?

  • Windows 10 64 位
  • Visual Studion 15 预览版 5
  • Xamarin 4.2.1.14
  • Xamarin.Forms 2.3.3.163-pre3

提前致谢

【问题讨论】:

    标签: c# .net xaml xamarin xamarin.forms


    【解决方案1】:

    这很可能是 IDE 或项目级别的缓存问题。

    如果是 IDE 级别: - 做一个干净的 - 重启 VS 或 XS - 重建

    但你可能已经尝试过了。

    我的猜测是其中一个 nuget 更新没有正确清理,并且您在解决方案的不同项目中引用了不同版本的 XF,或者一个 .csproj 文件引用了旧的 .targets 文件。

    希望通过一些手动清洁来解决这个问题。

    【讨论】:

    • 谢谢斯蒂芬!手动清洁解决了这个问题。
    • @Blazey 什么是手动清洁?删除包文件夹中的所有内容或从项目中删除所有包?
    • 我在记事本中编辑了 .csproj 并删除了所有对 XF 的旧引用。
    • 有同样的问题,简单的重建并没有解决它,所以,我清理了所有东西,关闭了 IDE,删除了 packages 文件夹(在解决方案的根目录),删除了项目的 obj 和 bin 文件夹,重新启动VS,恢复包。重建一切。
    • 如果你是 git 用户,你可以在你的项目根目录中git clean -xdf。只需确保任何更改都已分阶段/提交即可。
    【解决方案2】:

    如果您的项目依赖于使用 XamlC 的第 3 方程序集,并且该程序集是基于 XF

    存在修复并将作为 XF 2.3.3 的第一个服务版本的一部分发布

    【讨论】:

      【解决方案3】:

      就我而言,我的 Core 和 Android 版本有不同的 Xamarin.Forms 版本。在所有项目上安装相同的解决它

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多