Thursday 16 February 2012

VS2010 cannot add reference

If you have seen the all too infamous "Cannot add reference" in visual studio and gone down the usual route of making sure you have added the project to the solution, added necessary files, shaking the P.C. and performing a druid ceremony and it still doesn't work, I may have another one for you that I encountered today whilst at work.

At our place, we have a job service solution which is a windows service and a large number of projects which are the individual jobs.  All the settings for configuration are naturally on the service solution e.g. we have a configuration in the job service solution of dev, preprod, release, SIT and UAT.  The job service solution has all the projects for each job and the tests so its pretty large.

We also have solutions which have groups of jobs so we can work on the smaller projects and tests without having to recompile the whole service unless we are deploying the whole thing.  We did a bit of a tidy up so the service solution had the configrations but our other solutions only had debug and release as we didn't need them.

I didn't check the jobservice solutions selected configuration and tried to add an exisitng project and received the all too familiar "cannot add reference" due to the project that was being added having no matching configurtion.

Even worse if you try and add a reference to an existing project that is in the solution which was there before you deleted the configurations you cannot add that either even though its sitting there. What followed was a great deal of head scratching and WTF moments.

If all else fails and you are getting this issue or other bizarre behaviour, check the configurations that each project has against the main solution and you may find there is a bit of a mismatch.

No comments:

Post a Comment