尝试添加 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 关闭的情况下,
随心所欲)
编辑器(不是 VS)并将内容重命名为您在 #1
编辑器,搜索您在 #1 中复制的文件名并添加新的
类似的) - 将有 3 个地方添加它们
现在在 VS 中打开解决方案并重建 - 它应该看起来和构建良好。
关于visual-studio - 添加内容页面 VS 时出现 Xamarin System.Exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47738138/