未在项目的层次结构中找到新元素 [英] Did not find new element in the hierarchy for item

查看:31
本文介绍了未在项目的层次结构中找到新元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 Xamarin 应用创建一个简单的页面,但我完全无法继续执行最基本的步骤.我从项目存储库中检出分支,并尝试添加一个新文件.当我这样做时(右键单击文件夹,添加-> 新项目-> 内容页面)我收到此错误:

I am trying to create a simple page for a Xamarin app but am completely unable to proceed with the most basic of steps. I check out the branch from the project repo, and attempt to add a new file. When I do so (Right clicking on folder, Add-> New Item->Content Page) I get this error:

它实际上创建了 .xaml 文件,但没有创建与之配套的 .xaml.cs 文件.我首先尝试手动创建 cs 文件并将其关联,但遇到了越来越神秘的错误.今天,我在启动之前在 VS 之外创建了它们,现在两个文件都存在,但带有虚线图标而不是常规图标,并且 cs 文件未嵌套在 xaml 文件下方.

It does actually create the .xaml file but not the .xaml.cs file to go with it. I first tried to manually create the cs file and associate it but ran into increasingly mysterious errors. Today I created them outside of VS before booting it up and both files are now present but with the dotted icon instead of a regular one and the cs file is not nested beneath the xaml file.

如果我尝试在 VS 中打开我的 projiitems 文件以进行关联,则会出现错误不支持指定的方法".如果我选择打开方式",则不会弹出任何屏幕让我进行选择.在此之后,我关闭了 VS 并再次在记事本中编辑了 projiitems 文件并链接了 xaml 和 cs 文件.这看起来好像有效,但是当我使用简单的 Children.Add(new MyReviews()); 将它添加到主 TabbedPage 时,它无法识别 -> 找不到类型或命名空间名称MyReviews".

If I try to open my projitems file inside VS to make the association I am given the error "Specified method is not supported". If I choose to 'Open With', no screen ever pops up allowing me to choose. After this I closed down VS and edited the projitems file in notepad again and linked the xaml and cs file. This looked as though it worked but when I add it to the main TabbedPage with a simple Children.Add(new MyReviews()); it is not recognized -> The type or namespace name 'MyReviews' could not be found.

如果我基于 master 创建自己的分支或尝试直接向 master 添加新文件,则会发生这些错误.项目中没有其他人遇到这些错误.

These error happen if I make my own branch based on the master or try to add a new file to the master directly. No one else in the project is having these errors.

我真正做的与其他人不同的唯一一件事是尝试让模拟器为 android 工作,这显然有很多兼容性问题并且需要旧版本的 xamarin 插件.我无法做到这一点,最终卸载并重新安装了两次,因为我第一次没有接触安装程序软件,一切都卡住了.

The only thing I really did differently from the rest is try to get the emulator working for android which apparently has a lot of compatibility issues and requires older versions of the xamarin plugins. I was not able to do this and ended up uninstalling and reinstalling everything twice since I didn't touch the installer software the first time and everything stuck.

有没有人能帮我调试这些问题,或者知道为什么我每次都遇到这么多问题?

Is anyone able to help me debug these issues or know why I am encountering so many at every turn?

推荐答案

我遇到了完全相同的情况.事实证明,我团队的其他成员在他们的 VS2017 安装中添加了通用 Windows 平台 (UWP) 支持,而我没有.运行 Visual Studio 安装程序并添加 UWP 完全解决了这个问题.

I've been in the exact same situation. As it turned out, the rest of my team had added Universal Windows Platform (UWP) support to their VS2017 install, and I hadn't. Running the Visual Studio Installer and adding UWP fixed this issue completely.

当然,您可能不需要或不想在您的任何 Xamarin 应用中包含 UWP 支持(我没有).似乎很可能只有一两个支持程序集在没有 UWP 支持的情况下出现错误或错误,但我还没有找到时间或精力来找出更多细节.

Of course, you might not need or want to include UWP support in any of your Xamarin apps (I didn't). It seems most likely that it's just one or two support assemblies that are mssing or wrong without the UWP support, but I haven't found the time or energy to figure out any more details.

这篇关于未在项目的层次结构中找到新元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆