Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
183 views
in Technique[技术] by (71.8m points)

c# - 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.

Although both show up as "C#" projects... enter image description here ...in "Logging", for WPF items, I have only UserControl (WPF) as an option: Only UserControl is available

However, in "SanityCheck", I have a much-more-full list of WPF options: Many more WPF options available

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. 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?

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.

So how do I get my Logging project to let me add a WPF Window?

question from:https://stackoverflow.com/questions/65941833/item-templates-sometimes-missing-in-visual-studio-2017

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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. I copied the one from the SanityCheck.csproj file and now all the C# WPF templates are available. So far I haven't encountered any negative side-effects to this solution. Time will tell.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...