【问题标题】:"Error MT2002: Failed to resolve UIKit.UICollectionView::set_DataSource" after updating Xamarin.Forms iOS app to universal API将 Xamarin.Forms iOS 应用程序更新为通用 API 后,“错误 MT2002:无法解析 UIKit.UICollectionView::set_DataSource”
【发布时间】:2015-02-20 20:17:49
【问题描述】:

我将我的一个示例 Xamarin Forms 应用程序更新为新的通用 API 和 Xamarin.Forms 1.3.0.6286-pre4。

两个项目的主要部分:

//App.cs in XamlMaps (the PCL part)
namespace XamlMap
{
    public class App : Application
    {
        public App ()
        {   
            MainPage = new MainPage();    //Main page is a Xaml which holds a Label
        }

        protected override void OnResume()
        {
            Debug.WriteLine("OnResume");
            base.OnResume();
        }

        protected override void OnSleep()
        {
            Debug.WriteLine("OnSleep");
            base.OnSleep();
        }

        protected override void OnStart()
        {
            Debug.WriteLine("OnStart");
            base.OnStart();
        }
    }
}

//AppDelegate.cs in XamlMaps.iOS
namespace XamlMap.iOS
{
    [Register ("AppDelegate")]
    public partial class AppDelegate : FormsApplicationDelegate
    {

        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            Forms.Init();

            LoadApplication (new App ());

            return base.FinishedLaunching (app, options);
        }
    }
}

我删除了除 Xamarin.Forms 之外的所有其他依赖项。

当我尝试为设备构建时,我仍然收到以下错误:

错误 MT2002:无法解析来自“Xamarin.iOS,版本=0.0.0.0,文化=中性,PublicKeyToken=84e04ff9cfb79065”的“System.Void UIKit.UICollectionView::set_DataSource(UIKit.UICollectionViewDataSource)”引用 (MT2002) ( XamlPlayer.iOS)

当我在模拟器上运行我的项目时,一切正常:应用程序启动,一切正常。

知道为什么 Mtouch 在这方面失败了吗?

【问题讨论】:

    标签: xamarin.ios xamarin xamarin.forms


    【解决方案1】:

    Xamarin.Forms 1.3.0 基于统一 API 的预览 版本。自 Xamarin.iOS 7.4 发布(去年夏天)以来,已经有几个预览版,作为预览版,版本之间存在一些不兼容的更改(这需要您重新编译任何引用)。

    Xamarin.iOS 8.6 附带的最终/稳定统一 API 与预览版存在一些差异。您需要针对最终 API 构建的 Xamarin.Forms (1.3.1 iirc) 的更新版本。

    【讨论】:

      【解决方案2】:

      如果你没有原生库,你可以将Options->iOS Build->Link behavior设置为Din't link。

      【讨论】:

        【解决方案3】:

        出现 MT2002 错误是因为 mscorlib.dll 程序集中不存在某些符号。 >您的应用程序(或第 3 方程序集)中的某些代码正在使用此(缺少的)API,并且 >需要删除/重新编译。

        尝试将链接器设置为链接所有程序集,上次我遇到了与 splat 相同的问题并且它有效。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-07-16
          • 2020-02-23
          • 2023-03-12
          • 2021-08-07
          • 1970-01-01
          相关资源
          最近更新 更多