Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C#

Compiler Errors in Invader Class and Missing Source File

I recently finished the C# Objects course, following along with every video in my own workspace. I've basically copied exactly what the guy was doing (aside from giving variables different names, just to add my own flare). However, I've encountered several compiler errors that were not shown in the videos. Here's a snapshot of my workspace:

https://w.trhou.se/n6rpu2xooj

There are four errors pertaining to the Invader file, and two that state that a "source file" could not be found. What do they mean? If you know a fix for this, I'd like if the snapshot were forked and shown to me. Thanks!

1 Answer

Steven Parker
Steven Parker
215,984 Points

The "source files" are the files that make up your project, like 'Map.cs" and "Path.cs".

You might be getting some of these errors from changing some of the names but not changing it every place that it is referenced. For example, in Location.cs you have a reference on line 9 to "Maplocation", but now you no longer have that name defined in your project.

I cleared up the errors in Invader.cs (missing semicolon on line 10, "invader" misspelled on line 11), but that just revealed more compiler errors. Fixing them all might be a big job.

My recommendation is to download the project files and use the final version files (stage 4/video 5). Then, starting with those, make your changes one at a time, and make sure the project still compiles after each change. That will make it much easier to find overlooked reference mismatches.

I was also able to fix those errors in Invader.cs and that removed all those compiler errors for me. The only one I have left is error CS2001, stating that "Source file '.cs' could not be found". Is there any way to fix that problem without the project files? Besides, I don't even think I have the right program to use them.

Steven Parker
Steven Parker
215,984 Points

That doesn't seem like an actual file name, there should be something in front of the period. What was the actual command you gave that returned that error?