简体   繁体   English

程序集引用之间的差异

[英]Differences between assembly references

On some machines after add reference to assembly in csproj generated the next tag. 在一些机器上,在csproj中添加对程序集的引用后生成下一个标记。

<Reference Include="Microsoft.Expression.Interactions">
  <HintPath>..\Libs.SL\Blend\Microsoft.Expression.Interactions.dll</HintPath>
</Reference>

But on some machines generated reference with version, culture, token and processor architecture: 但是在某些机器上生成了带有版本,文化,令牌和处理器架构的参考:

 <Reference Include="Microsoft.Expression.Interactions, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\Libs.SL\Blend\Microsoft.Expression.Interactions.dll</HintPath>
</Reference>

Why is this? 为什么是这样?

Extracted from msdn: 从msdn中提取:

Processor architecture is added to the assembly identity in the .NET Framework version 2.0, to allow processor-specific versions of assemblies. 处理器体系结构添加到.NET Framework 2.0版中的程序集标识中,以允许特定于处理器的程序集版本。 You can create versions of an assembly whose identity differs only by processor architecture, for example 32-bit and 64-bit processor-specific versions. 您可以创建其标识仅由处理器体系结构不同的程序集版本,例如32位和64位处理器特定版本。 Processor architecture is not required for strong names. 强名称不需要处理器体系结构。 For more information, see AssemblyNameProcessorArchitecture. 有关更多信息,请参阅AssemblyNameProcessorArchitecture。 In this example, the fully qualified name indicates that the myTypes assembly has a strong name with a public key token, has the culture value for US English, and has a version number of 1.0.1234.0. 在此示例中, 完全限定名称表示myTypes程序集具有带有公钥标记的强名称,具有美国英语的区域性值,并且版本号为1.0.1234.0。 Its processor architecture is "msil", which means that it will be just-in-time (JIT)-compiled to 32-bit code or 64-bit code depending on the operating system and processor. 它的处理器架构是“msil”,这意味着它将根据操作系统和处理器及时(JIT)编译为32位代码或64位代码。

Code that requests types in an assembly must use a fully qualified assembly name. 请求程序集中的类型的代码必须使用完全限定的程序集名称。 This is called fully qualified binding. 这称为完全限定绑定。 Partial binding, which specifies only an assembly name, is not permitted when referencing assemblies in the .NET Framework. 在.NET Framework中引用程序集时,不允许使用部分绑定(仅指定程序集名称)。

All assembly references to assemblies that make up the .NET Framework also must contain a fully qualified name of the assembly. 对构成.NET Framework的程序集的所有程序集引用也必须包含程序集的完全限定名称。 For example, to reference the System.Data .NET Framework assembly for version 1.0 would include: 例如,引用版本1.0的System.Data .NET Framework程序集将包括:

See more in source: 在源代码中查看更多:

http://msdn.microsoft.com/en-us/library/k8xx4k69.aspx http://msdn.microsoft.com/en-us/library/k8xx4k69.aspx

These lines don't help your application to find the right reference or make a fully qualified assembly name, these lines help Visual Studio to find the reference. 这些行无法帮助您的应用程序找到正确的引用或创建完全限定的程序集名称,这些行有助于Visual Studio查找引用。 Probably you will find these lines only if VS had problems to identify which dll to load. 可能只有在VS确定要加载哪个dll时才会找到这些行。

This is, I know, not the answer that you're expecting :) but I hope it may help you to search in the rigt direction. 我知道,这不是您期望的答案:)但我希望它可以帮助您在严格的方向进行搜索。

I'm not 100% sure, but according to the usual behavior model of .NET Assemblies , in second case you get detailed description (fully qualified name) of the referenced assembly as there are more then one version of the assembly on the machine. 我不是100%肯定,但根据.NET Assemblies通常行为模型,在第二种情况下,您将获得引用程序集的详细描述(完全限定名称),因为计算机上有多个版本的程序集。

In this way compiler knows which assembly exactly is referenced in your project. 这样编译器知道它确切地装配在您的项目中引用。

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

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