Sunday, April 13, 2014

Strange CSC build Error in Visual Studio

Today I had one of those really horrible Visual Studio errors that just would not go away …

clip_image002

OK .. Message seemed simple enough, I’m missing a reference to the DataAccess assembly, which was breaking with a compilation error … So I check the solution to make sure WGPSN.Utility has been referenced and everything looked fine…

clip_image004

Reference is correct and when I compile WGPNS.Utility it’s building correctly. Weird …… ???

I went through the usual stuff like making sure that everything was building against the same version of .NET Framework (4.5) and everything was set correctly.

Solution !!

The reason for this error was nothing to do with the code but the Build Order for the solution …

Right click the solution file and select “Project Build Order”.

clip_image006

WGPSN.DataAccess was before WGPSN.Utility??? Why?? DataAccess references Utility and therefore the build should be Utility first then DataAccess.

Click the “Dependencies” tab and select the offending project “WGPSN.DataAccess” and it has not dependencies on “WGPWN.Utility”? That was not correct as once a project is referenced, that project should be built before the project that is using the reference.

clip_image008

Check the WGPSN.Utility and click “OK”.

clip_image010

All the problems went away.

I really don’t understand why this problem occurred as these settings are usually automatically controlled by Visual Studio, but keep your eyes out for it.