启动 Xamarin 项目时值不能为空
Value cannot be null when launch Xamarin project
我当前的项目是一个空白项目,我在其中复制了 Visual Studio 示例的页面和 类,因为我试图了解其中的一切是如何工作的。
现在,我的项目被编译了,但是当我 运行 它时,我得到
System.ArgumentNullException: Value cannot be null. Parameter name:
newRoot at Xamarin.Forms.Platform.UWP.Platform.SetPage(Page
newRoot) at
Xamarin.Forms.Platform.UWP.WindowsBasePage.LoadApplication(Application
application) at MyApp.UWP.MainPage..ctor() at
MyApp.UWP.MyApp_UWP_XamlTypeInfo.XamlTypeInfoProvider.Activate_4_MainPage()
at MyApp.UWP.MyApp_UWP_XamlTypeInfo.XamlUserType.ActivateInstance()
at Windows.UI.Xaml.Controls.Frame.Navigate(Type sourcePageType, Object
parameter) at MyApp.UWP.App.OnLaunched(LaunchActivatedEventArgs e)
我想了解这是从哪里来的,并纠正它。
回答:
发生这种情况是因为我删除了
MainPage = new MyApp.MainPage();
来自 MyApp\App.xaml.cs
实际上我已经将它移除并放回原处,但出于某种原因,似乎这种类型的项目直到我做了一个新的 "Build" + "Deploy" 才真正更新。我习惯于只需要重新构建而不是重新部署,所以我的更改还没有被考虑在内。
我当前的项目是一个空白项目,我在其中复制了 Visual Studio 示例的页面和 类,因为我试图了解其中的一切是如何工作的。
现在,我的项目被编译了,但是当我 运行 它时,我得到
System.ArgumentNullException: Value cannot be null. Parameter name: newRoot at Xamarin.Forms.Platform.UWP.Platform.SetPage(Page newRoot) at Xamarin.Forms.Platform.UWP.WindowsBasePage.LoadApplication(Application application) at MyApp.UWP.MainPage..ctor() at MyApp.UWP.MyApp_UWP_XamlTypeInfo.XamlTypeInfoProvider.Activate_4_MainPage() at MyApp.UWP.MyApp_UWP_XamlTypeInfo.XamlUserType.ActivateInstance()
at Windows.UI.Xaml.Controls.Frame.Navigate(Type sourcePageType, Object parameter) at MyApp.UWP.App.OnLaunched(LaunchActivatedEventArgs e)
我想了解这是从哪里来的,并纠正它。
回答: 发生这种情况是因为我删除了
MainPage = new MyApp.MainPage();
来自 MyApp\App.xaml.cs
实际上我已经将它移除并放回原处,但出于某种原因,似乎这种类型的项目直到我做了一个新的 "Build" + "Deploy" 才真正更新。我习惯于只需要重新构建而不是重新部署,所以我的更改还没有被考虑在内。