简体   繁体   English

为什么VS2010“失去”我对构建的参考?

[英]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. 然后,我在Windows服务项目中添加了解决方案,以便将库包装起来。

I've added a reference to my class project, added a using statement and var'd an object from the class lib. 我添加了对我的类项目的引用,添加了一个using语句并从类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: 它的颜色编码很好,Refactor可以按住Ctrl键并导航到它,但是当我构建项目/解决方案时,它声称我的类型是未知的并且有一个例外:

The type or namespace name 'EmailLoaderCore' does not exist in the namespace 'MPN.Apollo' (are you missing an assembly reference?) 名称空间'MPN.Apollo'中不存在类型或命名空间名称'EmailLoaderCore'(您是否缺少程序集引用?)

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? 我做错了还是VS2010很奇怪?

Turns out, if you show the Warnings in the Build window, it tells you why :) Doh. 事实证明,如果你在Build窗口中显示警告,它会告诉你为什么:) 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. 服务项目现在默认为“Framework 4 Client Profile”,这是Framework 4的一个子集,这意味着不会链接到除此之外的任何其他内容。 Changed the project type to Framework 4 and all is good. 将项目类型更改为Framework 4,一切都很好。

When there is a difference in Target .Net Framework(under project settings), it will create reference missing problems. 当Target .Net Framework(在项目设置下)存在差异时,它将创建参考缺失问题。 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. 使Target框架工作相同后,两个项目都解决了错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM