大会通过不会被复制到输出目录添加引用添加,除非在code简称 [英] Assembly added via Add Reference not copied to output directory unless referred to in code

查看:214
本文介绍了大会通过不会被复制到输出目录添加引用添加,除非在code简称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:

  • 在项目1项是在解决方案中的程序集
  • 在项目2是在同一个解决方案的可执行程序集项目
  • 在项目2有一个项目引用(通过添加引用)到项目1
  • 在项目2没有的直接的参考命名空间/项目中的1种在code
  • 在项目2使用Ninject动态加载项目1,并在其中使用的实现类
  • Project 1 is an assembly in the solution
  • Project 2 is an executable assembly project in the same solution
  • Project 2 has a project reference (via Add Reference) to Project 1
  • Project 2 does not directly refer to namespaces/types in Project 1 in the code
  • Project 2 uses Ninject to dynamically load Project 1 and use the implementation classes within it

问题:

  • 即使复制本地设置为True为引用,被引用程序集不在GAC存在,引用的程序集的没有的复制到输出构建目录
  • 在Ninject随后没有找到总成等绑定/解析失败
  • Even though Copy Local is set to True for the reference, and the referenced assembly does not exist in the GAC, the referenced assembly is not copied to the output build directory
  • Ninject subsequently does not find the assembly, and so the binding/resolution fails

这个过程很好地满足相同的设置,其中一些类的引用程序直接引用,以及装载了Ninject,所以我认为原因如下:如果VS检测到任何类型的引用的组件内被称为到的在code 的,它不会复制引用的程序集,即使它添加为具有复制本地=真。

This process works fine for an identical setup where some classes in the referenced assembly are referenced directly, as well as loaded by Ninject, so I believe the cause is as follows: If VS detects that no types within a referenced assembly are referred to in code, it won't copy the referenced assembly, even if it's added as a reference with Copy Local = True.

解决方案(S):

  • 找到讲VS的一种方式,复制本地(我是认真的)=真 - 这将是我的理想的解决方案
  • 添加文件引用的引用程序集。不是很大,因为我失去了一个项目引用的优势(这可能是也可能不是完全在我的脑海)。
  • 请参见装配在code一些'令牌'的方式。凌乱 - 我想用引用列表维护我想包括的组件/模块列表
  • 在生成后的步骤组装各地复制。凌乱,不够理想。

谁能帮助的第一个解决方案,或提出另一个?

Can anyone help with the first solution, or suggest another?

推荐答案

啊哈......引用程序集针对性的.NET Framework 4.0,但引用组件是针对.NET程序4.0的客户端配置文件版本。

Aha.. the referenced assembly targeted .NET Framework 4.0, but the referencing assembly was targeting the Client Profile version of .NET 4.0.

基准加入,出现了,完全没有问题或警告(从UI或VS至少),但我的无法的是指它在code,它不会告发'T出现在输出。

The reference was added, appeared, no problems or warnings at all (from the UI or VS at least), but I couldn't refer to it in code, and it wouldn't appear in the output.

如果任何人有想法,为什么这也未被发现,也许他们可以让我知道?

If anyone has ideas why this went undetected, perhaps they could let me know?

这篇关于大会通过不会被复制到输出目录添加引用添加,除非在code简称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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