简体   繁体   中英

Visual studio 2010 assembly references

I've got a project on a computer with installed devexpress line for win forms. In VS2010 I add references to some of devexpress .dll(s) and mark those references as 'Copy Local' and build project. Than I send a folder with a project to another user whose machine has not installed devexpress on it. When he opens the solution all devexpress references are shown as broken and the assembly won't compile.

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?

In order to do that you need to add the references via Add Reference... / Browse . In the csproj file for your project you should have something like:

<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. You can either:

  1. Not install the DevExpress package and only copy the DLLs to your development machine
  2. Manually edit the .csproj file

Either way, you need to keep the DLLs somewhere. 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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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