1

I am running into a very strange problem and I would like to understand what is happening. I have a solution with 30 projects and all it is working fine except one of them. This project has a dependency on another project in the same solution. Adding a Project reference, looks fine in the editor (no red lines etc) but when compiling I get compiler error as if the reference is not there. However if I go and Add Reference directly on the DLL which the project generates then it works fine. I double check and in both scenarios it references the exact same DLL. Why it wouldn't work as a project reference? Any ideas welcome !

4

6 回答 6

3

Project build order is a ratty problem to solve and MSBuild certainly does drop the ball sometimes. There isn't anything in the question that helps us help you find the root cause.

The simple solution is to help MSBuild and just be explicit about it. Right-click the project that doesn't build correctly and select "Project Dependencies". Tick the ones that need to built first. Also note the Build Order tab in that same dialog, it shows you in what order the projects are going to get built. Make sure it is now a happy order.

Also note that it is technically possible to create a circular dependency. It isn't simple to do, it requires incrementally changing the projects and adding references to existing DLLs. In other words, what you did and shouldn't have done :) You diagnose that with Build + Clean and never succeeding in building the solution again.

于 2013-07-29T16:18:03.273 回答
0

我建议编辑项目文件并查看每个引用实际指向的内容。此外,检查配置管理器并确保在为您正在构建的特定平台\配置构建时包含“问题”项目。'

于 2013-07-29T16:04:25.800 回答
0

两个项目都在同一个解决方案中?如果是,您可能需要检查它们的构建顺序,确保引用的顺序是在引用它的顺序之前构建的。MSBuild 中也有一个错误,也许这会解决您的问题: MSBuild 错误的解决方案

于 2013-07-29T16:26:08.303 回答
0

当我遇到这样的问题时,我通常会通过以下两件事之一来解决它们......

  1. 关闭 VS 并重新打开解决方案。有时它对引用“感到困惑”
  2. 删除项目引用并重新添加
于 2013-07-29T15:55:35.123 回答
0

您可能没有引用所述 DLL 的最新版本。直接 DLL 引用不会强制重建该 DLL,但项目引用会。有时 VS 不会清楚地报告依赖项 DLL 构建错误,因此很可能是 DLL 的最新代码中存在错误,而您要链接的代码是旧代码。尝试查看输出窗口(而不是错误列表),了解为什么它不会构建的详细信息。

于 2013-07-29T16:00:03.373 回答
0

项目名称与所在文件夹的名称不同。不确定将其用作项目参考时是否与此有关,但重命名项目文件夹可解决此问题。

于 2013-07-29T21:35:52.470 回答