Lesson 17.1 – Running the game on another computer

Lesson Objectives

At the end of this lesson, you will know…

  • How to move your game to another computer, and run it without Visual Studio


Right now, you have to start Visual Studio and load your solution before you can play the game. But if you want to share your program with someone else, you don’t want to make them install Visual Studio.

So, now we’ll build a version that you can copy to a CD/DVD/thumb drive/etc. and share with your friends and family.

Visual Studio has a nice installation package creation project, but it gets a little complex. So, we’re going to use the “quick and dirty” method, for now.


Building the program for another computer

The first thing you want to do is build the program in “Release” mode.

So far, we’ve used “Debug” mode, which can be useful while writing the program. Debug mode lets you take a look into the program while it’s running, in case you have a problem and aren’t sure where it’s happening.

But when you’re done writing your program, and are ready to “release it”, you want to use Release mode.

Then, you just need to copy the program’s files to a computer that has the correct .Net Framework installed, and you can run it there.


Link to video on YouTube


Step 1: Start Visual Studio Express 2013 for Desktop, and open the solution.

Step 2: In the menu, to the right of the “Start”, there is a dropdown that probably says “Debug” right now (that’s the default value). Change it to “Release”.

Step 3: From the menu, click on “Build”, then “Build Solution”. This will create the executable files – the ones needed to run your program.

Check the “Output” box, in the bottom middle of Visual Studio. It will tell you when it’s done building the program, along with where it was built.

Step 4: Open up Windows Explorer and get to the folder where the executable file was created.

You’ll see the file there, along with some other ones. You don’t need all of them, but it won’t hurt to have the extra files. So, we’ll copy all of them to our new location.

In this case, I just created a new folder named “Games”, with a sub-folder under it named “SuperAdventure”. You can name your folder whatever you want.

Then, paste the files into this folder.

Step 5: To make this easier to run, create a desktop shortcut for the SuperAdventure.exe file. That’s the executable, the file to run the game.

Now, you can double-click on the shortcut on the desktop and start playing your game.



Now you can copy your program to another computer (assuming they’ve been running Windows Update, and have the same version of the .Net Framework you used when you made the program.

If you learn how to create a Windows Installer project, you can end up with a single program someone can use to install your program on their computer. If their computer is missing anything, or doesn’t have the correct version of the .Net Framework, the installer program will fix that for them.

There are also some more complex installations for different types of projects – ones that use a database, or are run as a website.

But, now you know how to copy this game over to your friend or family member’s computer, so they can see the program you created and play the game.


Source code for this lesson

No source code for this lesson


Next lesson: Lesson 18.1 – Future enhancements for the game

Previous lesson: Lesson 16.3 – Functions to use weapons and potions

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

20 thoughts on “Lesson 17.1 – Running the game on another computer

  1. Hey Scott! I changed the Solution Configurations to “Release” and when I build the program it came up with an error: “SuperAdventure” is a ‘namespace’ but is used like a ‘type’ in the program.cs Ive checked the code on SuperAdventure and it is spelled correctly I also re typed it in both codes. Not sure what happened :/

    1. Does it work if you build the program in “Debug” mode, or do you still see the same error?

      I’ve seen this problem come up for a couple other people, and it’s usually a little difficult to track down to the original source. But, here are the places I’d start:
      1. Did you rename any of the projects (SuperAdventure or Engine) after you created them? If so, you’ll probably need to manually correct the namespaces in the projects. You can see how to do that here: https://scottlilly.com/learn-c-by-building-a-simple-rpg-index/lesson-05-1-creating-objects-from-classes/#comment-1639
      2. Check the SuperAdventure.cs class and make sure it says “public partial class SuperAdventure : Form”. Then check SuperAdventure.Designer.cs and make sure it starts with this:
      namespace SuperAdventure
      partial class SuperAdventure

      If those look good, is there a place you can upload a copy of your solution? DropBox, Github, etc. Then I could check out some other things that are a little difficult to describe through us talking back and forth in the comments here.

      1. Nope haven’t Renamed anything and everything else looks fine. I don’t have a way to upload it but I can make an account which site do you prefer?

        1. DropBox is probably the easiest. Please upload the complete solution (including all the sub-directories, and files in them) and reply here with the share link for the DropBox directory. I might not be able to look at it until Friday night or Saturday.

    1. I got the comments, but am holding them in moderation (since they’re not really relevant to anyone else, until we figure out the problem). I sent you a couple e-mails that the Engine project was missing from the zip file. Can you check on that and try re-uploading it?

    2. I’m going to check something out on Monday (when I’ll be at my computer with Visual Studio 2013). I think the problem might be how the solution was setup, which might also be why you had problems sending both projects together.

    3. I found the problem. Your UI project’s name is different from “SuperAdventure”. If you right-click on your UI project, and select “Properties”, and click on “Application”, you’ll see your project’s namespace. Right now, it matches the project name “WFA game practice”. But, when you copy-paste the code from the lessons, they are all defined with “namespace SuperAdventure”.

      The easiest way to fix this is to change the “Default namespace” value (on your UI project’s properties) to “SuperAdventure”. You could also change all the classes in the UI project to have the namespace match the namespace in your properties. But then you’d need to remember to do that every time you copy-paste something into the project.

      Please let me know if that doesn’t fix the problem.

  2. Hey Scott

    this was my first experience with visual studio and programming, and i had a lot of fun ! really great tutorial and looking forward to continue this one with the enhancements to the game !

    Thanks you so much for doing this really complete tutorial

    Keep up ! 🙂

    1. Thanks! I’ve started creating the lessons for a WPF version of the game, which will eventually add more capabilities to the game. I should be posting the initial lessons in the next week or two.

  3. Hi Scott, I really appreciate your C# lessons as they gave a lots of insight into how to make a windows form application, as I have only have some previous experiences with C and Java.
    Now, onto my question, I ran into some problem when trying to compile the program in the final step. I have 2 errors which I don’t know how to resolve since the C# source file here doesn’t related to the files in the tutorial.
    I also want to mention that when I commented those files, the game compiled normally, but I can’t kill the rat in the first quest since the use button didn’t work, so I suspect that the error has something to do with the “use” button
    Sorry if my description is to vague to you, in that case, here is my solution:

    Thanks for reading my question 🙂

    1. Hello Trung,

      For the first problem, when you were working with SuperAdventure.cs in the Design screen, you might have accidentally double-clicked on a control. When that happens, Visual Studio creates an “eventhandler” and a new function. If you paste in code from one of the lessons, that code will not have the function – which causes the error. You can comment out lines 243 and 290, in SuperAdventure.Designer.cs. Those are the eventhandlers you do not need.

      For the “Use” button, it is missing its eventhandler. To fix this, edit SuperAdventure.cs, in the “Design” screen (you should be able to do this after you comment the two extra eventhandler lines). Left-click on the “Use” button once. Look at the “Properties” section in the lower-right corner of Visual Studio (see the picture below). Click on the lightning bolt picture (to see all the events). Find the “Click” event, and left-click in the box to the right of it. This will show you the available functions. Select “btnUseWeapon_Click”. That will create the eventhandler to connect the “Use” button to the function to use the weapon.

      Connect the Use button to its function

      You can read more about eventhandlers in Lesson 21.3.

      Please tell me if that does not fix the problem.

      1. My gosh, I can’t believe that the solution is so simple I have finally been able to fix the problem, thank you so much.
        As for the event handle, I have only reached lesson 17.1 of yours, so I haven’t thought about it. Now I can finally resume building the game.
        Just one question, do you work on any other languages other than C#?

          1. Hi Trung,

            I can’t login to my Microsoft account, to look at your screenshot. But, check the eventhandlers for the movement buttons, to ensure they are moving to the correct location. The “South” button should call btnSouth_Click. If it is calling a different direction, that is one thing that could cause that error.

            If that is not the problem, can you post the error message in another place?

  4. Sorry for the late reply, works in college carried my away.

    Anyhow, I can assure you that I have linked all the buttons with their appropriate events. As for the OneDrive link, I found it a little odd that since I thought that the link allow anyone to view and download the photo, with or without a Microsoft account. But here is my alternate Google drive link: https://drive.google.com/file/d/0B3ZAN8xIbpCdWlJBVkdwUjE3OTg/view?usp=sharing

    1. Hi Trung,

      If the buttons are all connected correctly, my next thought is to look at the PopulateLocations() function in the World class. Make sure all the lines that set the LocationToNorth/East/South/West properties are set correctly. If this is happening when moving South from the Alchemist’s Garden (for example), make sure there is the line:

      alchemistsGarden.LocationToSouth = alchemistHut;

      If you can’t find the source of the error there, can you upload your solution (including the folders under it, and all the files in them) to GitHub or Dropbox, so I can look at it?

      The OneDrive problem is with my Microsoft accounts. I have several of them, tied to different countries (I lived overseas for several years). So, logging in is often a problem for me. 🙁

Leave a Reply

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