Search code examples
visual-studioproject-reference

Visual Studio cannot find reference


The problem

Suddenly, Visual Studio (2015 RC) started throwing error CS7069 in my face a lot. It states

Reference to type '...' claims it is defined in '<assembly>', but it could not be found.

Yet VS's functionality "Goto reference" did function and squigglies weren't consistently present, so I figured something weird was going on.

How I created the problem

It started when I was refactoring/splitting a project. I was moving .cs files from one project to a new one. Types that I moved to the new project couldn't be found anymore by the compilation process of a project that referenced both projects.

What I tried

I verified that the relevant assembly was indeed referenced, present and had the type with public modifier. I rebuilt it, checked version numbers (of target frameworks etc), removed the relevant reference and re-added it, cleaned solutions and projects, checked configuration manager settings, removed all VS's temporary files and whatnot, and I couldn't fix the bug for 4 days. 4 long days, might I add.

Googling didn't result in anything either, so I hope that the next poor fellow who made the same mistake as I did finds this page, as I finally found out what was going on:


Solution

  • I had two projects with identical assembly names...

    Renaming the new assembly in its properties menu made all errors vanish.