Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Does VS2010 "Lose" my reference on build?

I've developed a class library that does stuff, and tested it with unit tests. The library and tests build and work fine. I then added in a Windows Service project to the solution to wrap the library up in.

I've added a reference to my class project, added a using statement and var'd an object from the class lib. It colour-codes just fine and Refactor can ctrl-click and navigate into it, but when I build the project/solution, it claims the type of my is unknown and there's an exception:

The type or namespace name 'EmailLoaderCore' does not exist in the namespace 'MPN.Apollo' (are you missing an assembly reference?)

This doesn't make sense to me. I've tried removing the reference, cleaning the solution, re-creating the reference, but no joy. Am I doing something wrong or is VS2010 being weird?

like image 448
Amethi Avatar asked Jun 09 '10 21:06

Amethi


2 Answers

When there is a difference in Target .Net Framework(under project settings), it will create reference missing problems. It creates strange problems like when i add the reference it gets added. But when i build, again it will loose the reference. After making Target frame work same for both the project resolved the error.

like image 37
Anant Avatar answered Oct 21 '22 14:10

Anant


Turns out, if you show the Warnings in the Build window, it tells you why :) Doh.

Service projects default to "Framework 4 Client Profile" now, and that is a sub-set of Framework 4 which means no linking to anything else other than that. Changed the project type to Framework 4 and all is good.

like image 79
Amethi Avatar answered Oct 21 '22 14:10

Amethi