30 December 2010

An error occurred while validating. HRESULT = '80004005'

I was having trouble with this error today, when I was trying to build a Deployment package. I also noticed that my deployment package showed no Detected References anymore.
The weird thing was, that my solution build properly and I could even run the software. It was just the deployment package that was producing errors.

As I found, the first thing to check is missing references. If they are not in use in the code, debugging the project will not produce any errors, building the deployment will. This also includes references to other projects, which are not included in the solution. If not pointing directly to the pre-built dll, these will produce problems.

For me though, this did not solve my problem, but I did find something else that caught my eye;
during building, the output was showing:
Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5"
After some searching, I discovered that one of my colleagues had opened the project (which is used in various solutions) in Visual Studio 2010 (which changed the csproj file) and checked it in, rather than using the VS 2010 version of the csproj file.
After rolling back this csproj file (and some others with the same problem), I checked my build output, and saw that it didn't show this ToolsVersion warning anymore.
After this, the deployment package built as expected. It even shows its Detected References properly again.
If you don't have any means of reverting to an older version, you can also just open the csproj file with any text editor (may I recommend notepad++, a very good free text editor) and do a find and replace on ToolsVersion="4.0", to replace it with ToolsVersion="3.5". Make a backup of your files though, just in case.

2 comments:

Anonymous said...

What do you need to do to use VS 2010 version of the csproj file (for a project created with VS 2008) without checking it in?

Michael Jepson said...

I guess you could just upgrade the csproj file to VS 2010 and use it, without checking it in.

Please keep in mind though that any new files you add (or remove) are not updated in the csproj file that is checked in, so your colleague who is using the project in VS 2008 will have to be notified of these changes, so (s)he can manually add or remove these files from the project.
There might be other changes that have to be manually repeated by any colleague using the checked in csproj file.