Begin to Code with C# Snaps works with Visual Studio 2022

Begin to Code with C#
By Miles, Rob

My Begin to Code with C# book was published in 2016, which is a long time ago in the field of computing. Still a good read though (subtle plug).

It was great fun to write, although I did make things extra difficult for myself by inventing an environment called “Snaps”, where you learn to write your code. As you work through the book you interact with the examples and build your own Universal Windows Applications.

I spent some time today checking that the Snaps framework still works with the latest version of Visual Studio. It turns out that it works fine; in fact it is now even easier to install and use Snaps nowadays because Visual Studio 2022 automatically downloads the required libraries, and can even clone the Snaps framework files straight from a GitHub repository. Here’s how you get it all going:

Figure 01 VS 2022 Install.png

Step zero is to make sure that when you install Visual Studio you include the Universal Windows Platform Development component. You can see it at the bottom right of the options shown in the Visual Studio Installer above above. Then, once Visual Studio 2022 has started after installation you can get the Snaps framework straight from GitHub.

If you haven’t got the Universal Windows Development component installed, or want to check, open the Tools menu and select Get Tools and Features from the menu to open the Visual Studio 2022 installer. Once you have installed Visual Studio 2022 and run it you will get the startup page:

Figure 02 Open Project.png

This is the startup page for Visual Studio 2022. To get a copy of Snaps (you will only have to do this once) click “Clone a repository” at the top left. Then you can fetch the Snaps framework from Github.

Figure 03 Clone Snaps.png

You use this dialog to copy Snaps from GitHub into a folder on your machine. Snaps are on GitHub here:

https://github.com/CrazyRobMiles/snaps

Type this into the Repository location box, make sure that the destination path is a sensible place to put Snaps and then click Clone in the bottom left. This will bring down the framework and open it.

Figure 04 Solutions.png

Once you have downloaded the repository you will find all the repository contents are displayed in the Solution Explorer window at the top right hand side of Visual Studio.

This window lets you explore the solutions in your project. There are two solutions, BeginToCodeWithCSharp holds all the example programs from the book, plus the browser that you use to explore them. Snaps holds the Snaps library functions.

You need to open the BeginToCodeWithCSharp as above. You will have to do this each time you start with the repository in Visual Studio 2022. Do this by double clicking the solution line in the explorer above.

Figure 05 Update.png

The very first time you run the solution Visual Studio 2022 will ask if you want to install the libraries that it uses. This only needs to be done once, just click OK to install them. Now you need to configure the target device for the application.

Figure 06 Build Select.png

Before you can run the Snaps browser you need to tell Visual Studio the hardware platform that you want to use. This is initially set to “Any CPU”. Open up the selection and choose “x86” from the menu at the top of Visual Studio.

Figure 10 Run Button.png

Now you can hit the green arrow to start the program running.

Figure 08 Running.png

This is the Visual Studio 2022 display you’ll see when your Snaps program is running.

Figure 09 Menu.png

This is the example browser for all the programs in the book, which you should now rush out and buy….