清理解决方案会导致引用错误 [英] Clean Solution causes reference errors

查看:165
本文介绍了清理解决方案会导致引用错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试通过以前提出的问题进行搜索,但难以通过他们进行筛选,因为它似乎99%指的是引用的问题构建后的 的,而我的问题是,参考文献问题的干净后

I have tried to search through previously asked questions, but it is difficult to sift through them because it seems 99% refers to reference problems after a build, whereas my problem is references issues after a clean.

的问题如下,我重振旧项目哪位我从来没有先前unfortunately-工作和一切编译和当我构建解决方案正常工作。

The problem is as follows, I am reviving an old project -which I've never worked on previously unfortunately- and everything compiles and works fine when I build the solution.

当我做了清理解决方案,虽然,我得到的引用错误的一个项目。有问题的项目是一个Visual Basic Web服务项目。它有另外两个项目(这是C#),当我看项目属性,在引用窗格中我看到,用于参考的路径是SolutionFolder\Project\bin\Debug\Projectname的参考。 DLL。

When I do a Clean Solution though, I get reference errors for one project. The project in question is a Visual Basic web service project. It has a reference to two other projects (which are C#) and when I look at the Project Properties, in the References pane I see that the Path used for the reference is SolutionFolder\Project\bin\Debug\Projectname.dll.

所以当我清理我的解决方案的bin\Debug被清空和参考丢失。这是否意味着基准是设置错?

So whenever I clean my solution the bin\Debug is emptied and the reference is missing. Does this mean the reference is setup wrongly?

我从研究该项目引用工作方式不同的VB项目的问题理解,但我觉得很奇怪的是C#的一个组合, VB项目会给引用错误您清洗液的时刻。

I understand from researching the issue that Project References work differently for VB projects, but I find it weird that a combination of C# and VB projects would give reference errors the moment you clean the solution.

谁能帮我/解释为什么出现这种情况?

Can anyone help me / explain why this happens?

好吧,我创建步骤,来重新创建问题。它的工作原理如下:

Okay, I've created steps to recreate the issue. It works as follows:

Visual Studio中 - >新建项目 - > Visual Basic中WCF服务应用程序

Visual Studio -> New Project -> Visual Basic WCF Service Application

解决方案 - >添加 - >新建项目 - > C#类库

Solution -> Add -> New Project -> C# Class Library

在类库中添加的功能

namespace ClassLibrary1
{
    public class Class1
    {
        public static int Foo()
        {
            return 1;
        }
    }
}



Visual Basic中WCF项目 - >添加 - >参考 - > C#ClassLibrary(从解决方案项目)

Visual Basic WCF Project -> Add -> Reference -> C# ClassLibrary (from the Solution Project)

构建解决方案

在服务我改变GetData函数如下:

In the Service I change the GetData function as follows:

Public Function GetData(ByVal value As Integer) As String Implements IService1.GetData
    Dim foo = ClassLibrary1.Class1.Foo

    Return String.Format("You entered: {0}", value)
End Function

构建解决方案

现在清理解决方案。

Visual Studio中,现在告诉我,我有引用错误。

Visual Studio now tells me I have reference errors.

重新生成。

错误了。

推荐答案

前面提到有一个重要区别的添加一个项目引用添加文件引用的。我想解释一下更详细! - 原来学分去马腾

As Maarten stated there is an important difference between adding a project reference or adding a file reference. I'd like to explain it in more detail - original credits goes to Maarten!

有增加一个参考到 severeal方式不同的充部件。有关详细信息,您可以看看在 MSDN文章 如何:添加或删除引用使用参考管理器

There are severeal differnt ways for adding a reference to an assembly. For detailed information you may have a look at the MSDN article How to: Add or Remove References By Using the Reference Manager.

作为运算要求我们专注于文件和项目引用。我将展示如何VS保存参考设置和什么样的影响,他们对你的项目!在我的例子我做了三个项目的解决方案(A,B和C)。的项目C指的是A和B。

As the op asked for we focus on the file and project reference. I'll show how VS saves the reference settings and what impact they have on your project! In my example I made a solution with three projects (a, b and c). Project C refers to A and B.

正如我们所看到的文件引用的静态是指在你的硬盘文件即可。如果该文件所指向的不是用你会得到的损坏的引用警告的。所以,当你清理你的解决方案,已建成的任何程序集,将被清理。对于这个原因,你得到警告

As we can see a file reference statically refers to a file on your hdd. In case the file refered to is not available you will get a broken reference warning. So when you clean your solution, any assemblies already built, will be cleaned up. For this reason you do get the warning.

指的是一期工程节省目标项目GUID。所以建立在当前项目时,VS会寻找目标项目,并建立他们太多 - 如果有必要

Refering to a project saves the project GUID of the target. So when building the current project, VS will look for the target project and build them too - if necessary.

这就是为什么MSDN说:

That's why MSDN states:

您应该避免添加文件引用到另一个项目的产出
在同一个解决方案,因为这种战术可能会导致编译
错误。相反,使用参考管理器对话框
框的解决方案选项卡创建项目到项目引用。这种战术使得球队
发展通过使您在您的项目创建类
库的更好的管理更容易。欲了解更多信息,请参阅
故障排除断开的引用。

You should avoid adding file references to outputs of another project in the same solution, because this tactic may cause compilation errors. Instead, use the Solution tab of the Reference Manager dialog box to create project-to-project references. This tactic makes team development easier by enabling better management of the class libraries that you create in your projects. For more information, see Troubleshooting Broken References.

修改

由于项目中包含的不同的语言 VS未能解决您的项目引用。你可能有一个看看这个相似,所以问题的处理两种语言在一个解决方案。显然,尽管它是一个项目的参考,VS处理它像一个文件引用。

As your project contains different languages VS fails to resolve your project reference. You might have a look at this similar SO question dealing with two languages in one solution. Apparently although it is a project reference, VS handles it like a file reference.

在Visual Studio中存在的几种语言服务 它们的特定语言的。所以,如果你通过一个C#装配另​​一种C#程序集时,由项目引用创建的根据语言服务将处理任何可能引用错误引用。

Within Visual Studio there are several language services which are language specific. So in case you refer from one C# assembly another C# assembly the according language services will handle any potential reference errors when created by a project reference.

但如果你是指一个从C#(或其他方式轮)VB.net装配的没有接口语言服务为。一个很简单的例子是,相关的<总结>标签从C#程序集不会在VB.net项目显示(如链接的问题/表示注释)。

But in case you refer a VB.net assembly from C# (or the other way round) there is no "inter-"language service for that. A very simple example is that related <summary> tags from a c# assembly won't show up in a VB.net project (as the linked question/comments stated).

这篇关于清理解决方案会导致引用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆