简体   繁体   English

Visual Studio 2017 中有时缺少项目模板

[英]Item Templates Sometimes Missing in Visual Studio 2017

Using Visual Studio 2017, sometimes new item templates are missing, and it seems to be tied to the particular project to which I'm trying to add an item.使用 Visual Studio 2017 时,有时会缺少新的项目模板,并且它似乎与我尝试添加项目的特定项目相关联。

Although both show up as "C#" projects...虽然两者都显示为“C#”项目...... 在此处输入图像描述 ...in "Logging", for WPF items, I have only UserControl (WPF) as an option: ...在“记录”中,对于 WPF 项目,我只有 UserControl (WPF) 作为选项: 只有 UserControl 可用

However, in "SanityCheck", I have a much-more-full list of WPF options:但是,在“SanityCheck”中,我有一个更完整的 WPF 选项列表: 更多可用的 WPF 选项

The only difference I can easily see so far is that the one ("Logging") is a Class Library project while the other ("SanityCheck") is a Windows Application project.到目前为止,我可以轻松看到的唯一区别是一个(“日志记录”)是 Class 库项目,而另一个(“SanityCheck”)是 Windows 应用程序项目。 However, changing Logging to Windows Application doesn't make more options available, and I ought to be able to create a Window in a Class Library, right?但是,将日志记录更改为 Windows 应用程序不会提供更多选项,我应该能够在 Class 库中创建 Window ,对吧?

I also noticed that Logging didn't contain all the same references as SanityCheck, so I added all the ones that seemed possibly-related, and that also didn't make any difference in the set of templates available.我还注意到 Logging 没有包含与 SanityCheck 相同的所有引用,因此我添加了所有可能相关的引用,并且这也没有对可用模板集产生任何影响。

So how do I get my Logging project to let me add a WPF Window?那么如何让我的 Logging 项目让我添加 WPF Window?

Thanks to a comment from ASh and the list referred to from this question , I determined that the cause was a missing <ProjectTypeGuids> block in the Logging.csproj file.感谢ASh的评论和这个问题中提到的列表,我确定原因是 Logging.csproj 文件中缺少<ProjectTypeGuids>块。 I copied the one from the SanityCheck.csproj file and now all the C# WPF templates are available.我从 SanityCheck.csproj 文件中复制了一个,现在所有 C# WPF 模板都可用。 So far I haven't encountered any negative side-effects to this solution.到目前为止,我还没有遇到此解决方案的任何负面影响。 Time will tell.时间会证明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM