0

I have the following problem.

I made an application in C# (using Visual Studio 2010). Everything worked fine.

Then I had to make some changes in a "main.cs". Did those... all fine again.

Then I had to make other changes in same file. Did those... cleaned the solution built it. The problem is that when I run/debug/anything the application I get the same result as I did before I made the changes. I even tried to break the code (called a random function that didn't exist, used wrong syntax), but the result was the same "Build successful" and the old version.

Is there some kind of cacheing mechanism or something? How do I get rid of this problem?

I added prints for the "compile" solution... I can't find the build property.

Enter image description here

Enter image description here

3 Answers 3

4

Try deleting the bin and obj directories in the Visual Studio project directory. The obj directory contains the temporary files used to create the binary while the bin directory contains the binaries for that project. In addition, check if there are any warnings being shown when you build your solution.


I was able to reproduce the same error i.e. build successfully even though the file has not been compiled. The Build Action of the file had not been set to Compile.

Build Action not set to Compile

The correct Build Action for a code file (main.cs) would be Compile.

Correct build action


According the updated question the file properties does not have the compile option

The reason for this is that the file (main.cs) has not been included in the project, but the "Show all files" button is "on" in the Solution Explorer. The file has not been included in the project (hence not compiled) and the file icon is greyed out in Solution Explorer.

To include this file in the project, right click on add existing item to the project (see following image). In the subsequent dialog select the file (main.cs) and click on the add button.

Add existing item

This should solve your problem.

In future, it is best to keep the "Show All Files" button as "off" to avoid confusion.

Sign up to request clarification or add additional context in comments.

5 Comments

@zozo, have you verified that the bin folder(s) (of all projects in the solution) is empty after you clean the solution?
I deleted the directory. All of it. It is recreated exactly the same.
Can you check whether the Build Action for the file in question (main.cs) is set as Compile (it is available under the file properties)?
Probably this would solve... but at the specified .cs seems that I don't have the build option. I added prints.
@zozo, I have edited the answer according to your updated question.
2

Is it possible you have selected the build and run last successful version? Check out my answer to something similar here. If the changes you made broke something and you had checked the boxes and hit yes to the dialog boxes in my answer below then that's most likely the issue.

Cannot see changes I make when I run my application in Visual Studio

2 Comments

I selected prompt to launch... no prompt. Build successful
This may not be your issue then. The other guy has some other tips. If you don't get anywhere and it's not a big project, could you just delete the solution files and recreate the project?
1

Make a backup of your solution.

Delete the .cs files from within the solution explorer. If your program compiles and runs, than you are linked to source folders and not actually using the one in your solution.

I doubt this is it, but worth a try. The other things that came to mind you have already eliminated out with the previous answers.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.