添加内容页面VS时Xamarin System.Exception [英] Xamarin System.Exception when adding Content page VS
问题描述
在Visual Studio中尝试将Content Page
添加到解决方案时,发生以下错误:
When trying to add a Content Page
to the solution in visual studio, the following error occurs:
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.
添加文件时,请执行以下操作:
When adding the file I do the following:
Right click on Views in my Xamarin Solution > Add > New Item > Content Page > Add
在Windows资源管理器中查看时,会创建一个文件MyPage.xaml
,但尚未创建MyPage.xaml.cs
,并且未将其添加到解决方案中
When looking in the windows explorer, there is a file created MyPage.xaml
but it has not created MyPage.xaml.cs
and it is not added to the solution
这是一个空白的Xamarin共享项目,并且此错误不断发生...
It is a blank Xamarin shared project and this error just keeps happening...
这让我发疯,因为我什至无法添加单个页面
It's driving me nuts as I can't even add a single page
作为一种解决方法,我使用W.explorer手动添加文件,然后手动编辑app.projitems,但这很荒谬.
As a workaround, I add the files manually using the W. explorer and then edit app.projitems manually, but this is just ridiculous.
推荐答案
在解决此问题之前,作为一种肮脏的解决方法,将文件手动"添加到项目中即可完成工作.
As a dirty workaround until this gets fixed, adding the files "manually" to the project gets the job done.
在Visual Studio关闭的情况下,
With Visual Studio closed,
- 复制/粘贴现有的(正在运行的)*.xaml和* .xaml.cs文件(重命名) 他们随便你)
- 使用文本打开新粘贴的文件 编辑器(不是VS),然后将内容重命名为您在#1中选择的名称
- 将新粘贴的文件添加到* .projitems文件(以文本形式打开) 编辑器中,搜索您在#1中复制的文件名并添加新文件名 类似地)-将有3个地方添加它们
- copy/paste existing (working) *.xaml and *.xaml.cs files (rename them as you please)
- open the newly pasted files with a text editor (not VS) and rename the contents to your chosen name in #1
- add newly pasted files to your *.projitems file (open it in a text editor, search for the filenames you copied in #1 and add the new ones similarly) - there'll be 3 places to add them
现在在VS中打开解决方案并重新构建-它应该看起来并构建良好.
Now open the solution in VS and rebuild - it should look and build fine.
这篇关于添加内容页面VS时Xamarin System.Exception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!