简体   繁体   English

Visual Studio 2010程序集参考

[英]Visual studio 2010 assembly references

I've got a project on a computer with installed devexpress line for win forms. 我在装有用于获胜表格的devexpress行的计算机上有一个项目。 In VS2010 I add references to some of devexpress .dll(s) and mark those references as 'Copy Local' and build project. 在VS2010中,我添加了对一些devexpress .dll的引用,并将这些引用标记为“复制本地”并构建项目。 Than I send a folder with a project to another user whose machine has not installed devexpress on it. 然后,我将一个包含项目的文件夹发送给另一个未在其计算机上安装devexpress的用户。 When he opens the solution all devexpress references are shown as broken and the assembly won't compile. 当他打开解决方案时,所有devexpress引用均显示为损坏,并且程序集无法编译。

The output is as the following: 输出如下:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): 
warning MSB3245: Could not resolve this reference. Could not locate the assembly
 "DevExpress.Data.v13.1, Version=13.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a". 
Check to make sure the assembly exists on disk. 
If this reference is required by your code, you may get compilation errors.

How to add references to the assembly correctly so as I can open it on a machine with no such .dll(s) installed? 如何正确添加对程序集的引用,以便可以在未安装此类.dll的计算机上打开该程序集?

In order to do that you need to add the references via Add Reference... / Browse . 为此,您需要通过Add Reference ... / Browse添加参考 In the csproj file for your project you should have something like: 在项目的csproj文件中,您应该具有以下内容:

<Reference Include="Name.Of.Assembly">
    <HintPath>Relative\Path\ToAssemblyFile.dll</HintPath>
</Reference>

BUT VisualStudio tries to be smart and adds the Reference to the installed assemblies, even if you choose Browse... to add them. 但是 VisualStudio会尝试变得聪明,并且即使将“ 浏览...”添加到已安装的程序集中,也将“引用”添加到已安装的程序集中。 You can either: 您可以:

  1. Not install the DevExpress package and only copy the DLLs to your development machine 不安装DevExpress软件包,仅将DLL复制到您的开发机器上
  2. Manually edit the .csproj file 手动编辑.csproj文件

Either way, you need to keep the DLLs somewhere. 无论哪种方式,您都需要将DLL保留在某个地方。 I usually put them under source control. 我通常将它们置于源代码控制之下。

"Copy Local" option is copying files to the published directories after building process. “复制本地”选项是在构建过程之后将文件复制到发布的目录。

You can include these dlls in the separated solution folder, reference VisualStudio to them and commit this folder with solution to svn or tfs. 您可以将这些dll包含在单独的解决方案文件夹中,将它们引用VisualStudio并将此文件夹与解决方案一起提交给svn或tfs。

To achieve this, you should add the DevExpress (or other third-party) assemblies to a folder under your solution root directory, then reference the assemblies in this folder rather than referencing the DevExpress install directory. 为此,您应该将DevExpress(或其他第三方)程序集添加到解决方案根目录下的文件夹中,然后引用此文件夹中的程序集,而不是引用DevExpress安装目录。

You should also add the third-party assemblies to source control, so they're available to all developers. 您还应该将第三方程序集添加到源代码管理中,以便所有开发人员都可以使用它们。

If the other developer hasn't installed a DevExpress license, it will still build, but will display a nag screen at runtime. 如果其他开发人员尚未安装DevExpress许可证,则仍会进行构建,但会在运行时显示nag屏幕。

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

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