JBSnorro
JBSnorro

Reputation: 6746

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:

Upvotes: 3

Views: 6001

Answers (4)

4sofwill
4sofwill

Reputation: 1

I had this problem and it turned out I had the wrong build configuration selected. The reference projects and the project I was building were not selected for that build configuration. Simple to fix, but not something I looked at for a while.

Upvotes: 0

user3691460
user3691460

Reputation: 141

Fixed bug on Visual Studio 2015. Go to Tools menu, Options, Debugging, General: Check: "Use the legacy C# and VB expression evaluators"

Upvotes: 3

JBSnorro
JBSnorro

Reputation: 6746

I had two projects with identical assembly names...

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

Upvotes: 3

vmg
vmg

Reputation: 10576

Try to clean/rebuild the project. It helped me.

Also try to remove all of the *.suo and *.user files in your solution folder http://blog.galasoft.ch/posts/2014/01/quick-tip-what-to-do-when-visual-studio-freaks-out-and-everything-is-red/

Upvotes: 0

Related Questions