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 trialRadu - Adrian Buha
Courses Plus Student 5,535 PointsCannot open assembly 'Program.cs': File does not contain a valid CIL image.
Hello,
Apparently, it seems that my workspace won't compile the code. I have tried to copy the original code from this video and it still doesn't work.
Just for posterity, here is the code:
using System;
namespace Treehouse.FitnessFrog { class Program { static void Main() { int runningTotal = 0;
bool keepGoing = true;
while(keepGoing)
{
// Prompt user for minutes exercised
Console.Write("Enter how many minutes you exercised or type \"quit\" to exit: ");
string entry = Console.ReadLine();
if(entry == "quit")
{
keepGoing = false;
}
else
{
// Add minutes exercised to total
int minutes = int.Parse(entry);
if(minutes <= 10)
{
Console.WriteLine("Better than nothing, am I right?");
}
else if(minutes <= 30)
{
Console.WriteLine("Way to go hot stuff!");
}
else if(minutes <= 60)
{
Console.WriteLine("You must be a ninja warrior in training!");
}
else
{
Console.WriteLine("Okay, now you're just showing off!");
}
runningTotal = runningTotal + minutes;
// Display total minutes exercised to the screen
Console.WriteLine("You've entered " + runningTotal + " minutes.");
}
// Repeat until user quits
}
Console.WriteLine("Goodbye");
}
}
}
Does anyone has any idea why? Thank you.
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! I suspect that the problem here are the commands that you're running at the command line. Your code does compile and run for me.
The first command you should be typing is:
mcs Program.cs
This compiles the program and makes an executable. If you right click your file structure on the left side and choose "Refresh", you should now see "Program.exe" has appeared magically. To run this newly created executable file you should type:
mono Program.exe
If you're issuing these commands in this order and it's still not running, please let me know!
Radu - Adrian Buha
Courses Plus Student 5,535 PointsHey! You are right. I found the problem. I used the wrong command. I tried to combine "clear && mcs Program.cs && mono Program.exe" as show in the tutorial but instead of using "mono Program.exe" i used " mono Program.cs". Thanks a lot for your help!