Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Methods Return Values

Andrew Mackrell
Andrew Mackrell
2,734 Points

Compiler error: error CS2015: Source file `TreehouseDefense.exe' is a binary file and not a text file

I already worked through a bunch of errors but I can't get rid of this one.

error CS2015: Source file `TreehouseDefense.exe' is a binary file and not a text file

2 Answers

Steven Parker
Steven Parker
231,198 Points

That file "TreehouseDefense.exe" is the output file, it's not one of the sources. So when you build the code, you want to be sure to tell the compiler that's where to put the output and not to use it as an input.

Typically, the build command would look like this:

$ mcs -out:TreehouseDefense.exe *.cs

If you still have trouble, show what you are using as the build command.

Wesley Trayer
Wesley Trayer
13,812 Points

I got this error when I had a space between the "*" and ".cs".

mcs -out:TreehouseDefense.exe * .cs // Threw an error,
mcs -out:TreehouseDefense.exe *.cs  // did not.
Steven Parker
Steven Parker
231,198 Points

The correct command (with no extra space) means "use every file that ends in ".cs" as an input", but the command with the space means "use every file as an input, and then read the file named ".cs" again".

Wesley Trayer
Wesley Trayer
13,812 Points

Thanks! I was wondering what difference the space made.

mcs -out:TreehouseDefence.exe *.cs && mono TreehouseDefence.exe

Is still giving me this error. Hmm