我通过选择:"file">“新解决方案”>“使用 .Net 标准库的表单应用程序”创建了一个新的 Xamarin.Forms 解决方案。
在不进行任何代码更改的情况下进行重建后,我会看到以下错误:
namespace test3.Droid
{
[Activity(Label = "test3", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
}
protected override void OnCreate(Bundle bundle)
Green line under bundle with this message: parameter name differs in base declaration
TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar;
Red line under Tabbar with this message: Ambiguity between Resource.Layout.Tabbar and Resource.Layout.Tabbar
有人知道发生了什么事吗?希望大家给点建议。
请注意,如果有任何帮助,似乎有两个版本的资源:
..test3.Android/Resources/Resource.designer.cs
..test3.Android/obj/debug/designtime/Resoure.designer.cs
至于覆盖不同,我不确定是什么导致了该问题
谢谢
最佳答案
parameter name differs in base declaration
项目模板只是参数名称不匹配,它不会导致任何编译/运行时问题,只是在编辑器中看到很痛苦。您可以将名称更改为 savedInstanceState
匹配以使 Intellisense 满意。
Ambiguity between Resource.Layout.Tabbar and Resource.Lay.....
歧义问题是生成的文件如何应用于基于 Roslyn 的 Intellisense 系统的错误。长期已知的问题已在不同版本中多次修复和重新解决。虽然看到红色的 Intellisense 线很痛苦,但该项目将编译/运行良好......
关于xamarin - 使用模板的新 Xamarin.Forms 解决方案失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51242268/