Mamarin.Android上的MvvmCross 5.2引发了错误'Assembly'无法找到

时间:2017-09-19 05:22:38

标签: c# xamarin.android mvvmcross

将Xamarin.Android项目从MvvmCross 5.1升级到5.2后,代码抛出错误

Error CS0246 The type or namespace name 'Assembly' could not be found (are you missing a using directive or an assembly reference?)


public class CustomAndroidPresenter : MvxAndroidViewPresenter
{
    public CustomAndroidPresenter(IEnumerable<Assembly> androidViewAssemblies) : base(androidViewAssemblies)
    {
    }

    public override void Show(MvxViewModelRequest request)
    {
        if (request != null && request.PresentationValues != null)
        {
            if (request.PresentationValues.ContainsKey("MyCustomFlag"))
            {
                // Get intent from request and set flags to clear backstack.
                var intent = base.CreateIntentForRequest(request);
                intent.AddFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask);
                base.Show(intent);
                return;
            }
        }
        base.Show(request);
    }
}

1 个答案:

答案 0 :(得分:1)

  

没有任何参数对应于'CustomAndroidPresenter.CustomAndroidPresenter(IEnumerable)'所需的形式参数'androidViewAssemblies'

请注意,在Setup.cs课程中,您将CustomAndroidPresenter初始化为:

var presenter = new CustomAndroidPresenter();

但是你在CustomAndroidPresenter类中添加了一个构造函数:

public CustomAndroidPresenter(IEnumerable<Assembly> androidViewAssemblies) : base(androidViewAssemblies)
{
}

因此,当您初始化CustomAndroidPresenter时,请为其指定参数:

var presenter = new CustomAndroidPresenter(AndroidViewAssemblies);
  

无法从'Android.Content.Intent'转换为'MvvmCross.Core.ViewModels.MvxViewModelRequest'

使用base.ShowIntent(intent)代替base.Show(intent)