Press "Enter" to skip to content

Lesson 02.2 – Building the solution for the game

Lesson objectives

At the end of this lesson, you will know…

  • How to create a program (solution) in Visual Studio
  • How, and why, to have separate projects in your solution


How to build your first solution in Visual Studio

People generally use “program”, “application”, and “project” interchangeably. However, Visual Studio calls a program a “solution”.

A “solution” is broken into smaller pieces that Visual Studio calls “projects”. The solution must have at least one project.

In these lessons, I’ll use “program” to talk about the game, “solution” for all the files used to make the game, and “project” for the different groups of files within the solution.


Deciding how many projects the solution needs

When I create a solution, there are always at least two projects.

One is for the user interface (UI), the part of the program that reads and writes to the screen. The second project is for the “logic” of the program.

I do this is for a couple of reasons.

First, it makes the program easier to test.

We won’t do it in these tutorials, but it’s possible to write automated tests to make sure the program does what it’s supposed to do. If you have “logic” in the user interface, this is difficult to automate.

Second, sometimes you’ll want to use one of your projects in another program.

One example might be the code to read from, and write to, a database. That could be useful for any program you write that needs to access a database.

If the database code is in the UI project, you won’t be able to use it in another project, unless it needs to use the same screens from the UI project.

So you put that all that database access code into a separate project, and you can copy it to your next project that uses a database.

When we write the game, you’ll see how I decide what to put in the Engine project.

NOTE: For a large business program, you might have dozens of projects in a solution – which sometimes leads to problems with keeping track of everything.


Creating a solution with two projects

Here’s a video of how to create the solution for your game.



Link to video on YouTube


Step 1: Start Visual Studio Express 2013 for Desktop


Step 2: Create a new solution with a “Windows Forms” project (File -> New Project -> Windows Form Application). Make sure you are using the using the project templates listed under “Visual C#”.

NOTE (for Visual Studio 2017 users): You can create this project under Visual C# -> Windows Classic Desktop -> Windows Forms App (.NET Framework). The “Engine” project will be under Visual C# -> Windows Classic Desktop -> Class Library (.NET Framework)

A Windows Form application is a user interface project, one that will display the program on the screen, wait for the user’s input, and update the information on the screen.

We’ll name the program “SuperAdventure”, and save it in the C:\Projects directory.

Important note!If you give your UI project a different name, click here to see how to fix the namespace (so you won’t have problems in the rest of the lessons).



Step 3: Now we’ll create the “logic” project.

Right-click on the name of the solution “SuperAdventure”, in the Solution Explorer and select Add -> New Project…, to bring up the project selection screen.

For the project type, select Visual C# -> Windows Classic Desktop -> Class Library (.NET Framework). Name the project “Engine”. (See the image above)

NOTE: If you are using Visual Studio Community Edition 2015, you want the project type that just says “Class Library”, NOT “Class Library (Portable)” or “Class Library (Package)”

The project didn’t need to be named “Engine”. That’s just what I like to name it. However, use “Engine” when you create yours, so it will match what’s in the other lessons and videos.


Step 4: When you create a Class Library project, Visual Studio automatically adds a “Class1” class. You don’t need it, so right-click on it and select delete, to get rid of it.


Step 5: When you create a Windows Form project, Visual Studio creates a “Form1” screen by default.

You don’t need to rename it, but I always do. Right-click on it, select “Rename”, and rename it to SuperAdventure (be sure to leave the “.cs” on at the end).

The form name does not need to match the project name. That’s just what I chose to name it for this program.


Step 6: For the UI project to use the code in the Engine project, we need to connect them.

This is called “setting a reference”.

In the SuperAdventure project, right-click on References -> Add References… -> Solution (which will show you the other projects in the solution) -> Engine -> OK.

Now you can see that “Engine” is listed as a reference in SuperAdventure.

This means that the SuperAdventure project will be able to use the code in the Engine project.


Step 7: Now you can run the program.

Click on the “Start” button to see what the game looks like.

It’s not much yet, but you have to start somewhere.

NOTE: When you create the solution, Visual Studio says “New Project…”, when it really should say “New Solution…”, to use the correct term.



Now, everything is ready to start writing the program.

The solution has two projects – one for the UI, the other for the code to do all the calculations and logic for the game.

If you had any problems, or have any questions, please leave a comment below.


Next Lesson: Lesson 03.1 – Building the first screen

Previous lesson: Lesson 02.1 – Installing Visual Studio Community 2017

All lessons: Learn C# by Building a Simple RPG Index


  1. Stanley Havok
    Stanley Havok December 4, 2023

    You Sir deserve a coffee! Thank you for offering to use your time to further help.

    I did download VS 22 just to get moving on the project, I can now see some of the pro’s and con’s of both IDE’s.

    If you are willing to help get these working with VS code, that would be awesome.
    I am sure others would benefit from this.

  2. Matt
    Matt February 11, 2024

    Hi, I’ve downloaded Visual Studio 2022 with all of the components I thought I would need, but I cannot see “Windows Forms Application” anywhere. Is it possible that they have changed the name or something along those lines? I’ve looked for answers on the web but have found nothing particularly helpful. I am attempting to reinstall. Is there a particular component I need to be looking out for? Thanks!

    • Scott Lilly
      Scott Lilly February 12, 2024

      Hi Matt

      In the Visual Studio installer, you should need to select the “.NET desktop development” option, then look for “Windows Forms App (.NET Framework)” when creating the program. If you’re trying to install Visual Studio on a Mac, it probably does not have those options – WinForms only works on Windows.

      Visual Studio Installer - WinForms option

      Visual Studio WinForms project selection

Leave a Reply

Your email address will not be published. Required fields are marked *