Visual Studio compiles but the exe isn't there

Viewed 73803

Source code that compiles fine on other peoples environments won't correctly work in my environment. When I do a rebuild the compile occurs but when visual studio goes to move the exe from /obj/debug/{solution} to /debug/{solution} it cannot find the exe in the /obj/debug/{solution}. To make this even more crazy even after I reinstall visual studio it doesn't work. On other people environments it works find. Please note that this is a windows mobile 6, compact framework 3.5 project, Visual C++ project.

EDIT: Visual Studio 2008 is being used.

EDIT2: After looking at the logs again come to find out it says it is compiling but it isn't really compiling. Interesting enough it doesn't throw any errors until it tries to link the code. When it goes to link the object files, they aren't there and it fails.

14 Answers

There are two subtly different paths. I was looking here, which doesn't exist:

C:\Users\james\source\repos\CppHelloWorld\Release\CppHelloWorld.exe

The actual exe is here - note the path contains the x64 platform that it was built for:

C:\Users\james\source\repos\CppHelloWorld\x64\Release\CppHelloWorld.exe

In general, the path seems to be:

$PROJECT_PATH\$PROJECT_NAME\$PLATFORM\$CONFIGURATION\$PROJECT_NAME.exe

I had exactly the same problem. Just close Visual Studio and reopen it again (basically restart it) and it should work.

I've found this to be random for myself in now VS2016. My work around has been to just create another project and copy the contents from the one with out the .exe to the new one. For some reason the new one normally will have the proper .exe and location needed. While this isn't a complete solution at least it's been working for me for the time being.

It happened with me today:

TL;DR; You might be using some C# code in your project who belong to a language version which is not supported by the .NET Framework version targeted by your project

Details:

I had two projects in my solution. One project was already existing. I added a new project targeting most recent .NET Framework v4.6.1 supported by Visual Studio(VS) 2017 class library project template. I used some C# language features which is present in C# v7.0. In such a case, VS can compile the project but can't create the output in bin directory.

Eventually I had to merge the new project code files into the existing old project which was targeting .NET Framework v4.5.1.

So I changed the target Framework version to the latest .NET Framework v4.6.1 for the existing projects also. Then the old project also started supporting my newly pasted C# language features.

In my case, my network security team released an unannounced security update that preventing me from creating any .exe files. I figured that out at midday after trying all the solutions (+ more) here.

In my case, the error appeared after I cloned my solution on a new machine.

I did not realise that the newly-cloned solution had AnyCPU set by default, when in reality my solution only supported x64. The compiler, however, did not return any error.

What pointed me in the right direction was the Output log, highlighted that of the 4 projects my solution was composed of, one of them was always skipped, i.e. only 3 were actually compiled. Scrolling up a bit the log, I noticed some message similar to MSIL mismatch between CPU versions.
Switching from AnyCPU to x64 solved the error for me.

(I then deleted the AnyCPU option from the Configuration Manager to avoid this issue in the future)

Related