默认情况下在4.0中添加System.Core.dll? [英] System.Core.dll in 4.0 added by default?

查看:56
本文介绍了默认情况下在4.0中添加System.Core.dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩VS2010 beta2.我注意到,如果我尝试将System.Core.dll添加到尚未对此进行引用的项目中,则在VS2010中,它抱怨说我无法添加该程序集,因为它已被项目系统引用.知道他们为什么要在VS2010/4.0中这样做吗?是因为他们已经将少量类型从System.Core转发到mscorlib吗?

I was playing around with VS2010 beta2. I noticed that if I try to add System.Core.dll to a project which does not already have a reference to that, in VS2010, it complains saying I cannot add that assembly as it is already referenced by the project system. Any idea why they are doing that in VS2010/4.0? Is it because they have forwarded few types to mscorlib from System.Core?

推荐答案

不是他们为什么这样做的答案",但可能会有所帮助.

Not an answer for "why they are doing that", but could be helpful.

这就是我看到导致隐式引用 System.Core.dll 的一系列操作的方式:

This is how I see the chain of actions that lead to implicit referencing System.Core.dll:

  • 您在Visual Studio 2010中创建一个项目.它将使用以下命令生成.csproj ToolsVersion = 4.0 .假设它将使用.NET 4中的MSBuild.
  • 您的.csproj从 $(MSBuildBinPath)导入 Microsoft.CSharp.targets .我想它将是 c:\ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319 \ Microsoft.CSharp.targets
  • Microsoft.CSharp.targets导入 Microsoft.Common.targets
  • 在.NET 4中,Microsoft.Common.targets导入 Microsoft.NETFramework.props
  • 在Microsoft.NETFramework.props中,您可以找到 AdditionalExplicitAssemblyReferences 节点,该节点具有以分号分隔的程序集列表.我在那里找到System.Core.dll和一个变量,以便以后替换.
  • You make a project in Visual Studio 2010. It generates .csproj with ToolsVersion=4.0. Suppose it will use MSBuild from .NET 4.
  • Your .csproj imports Microsoft.CSharp.targets from $(MSBuildBinPath). I guess it will be c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets
  • Microsoft.CSharp.targets imports Microsoft.Common.targets
  • In .NET 4, Microsoft.Common.targets imports Microsoft.NETFramework.props
  • In Microsoft.NETFramework.props you can find AdditionalExplicitAssemblyReferences node, which has a semicolon-separated list of assemblies. I found there System.Core.dll and a variable for later replacement.

因此,要禁用System.Core.dll的隐式引用,可以将其从 c:\ WINDOWS \ Microsoft的 AdditionalExplicitAssemblyReferences 节点的列表中删除..NET \ Framework \ v4.0.30319 \ Microsoft.NETFramework.props .

So, to disable implicit reference of System.Core.dll, you can remove it from the list in AdditionalExplicitAssemblyReferences node in c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.NETFramework.props.

在此之后,如果您使用例如 System.Linq ,并且在项目中没有对System.Core.dll的引用,则在逻辑上将出现编译错误,就像在Visual Studio 2008中一样

After this, if you use, for example, System.Linq and have no reference to System.Core.dll in your project, you will logically get compile error, just like in Visual Studio 2008.

这篇关于默认情况下在4.0中添加System.Core.dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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