简体   繁体   English

Visual Studio 2008生成解决方案问题

[英]Visual Studio 2008 Building Solution Issues

We have a VB.NET Windows Forms Solution developed using the 3.5 framework. 我们有一个使用3.5框架开发的VB.NET Windows窗体解决方案。

The solution has more than 30 projects (dlls) that are referenced from one to another. 该解决方案具有30多个相互引用的项目(dll)。 We even have some projects separated into N layers too (one for the data Access, other for the business logic, and so on). 我们甚至将一些项目也分为N层(一个用于数据访问,另一个用于业务逻辑,依此类推)。

Since a time ago the solution does not work properly. 从前,该解决方案无法正常工作。 When we start Visual Studio (2008), it shows hundreds of errors. 当我们启动Visual Studio(2008)时,它显示了数百个错误。 The vast majority are: 绝大多数是:

"Type 'XXXX' is not defined. “未定义类型'XXXX'。

And after doing some "clean" + several "build" we are able to get the binaries. 在完成一些“清理” +几次“构建”之后,我们便可以获取二进制文件。

Anyone has any idea about what is the problem and how to solve it?? 任何人都对问题和解决方法有什么想法?

You have a problem with the dependencies, maybe incorrect order or circular reference. 您的依赖项有问题,可能是顺序不正确或循环引用。 For example this can be one of the scenarios you are suffering: 例如,这可能是您所遇到的情况之一:

  • Project A depends on Project B 项目A取决于项目B
  • Project B depends on Project C 项目B取决于项目C
  • Project C depends no nothing. 项目C毫无依赖。

You build all projects in this order A,B,C. 您以A,B,C的顺序构建所有项目。 First time you build A,B fails but C works. 第一次构建A,B失败,但是C起作用。 Second time A fails but B,C works. 第二次A失败,但B,C起作用。 Third attempt A,B,C works. 第三次尝试A,B,C有效。

In theory Visual Studio should work out the correct order... but if you have unused dependencies or circular references it fails. 理论上,Visual Studio应该计算出正确的顺序...但是,如果您有未使用的依赖项或循环引用,它将失败。

You have to review and clean your dependencies . 您必须检查并清理依赖项 You can use nDepend ( http://ndepend.com ) or similar tool (Resharper, Architecture Explorer in VS2010 Ultimate, etc.) to make a dependency map and then use it to clean your dependencies. 您可以使用nDependhttp://ndepend.com )或类似工具(Resharper,VS2010 Ultimate中的Architecture Explorer等)制作依赖关系图,然后使用它来清理依赖关系。 You can find a lot of good tools in this SO question . 您可以在此问题中找到很多好的工具。

Once you review and clean your dependencies it would build at the first attempt. 一旦检查并清理了依赖关系,它将在第一次尝试时建立。

All you need is to correct your project build order. 您需要做的就是纠正您的项目构建顺序。

First work out what projects depend on what others. 首先确定哪些项目取决于其他项目。 The ones that do not depend on anything should go to the top of list and ones that depend on others should go below in order. 不依赖任何内容的应排在列表的顶部,不依赖其他内容的应排在下面。

Then right-click your solution and select Project Build Order... from the popup menu. 然后右键单击您的解决方案,然后从弹出菜单中选择Project Build Order...

在此处输入图片说明

The following dialog box will appear. 将出现以下对话框。 Set the project build order in correct sequence. 按正确的顺序设置项目构建顺序。 Use the Dependencies tab to specify the dependencies correctly. 使用“ Dependencies选项卡可以正确指定依赖关系。 在此处输入图片说明

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

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