63
votes

I have a Visual Studio 2010 solution with a few projects. I can successfully build with Build -> Build Solution or Build -> Build MyCompany.MyProduct.MyProject. After building I press CTRL+F5 and successfully run the start up project. This works as expected.

After I change a source file, save it and then again build (with either Build -> Build Solution or Build -> Build MyCompany.MyProduct.MyProject) it builds successfully. I am still able to press CTRL+F5 and run the startup project. This again works as expected.

The problem is in the following scenario: After I change a source file, save it and directly press CTRL+F5 then Visual Studio 2010 says BUILD FAILED and there are no errors. And it doesn't start my startup project (of course).

Am I missing something?

17
Might not hurt to clean the project and rebuild if that error keeps happening consistently. If it's all of your projects, then that would imply an underlying problem that I'm ill-equipped to diagnose.lsuarez
Copy and paste the content of the Output window into your question.Hans Passant
I closed and reopened Visual Studio and also deleted the output folder of some of the projects (3 of them have it shared) and the problem disappeared. I think it will reappear though and I'll paste the output window's content.ceco
Gopi's answer helped... Copied the files to a different folder with a smaller path length.LCJ

17 Answers

110
votes

Close Visual Studio, delete the .suo file for your solution. It's a 'hidden file' in Windows and contains user preferences, but it can also do nasty things.

20
votes

Seems a bit late, but what worked for me was to check my Output window.

I had a reference to a Function that didn't exist yet. I don't know why it never came up in the Error List, but the Output window told me exactly where the problem was.

13
votes

Try repeating the same steps by changing the location where you compile/run. Make sure your new location has less folders to traverse when compared to your old location. A lengthy path to the source code had resulted in a similar issue to me and I overcame it by choosing a shorter path.

8
votes

I closed my visual studio.

Deleted every bin folder. (I had a weird permission error, so I deleted the files and back track deleted the folders including bin).

Reopened visual studio. Performed build or rebuild and everything was working again.

3
votes

Check your project physical path , If is to long , Copy project to some root directory folder with very short name. And try to build your project.

2
votes

I had this problem and had one warning but couldn't find any errors. Eventually I copied the build command from the output window into a command window and ran it manually - it spat out four errors after the warning. I have no idea why this worked.

The command required should be labelled "CoreCompile" and look something like this: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;SILVERLIGHT;WINDOWS_PHONE /errorendlocation /preferreduilang:en-US /highentropyva- /reference:"C:\Dropbox\code

If you don't see it, try changing your build output settings under Tools->Options->Projects and Solutions->Build and Run, set "MSBuild project build output verbosity" to Normal or higher.

1
votes

In case some other folks are experiencing this issue (I had tried deleting the SUO file first but this didn't work for me):

I solved it by creating a blank new Project in my solution and importing all source files into the new project. Likely the problem sat in project file.

1
votes

I had the same problem, solved by the following step

go to Tool->option->projects and Solution->General, make sure to check the box "Always show Error List if build finishes with errors", in this case, visual studio will show the error list.

0
votes

In my case I did not see a Code Contracts bug in the output window:

CodeContracts: xxx: Unhandled Exception: System.IO.FileNotFoundException:
Could not load file or assembly 'System.Data.SqlServerCe, Version=3.5.1.0,
Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies.
The system cannot find the file specified.

I solved it by disabling Cache Results in the Code Contracts windows for that project, as suggested in this answer.

0
votes

I was working on a web site project that referenced a library project (in the same solution) when I ran into this issue. Build failed while the editor was highlighting syntax and navigating to the source. Very frustrating.

None of the other answers worked for me; I thought this issue might be related as I recently used DBML for the first time on this machine. Still not entirely sure it wasn't a contributing factor.

After cleaning solution, temp files, restarting VS, etc., I ended up excluding the 2 offending files, which allowed the solution to build successfully, then when I included them again everything built correctly.


0
votes

My issue arose from converting a functional vs2008 project to vs2010. All other projects in the solution came across fine, but this one would build the MIDL portion, then stop and fail. Detailed build setting revealed nothing, so finally I created a whole new project with all files the same. This worked. Then I compared the settings, and finally after changing the various parts to match, I discovered that the converted project had MIDL->General -> "MkTypeLib Compatible" set to blank. This was a valid setting in vs2008 apparently, but in vs2010, it apparently must be set to Yes or No (or inherit).

This has fixed my issue.

0
votes

if your solution contains too many projects ,

build projects individually,

Check which project is failing

for that project check the references of that project , if on any reference if their is yellow color mark, then delete that reference , and add that again , then build and check,

this will work

or

check in output window , each line , in some line it may be showing , dependency is their , but didnt found it , that is the problem causing

this may be due to file corruption

0
votes

Has this issue when dealing with Sharepoint 2013 Workflows in VS 2013. To solve it did the following:

  1. Unload worklfows ( the buggy one) project.
  2. Delete .csproj.user file
  3. Opened .csproj file in the notepad and delete the following lines:

     <PropertyGroup>
      <VisualStudioVersion Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0'">11.0</VisualStudioVersion>
     <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
    

After RELOADING project into solution, the VS added exactly the same lines AGAIN, but no LoaderException issues now.

0
votes

I had this issue today as well... after changing the verbosity of build to diagnostic like @Jac suggested, i discovered that the problem relies in one my resx files. Apparently, one image was corupted or was too big, i deleted it and it worked!

0
votes

I faced that problem two days ago. I checked on Windows output and I founded there was a missing reference to VBIDE: Cannot find wrapper assembly for type library VBIDE. I showed all files on the solution explorer, expanded references and I found there was a reference to that assembly. I do not know how that reference came into my project and I was sure I did not need it. I just removed it and everything was fixed.

0
votes

Another thing to check is that if any of your source files are open it will not be able to build. I had to restart my computer.

0
votes

Some times if the Directory path is more than 248 chars it will fail the Solution. Make sure complete path is less than that.I have faced the same issue than i made short and it did worked for me.

Regards Venkateshwarlu, MSBI Developer, Hyderabad.