gpt4 book ai didi

visual-studio - 添加内容页面 VS 时出现 Xamarin System.Exception

转载 作者:行者123 更新时间:2023-12-04 08:03:07 24 4
gpt4 key购买 nike

尝试添加 Content Page 时在visual studio中的解决方法,出现如下错误:

Exception of type 'System.Exception' was thrown.

The project system has encountered an error.

Did not find new element in the hierarchy for item `Views\MyPage.xaml`.
The item would have been added with type "Page".
The project item schema service knows about this item type.
The item does exist in the project file.

添加文件时,我执行以下操作:
Right click on Views in my Xamarin Solution > Add > New Item > Content Page > Add
在 windows 资源管理器中查看时,创建了一个文件 MyPage.xaml但它没有创建 MyPage.xaml.cs它没有添加到解决方案中

这是一个空白的 Xamarin 共享项目,并且此错误一直在发生...

这让我发疯,因为我什至无法添加一页

作为一种解决方法,我使用 W. 资源管理器手动添加文件,然后手动编辑 app.projitems,但这太荒谬了。

最佳答案

在解决此问题之前,作为一种肮脏的解决方法,将文件“手动”添加到项目中即可完成工作。

在 Visual Studio 关闭的情况下,

  • 复制/粘贴现有​​(工作)*.xaml 和 *.xaml.cs 文件(重命名
    随心所欲)
  • 用文本打开新粘贴的文件
    编辑器(不是 VS)并将内容重命名为您在 #1
  • 中选择的名称
  • 将新粘贴的文件添加到您的 *.projitems 文件(在文本中打开它
    编辑器,搜索您在 #1 中复制的文件名并添加新的
    类似的) - 将有 3 个地方添加它们

  • 现在在 VS 中打开解决方案并重建 - 它应该看起来和构建良好。

    关于visual-studio - 添加内容页面 VS 时出现 Xamarin System.Exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47738138/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com