3

I have used Visual Studio and .Net as a professional developer pretty much for as long as they've existed. Last year I retired, got my own PC, Installed VS2019 (Community, v 16.9.5), and was able to convert over some of my personal projects (from vs2015) and edit and use them without problems. However, today I tried to make a new project and ran into a perplexing problem.

I wanted to create a project to play around with and learn the AutomationElement features in the System.Windows.Automation namespace. So I created a new c# Windows Form project and tried to add a using System.Windows.Automation; line to the Form1 code. But intellisense can't find the ".Automation" part and the IDE red-lines it as missing. So I figure I'll just add it.

But the vs2019 interface in this area is somewhat different, and once I find the Reference Manager, there's no "Assemblies" tab?!? So I Google for answer, and read several articles, including:

These seem to indicate that the problem is that you can't add assemblies with .Net Core. But I check and my project is using .Net 5.0 and not .Net Core 3.0 or .Net Core 3.1 (these are the only choices I have). So I delete the project and re-create, making sure to pick ".Net 5 (Current)" as the framework. Same result.

So google some more and I read some more articles, such as this one:

which seems to suggest that I need to use the Nugent Manager instead. So I try that, but these look like third party packages and I cannot find System.Windows.Automation through search the (enormous) list.

I have also read these articles (and others) and as far as I can tell, these are not my problem:

At this point I am kind of stumped. How can I create a (windows) project that I can add in the automation namespace?


OK, so after I posted this question I was checking the tags and noticed that the description of the .net-5 tags says "The next version of .Net Core ...", which would mean that I cannot add the assembly because I am actually using .Net Core even though I didn't realize it. If that's the case, then my problem/question is still similar: How can I either:

  1. Get and use a non-Core ,Net Framework? Or,
  2. Add the Automation assembly into my .Net 5.0 project?

Another weird thing that I noticed is that my vs2015 the projects that I now use in vs2019 do have the Assemblies features, and are using .Net 4.5.2 and the project properties have a drop down that allows me to change it to a bunch of different 4.x.x versions, even though my new vs2019 project only offer .Net 3.5 Core and .Net 5.0 and their project dropdowns only offer the three Core frameworks as options.

RBarryYoung
  • 55,398
  • 14
  • 96
  • 137

1 Answers1

2

OK, well I think that I have figured out what the problem is and how to solve it.

Apparently the problem is that when I create a new project in VS2019, and pick "C# Windows Forms App" that only allows you to make a .Net Core app. Much further down on the templates list is the option "C# Windows Forms App (.NET Framework)" which it seems is what you now have to pick in order to be allowed to use the full .Net framework.

Of course having never seen this option before (because the list is huge poorly formatted so you only see five options at a time) I had no idea of this distinction, nor of why they wouldn't annotate the Core-only version with "(Core)" so it would have been obvious from the start. (####)

RBarryYoung
  • 55,398
  • 14
  • 96
  • 137