Console Application transition from VS2008 to VS2022

Dina

New member
Joined
Aug 15, 2022
Messages
2
Programming Experience
10+
We have a lot of C# Console applications created in VS2008 ( .NET Framework Version 3.5 SP1). We are upgrading the hardware and I am thinking of installing VS2022 to my new PC. Will my C# code work in VS2022 or would you advise me to use an older version of VS, i.e. VS2017 (to make the transition more efficient and minimize time spent on converting the programs from VS2008 to VS2022) ? I am the only programmer and am busy with modifying existing programs. TIA for your wisdom and input.
 
There have been various breaking changes along the way but, for most applications, what you have should work exactly as it is. That's not just code but also projects. Most likely, you could just open the existing SLN file in VS 2022 and, after certain specific entries in the SLN and CSPROJ files are modified automatically, it will just work. There may be better ways to do certain things now, but that doesn't mean that the old ways won't still work. It's possible that you'll get specific warnings for types or members that have been deprecated but, if things don't just work, you'll likely need minimal changes.

You probably ought to look to update to .NET Framework 4.6.2 or 4.8, as I believe that they are the only versions still in support. Again, though, everything you already have will most likely just work as is.

Note that, when creating new projects in VS 2022, unless you specifically select a project template that says that it's for .NET Framework, you'll be targeting .NET Core. .NET Framework 4.8 is the last version and .NET 5 and later are based on .NET Core.
 
Also, when you make a new project in your VS2022, you may see a checkbox "Do not use top level statements" - I'd recommend checking that option ON until you get on board with what top level statements are (I personally always check it because I never want to use TLS; they offer little benefit but ample opportunity for confusion, in my opinion and I've never seen the sense in the argument that "one doesn't have to write as much to get a program going" given that every project template since the dawn of time has included the ~6 lines of boilerplate to get a program going anyway)
 
Also, when you make a new project in your VS2022, you may see a checkbox "Do not use top level statements" - I'd recommend checking that option ON until you get on board with what top level statements are (I personally always check it because I never want to use TLS; they offer little benefit but ample opportunity for confusion, in my opinion and I've never seen the sense in the argument that "one doesn't have to write as much to get a program going" given that every project template since the dawn of time has included the ~6 lines of boilerplate to get a program going anyway)
I think that top-level statements are only useful for very simple projects, where there's very little code, or very complex projects, where there's lots of code but very little in the Main method. It has always seemed like a solution in search of a problem to me.
 
I did always wonder if the design meeting went like; "hey, I'm a javascript/python/bash/whatever programmer and I can just open a text file and write a line of code for Hello World. You C# guys have to write sooo much boilerplate just to make it go; C# clearly sucks" that was met with a response of "OK, we'll put a checkbox that hides it and get the compiler to silently insert it for you.. happy?"

It could have just as easily been met with "so what?"..
 
I think it's more of a design principle taken too far, as well as the current "trend" in REPL. C#'s design was partly to be a Java that is less verbose and contains less ceremony. Add in the current leaning of C# towards functional style programming, and you get something like top level statements being created.

Top level statements is minimum in ceremony and verbosity in spades. Top level statements facilitates REPL amazingly well. You can writes functional style code using top level statements as long as you just use simple types, POCOs, and/or tuples.

Things just breakdown when you start shifting from procedural or functional code to object oriented code.
 
There have been various breaking changes along the way but, for most applications, what you have should work exactly as it is. That's not just code but also projects. Most likely, you could just open the existing SLN file in VS 2022 and, after certain specific entries in the SLN and CSPROJ files are modified automatically, it will just work. There may be better ways to do certain things now, but that doesn't mean that the old ways won't still work. It's possible that you'll get specific warnings for types or members that have been deprecated but, if things don't just work, you'll likely need minimal changes.

You probably ought to look to update to .NET Framework 4.6.2 or 4.8, as I believe that they are the only versions still in support. Again, though, everything you already have will most likely just work as is.

Note that, when creating new projects in VS 2022, unless you specifically select a project template that says that it's for .NET Framework, you'll be targeting .NET Core. .NET Framework 4.8 is the last version and .NET 5 and later are based on .NET Core.
Thank you. It does not let me choose framework. The only one that I see in the dropdown box when I create the project is .NET 6.0 (Long-term support) which is NETCore.
 
By any chance are you on a Mac?

NVM. I re-read your OP regarding upgrading PCs (although some people consider going from a PC to a Mac, an upgrade. :) )

Check what platform you have selected on the project filter. You may have selected another OS/Platform other than Windows.
 
Thank you. It does not let me choose framework. The only one that I see in the dropdown box when I create the project is .NET 6.0 (Long-term support) which is NETCore.
Are you talking about when creating a new project? If you choose a .NET Core project template then you'll only be able to select versions of .NET Core. If you want to choose a version of .NET Framework then you have to choose a .NET Framework project template. They're the ones with ".NET Framework" in the name. Once you've made that choice, the version drop-down will display every version you have the SDK installed for.

If you open an existing .NET Framework project in VS 2022 then it's not going to show you .NET Core versions.
 
Does your New Project window look like this when you search for "console":

1661342584291.png


Once you choose either "Console App" or "Console App (.NET Framework)" the decision is made as to whether you're in Core or Framework.. Same for other proejct types
 
Back
Top Bottom