.net dll不复制到bin文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3842383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 14:47:06  来源:igfitidea点击:

Dll not copying to bin folder

.netvisual-studiodllreference

提问by Dan H

I'm having an issue with Devart DLLs not getting copied to the bin folder of my web app. I have my web app project that references projectA. ProjectA references projectB. The Devart Dlls are used in projectB and are not being copied into the web app projects bin folder during a build. ProjectB also references EL Unity dlls and they are being copied correctly. All of the Dlls in question are physically located in a folder in projectB and that is where the reference point. (I don't have the references pointing to the GAC)

我遇到了 Devart DLL 无法复制到我的 Web 应用程序的 bin 文件夹的问题。我有引用 projectA 的 Web 应用程序项目。项目 A 引用项目 B。Devart Dll 在 projectB 中使用,并且在构建期间不会被复制到 web 应用程序项目 bin 文件夹中。ProjectB 还引用了 EL Unity dll,并且它们被正确复制。所有有问题的 Dll 都位于 projectB 中的一个文件夹中,这就是参考点。(我没有指向 GAC 的参考资料)

The dlls that copy correctly are Microsoft.Practices.Unity, Microsoft.Practices.Unity.Configuration and Microsoft.Practices.ServiceLocation.

正确复制的 dll 是 Microsoft.Practices.Unity、Microsoft.Practices.Unity.Configuration 和 Microsoft.Practices.ServiceLocation。

The dlls that are not being copied correctly are Devart.Data, Devart.Data.Oracle and Devart.Data.Oracle.Design.

未正确复制的 dll 是 Devart.Data、Devart.Data.Oracle 和 Devart.Data.Oracle.Design。

Here's the references for each dll...

这是每个dll的参考...

<Reference Include="Devart.Data, Version=5.0.124.0, Culture=neutral, PublicKeyToken=09af7300eec23701, processorArchitecture=MSIL">
  <HintPath>..\Dtn.PetroDex.Dal\ThirdPartyDlls\Devart.Data.dll</HintPath>
  <SpecificVersion>False</SpecificVersion>
  <Private>True</Private>
</Reference>
<Reference Include="Devart.Data.Oracle, Version=5.70.170.0, Culture=neutral, PublicKeyToken=09af7300eec23701, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\Dtn.PetroDex.Dal\ThirdPartyDlls\Devart.Data.Oracle.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Devart.Data.Oracle.Design, Version=5.70.170.0, Culture=neutral, PublicKeyToken=09af7300eec23701, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\Dtn.PetroDex.Dal\ThirdPartyDlls\Devart.Data.Oracle.Design.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\Dtn.PetroDex.Dal\ThirdPartyDlls\Microsoft.Practices.ServiceLocation.dll</HintPath>
  <SpecificVersion>False</SpecificVersion>
  <Private>True</Private>
</Reference>
<Reference Include="Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\Dtn.PetroDex.Dal\ThirdPartyDlls\Microsoft.Practices.Unity.dll</HintPath>
  <SpecificVersion>False</SpecificVersion>
  <Private>True</Private>
</Reference>
<Reference Include="Microsoft.Practices.Unity.Configuration, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\Dtn.PetroDex.Dal\ThirdPartyDlls\Microsoft.Practices.Unity.Configuration.dll</HintPath>
  <SpecificVersion>False</SpecificVersion>
  <Private>True</Private>
</Reference>

Anyone else having this issue? Am I doing this wrong? Thanks

还有谁有相同的问题吗?我这样做错了吗?谢谢

EDIT I opened a file monitor and watched where visual studio was loading the reference and for Unity it was getting the dlls from the location I specified. But, for the Devart dlls it's looking in the GAC! Could the Devart dlls be causing this somehow?

编辑我打开了一个文件监视器并观察了 Visual Studio 在哪里加载引用,对于 Unity,它从我指定的位置获取 dll。但是,对于 Devart dll,它在 GAC 中查找!Devart dll 会以某种方式导致这种情况吗?

采纳答案by Vinay B R

  1. right click on the referenced dlls and check if copy local is true.
  2. you can also try readding your references once, this had resolved a similar problem for me when i had converted a VS2005 project to VS2008 project.
  1. 右键单击引用的 dll 并检查复制本地是否为真。
  2. 您也可以尝试阅读您的参考资料,当我将 VS2005 项目转换为 VS2008 项目时,这为我解决了类似的问题。

回答by Oscar

I had a similar problem with external references. The thing is that the unused libraries are not copied. Do you use the Devart libraries from your projectB? Any instance, inheritance, anything, ...?? Please try this: Instansiate some mock class from the three libraries in your projectB and recompile. It has worked for me. I would like get to the formal explanation.

我对外部引用有类似的问题。问题是未使用的库不会被复制。您是否使用项目 B 中的 Devart 库?任何实例,继承,任何东西,......?请尝试以下操作:从 projectB 中的三个库中实例化一些模拟类并重新编译。它对我有用。我想得到正式的解释。

回答by Ognyan Dimitrov

The problem appears too when you have dlls that are dependencies of others. For example Microsoft.ApplicationServer.Caching.AzureClientHelper.dll is used internally by Microsoft.ApplicationServer.Caching.Client. Even though I have copyLocal = True the helper assembly is not copied because it is not referenced anywhere directly in my code. To avoid this problem you can make a private type variable like this :

当您的 dll 是其他人的依赖项时,问题也会出现。例如,Microsoft.ApplicationServer.Caching.AzureClientHelper.dll 由 Microsoft.ApplicationServer.Caching.Client 在内部使用。即使我有 copyLocal = True 辅助程序集也不会被复制,因为它没有直接在我的代码中的任何地方引用。为了避免这个问题,你可以像这样创建一个私有类型变量:

Type dependsOnThisTypeOfAssembly = typeof(TypeFromDependentAssembly);

类型dependsOnThisTypeOfAssembly = typeof(TypeFromDependentAssembly);

This will make a reference to the type and the assembly will be copied locally while in the build process.

这将引用类型,并且在构建过程中将在本地复制程序集。

回答by Rafael Diego Nicoletti

Set as Copy local doesnt work for me. The only thing that resolves (is unusable) is to reference some type contained in assembly.

设置为复制本地对我不起作用。唯一解决(不可用)的是引用程序集中包含的某些类型。

回答by DCNYAM

If these DLLs are in a sub-directory for project B, make sure the "Copy Local" property for each reference is set to true.

如果这些 DLL 位于项目 B 的子目录中,请确保将每个引用的“复制本地”属性设置为 true。

Also, if the DLL files are included as files in your project, check the visual studio properties for the files themselves. The "Build Action" should be set to "None" and the "Copy to Output Directory" should be set to "Do not copy". EDIT: Simply having them as references with copy local = true will take care of the copying.

此外,如果 DLL 文件作为文件包含在您的项目中,请检查文件本身的 Visual Studio 属性。“Build Action”应设置为“None”,“Copy to Output Directory”应设置为“Do not copy”。编辑:简单地将它们作为引用与 copy local = true 将处理复制。

If these settings are different for the different DLLS, that could explain why some are being copied into the bin folder and others are not.

如果这些设置对于不同的 DLLS 是不同的,这可以解释为什么有些被复制到 bin 文件夹中,而有些则没有。