将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);
}
}
答案 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)
。