If you use a different project name…
There’s one thing you need to do if you gave your UI project a name other than SuperAdventure, change the project’s namespace.
A namespace is a way to group your classes together.
When you create a project in Visual Studio, it will use the project’s name as the namespace name. So, if you name your project “MyAwesomeGame”, its namespace will be “MyAwesomeGame”. The problem you’ll have is if you copy/paste code from my code samples, it expects the namespace to be “SuperAdventure”.
Fortunately, there is a simple way to make the program work.
Open your solution in Visual Studio.
Right-click on your UI project name (in Solution Explorer) and select “Properties”.
Click on “Application” (on the left-side menu).
Change the “Default namespace” value to “SuperAdventure”.
Now you can copy and paste the code from the lessons, and not have problems due to the namespaces not matching.
Why would you not also change the Assembly name? Would it give rise to further problems?
The namespace is an artificial name, for us to group our classes in a way that makes sense to us. We only use it to say, “all these classes are in the XYZ namespace group.” In fact, if you create a folder in a project, and create classes underneath it, their namespace will be “ProjectName.FolderName”, instead of just “ProjectName”.
The assembly name is the name of the file that is saved on disk.
The assembly name is only used when Windows looks for the file to load into memory. Once the file is loaded and running, and the program is looking for the classes in memory, it will use the namespace. So, it is OK for them to be different.
Let me know if that didn’t make sense.
I had significant issues getting the “using Engine” part to work in lesson 5.1. The issue ended up being that I needed to go to the properties under SuperAdventure > References > Engine and change the name from ClassLibrary2 to Engine after changing it in the class library itself.
That’s something that’s frustrating about Visual Studio. If you create a project, it uses the project’s name as the namespace. But, if you rename the project, it doesn’t rename the namespace. It would be nice if it gave a warning and let you update that.