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
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
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
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.
With Visual Studio closed,
Now open the solution in VS and rebuild - it should look and build fine.
Make sure you have StackLayout instead of ContentPage.Content in your .xaml files that throw this exception on VS.
Apparently, if you go into the VS2017 installer and install the Universal Windows Platform (UWP) development workload, this fixes the issue.