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 Form” project (File -> New Project -> Windows Form Application). Make sure you are using the using the project templates listed under “Visual C#”.

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, in the Solution Explorer and add a new “Class Library” project named “Engine” (Add… -> New Project… -> Class Library).

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 Express 2013 for Desktop

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

52 thoughts on “Lesson 02.2 – Building the solution for the game

  1. Loving the guide, really helping me learn programming. Just want to point out some phrasing issues in this page – particularly in the “Deciding how many projects the solution needs” section in the 4th and 5th paragraphs. Great guide though, really enjoying every minute of it.

  2. The only thing that would have made this better, is pictures with each step. I could have flew through this thing with those, but I got slowed down by having to read things very carefully, or watching the slow-paced video (which is good, it needs to be slow-paced, which is why you need the pictures for speed!).

    But really though, great tutorial, I’m excited to get through it.

    1. Thanks, I’m glad you liked the course. It was tough trying to figure out a good balance for pictures, since they can be big and slow down the website. For future tutorials, I may see if there are any good tools to have small thumbnail pictures on the page (so it loads fast) that can easily (and optionally) be expanded for any users who want to see the full-sized versions.

  3. Liking the course!  Just wanted to know if I should have been able to hear audio for the “C# RPG Tutorial – 02.2 – Building the solution for the game” video.  I had volume turned to the max but no audio, which I was able to pickup when I watched the Visual Studio 2013 installation video.

    1. Thanks. There’s only audio for the Visual Studio installation video. I was living in a noisy apartment when I made the course, so I didn’t do audio for the rest of them.

  4. Hello! I’ve started this tutorial and already encountered a problem.

    When trying to create the reference, I get an error message saying “A reference to “Engine” could not be added.”

    Tried searching for a solution but couldn’t find any. Thanks.

    1. Hmmm. The only ways I can think of for this to happen don’t seem very likely to happen. Try going into the SuperAdventure references, delete any references to “Engine” that you see, save the solution, then try to re-add the reference.

      If that doesn’t work, can you take a screenshot of your Solution Explorer (with the references sections expanded for both projects), post the screenshot somewhere, and send me a link to it?

  5. Hi, me again! Found a fix for the error. I don’t know why it worked, but reinstalling Visual Studio did the trick. Now I could add the reference without a problem!

  6. I’m having the same problem with not being able to add the engine. The only thing that is different is that I’m using VS 2015.  Could that be the problem?

    1. I expect it should still work about the same in Visual Studio 2015. I haven’t installed 2015 yet, but will be doing that this week on my new computer.

      If you can do a reinstall without much difficulty, you might want to try that. Or, if you can post a picture of the Solution Explorer (with the “references” sections expanded), I’ll see if there’s any obvious problem.

  7. hello;

    i try to Add engine class to my reference and it doesn’t appear on my reference list as my previous happen to them how they sort out that error

  8. hello ;

    At time i was straggling with the reference i got other option so that i can access my class Engine so if there are other who get the same error like me i can guide him

      1. I had the same problem as others at first, but I went back and looked in the references section and tried to add Engine again when I noticed a small checkbox to the left of the Engine description. I checked it and all was good.

  9. Hi. Just asking why we use winforms instead of WPF. If everywhere I have heard was that is better in most cases, its newer, more styling and less work in graphics part. Should I still stay on winforms?

    1. I used WinForms because that’s what I was working with at the time – although I was mostly working on the back-end parts of systems. If you’re going to create your own new program, you’d probably want to use WPF, since it is more popular. If you’re familiar with WPF, you could create this solution with a WPF project for the UI. I don’t think there’s anything in the source code that is WinForms specific. It should work pretty much the same in WPF (other than the lesson on adding in the controls on the UI form – the labels, buttons, datagrids, etc.)

  10. Having the same problem with adding Engine Project. Included a screen shot of error, for some reason I cannot link a photo image to this page. Tried dropping it and that didn’t tried visual and text. well this was a short lesson

  11. Hello,

    I am a student learning informatics and very interested in creating video games, but I didn’t know how and where to start since we are not learning much about creating video games at school (only simple form applications with 1 project in the solution or little about HTML, but this is different! The divided projects and adding the references to link the projects makes it whole for me and as you explain  everything is so clear and reasonable!

    I am at the beginning, but it is already so awesome, just what I was searching for! These descriptions are working perfectly with Visual Studio 2015 too! Thank you already for this tutorial with these brief explanations! I hope that i can keep up with you and create this game for start 🙂 (I am interested in simple graphics too, but thats for later) I appreciate your work!

    Many thanks: David

  12. Adding a reference to Engine in Visual Studio Community 2015 failed for a Windows Form application, but creating as a WPF project had no issues referencing the Engine class library.

      1. Hi Scott, I think something is up with Visual Studio 2015 Community. Although I tried a couple times previously to close VS & start from scratch with no success, I’ve since rebooted and restarted VS & now the project adds the Engine reference without any issues.

        Great tutorial overall, thanks for putting the effort into this!

  13. I’m using VS 2015 Community and made it a Windows 8 solution (using Windows 10).

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

    There is no Solution button! I tried to browse to the Engine file but I couldn’t add it to the reference that way.

    1. I believe you need to create the Engine project as a “Portable Class Library”, instead of a “Class Library”, when you have a Windows 8 solution. I will test this tonight, when I finish work, and see exactly what you need to do.

  14. I`m stupid. I tried to add the referenc to the wrong project. I didn’t realise that there where two references. Sorry 🙂


  15. Hi scott im just starting ur lessons 🙂

    First off ive installed ect followed ur videos. After we started a mew project ive noticed that its “form1.vs” not .cs.

    Does this matter before I continue ?

    Many thanks kind regards


    1. Is it form1.vb? If so, that means you created the project as a Visual BASIC project, not a Visual C# project (the “cs” extension is used by C# projects, “vb” by Visual BASIC). You will need to delete that project. When you create the project again, make sure you are using the projects in the Visual C# section.

      Add new project under Visual C# section

  16. As a network guy who has a couple of (humility here) awesome ideas for games I’ve been having trouble finding where to start… I haven’t had a programming course since 06 let alone coded anything except webpages. A great big thank you for helping me overcome the initial obstacles.

  17. Hey Scott,

    I run into a little problem with this tutorial.
    I can not run the application because there is no static main method.
    But on your side there is also none and it seems to compile just fine.
    I use Visual Studio Community 2015.
    Any idea how i could fix this?

    1. Ok, I solved the issue. I created the project SuperAdventure with a wrong name, so I renamed it. Because of that I had to rename the namespace inside SuperAdventure.cs.
      I hope this may help others that have similar problems.

  18. Hiya i have a few questions (i am using MicrosoftVS 2015), for lesson 02.2, Step 5, do i rename the engine form 1 or do i rename the SuperAdventure form 1?. Also i don’t understand step 4 (lesson 03.1) very well as i can’t see SuperAdventures in the properties at the lower right corner and when i click on properties i still can’t move onto step 5 because i cannot find the ‘text’ property. as well step 5 says to change ‘Form1’ into ‘MyGame’ however i don’t know which form. Could you help?

    1. The Engine project should not have any forms. That project should be a “Class Library” project. It sounds like you might have created it as a Windows Form project. You can’t change a project type, so it might be easiest to delete the solution, and its files (since you haven’t added anything to the projects yet) and re-create the solution and projects.

  19. Hi Scott! I’m using Visual Studio Community 2015 and I’m having trouble adding the Engine class library.

    First of all, when I go to Add Item (“Add Project” is no longer an option) Class Library is not listed as a valid template.

    If I go to New Project then there are a few options: Class Library (Portable for iOS, Android, and Windows), Class Library, and Class Library (Portable).

    However, I’ve tried making each of these and I can’t seem to add them as a reference to the SuperAdventure project. If I choose Add Reference and go to browse, it’s by default searching for .dll, .tlb, .olb, .ocx., .exe, or .manifest files, none of which seem to be in any of the Engine class libraries I’ve tried creating. Any ideas?


    1. Hi Jason,

      When you add the Engine project, do you right-click on the solution file (in the Solution Explorer section), and see these menu options? This is where you would create the new project in the SuperAdventure solution.

      The project type for the Engine project should be “Class Library” – without the “Portable”, or “Portable for iOS”.

      When you add the reference, do you select the “Projects” section on the left side of the Reference Manager popup screen? That should show the projects in the solution. It should look like this:

      Please tell me if those do not fix the problem.

      1. Ah, I was right clicking on the project instead of the solution, stupid mistake! Thank you so much for the quick response.

  20. Hi, Just wanted to Say Thanks For this Brief Tutorial, Really helps. Love the way you Describe Parts of the Solution as you talking to “Dummies”, Makes it all the more easier for ANYONE to learn from you. GOOD JOB!

  21. When starting a new project I don’t have an option to choose location or solution name, only “Name:”. Also I’ve done this and when right clicking and trying to add class library, add project is not an option.

    1. Are you creating the solution by clicking on the “File” menu option (double-check with the video to make sure you are in the correct place)?

      If you are, can you take a screenshot, and upload it someplace for me to look at? Make sure it includes the Solution Explorer area of Visual Studio (the upper-right section).

Leave a Reply

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