Visual Studio 2012 How to debug "Unable to add reference to project x" error?

markmnl picture markmnl · Dec 12, 2012 · Viewed 13.5k times · Source

In Visual Studio 2012 in a blank new Class Library I am trying to add reference to an existing project in the solution, also a Class Library, MonoGame.Framework.Windows8 (https://github.com/mono/MonoGame), but get the error:

Unable to add reference to Project MonoGame.Framework.Windows8

I have built the existing library, MonoGame, successfully and made it a dependency of the new one. What could be the problem?

(It's extremely annoying the error message does not give a reason!)

Answer

markmnl picture markmnl · Dec 13, 2012

Trying to add the built dll has a reference gave a more explicit error message which has solved the problem for me, it said:

“A reference to ‘x’ could not be added. The project targets ‘.NetFramework’ while the file reference targets ‘.NetCore’. This is not a supported scenario”

The MonoGame Class Library is a Class Library (Windows Store apps) type! (The bit in parenthesis is important! Presumably the difference is the Windows Store apps type use .Net Core which is not the same as .Net Framework).

So to get it working your project must be a Class Library (Windows Store apps) which is available under the Windows Store option in Add New Project.