.NET 'Any CPU' 项目是否应该绑定到 Framework 或 Framework64 DLL? [英] Should .NET 'Any CPU' projects bind to Framework or Framework64 DLLs?

查看:21
本文介绍了.NET 'Any CPU' 项目是否应该绑定到 Framework 或 Framework64 DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 C# Visual Studio 项目 (.csproj),它引用了 System.Data 的 Framework64 版本.当我尝试使用 MSBuild/Team Foundation Server (TFS) 在另一台机器上失败,因为 64 位 DLL 不存在.

I have a C# Visual Studio project (.csproj) that has a reference to the Framework64 version of System.Data. When I try to build using MSBuild/Team Foundation Server (TFS) on another machine, it fails as the 64-bit DLL doesn't exist.

我应该绑定到框架版本,还是在 64 位机器上运行时这会限制我?.NET 是否会在可能的情况下重定向绑定以使用 64 位?

Should I bind to the Framework version, or will this limit me when running on 64-bit machines? Does .NET redirect the binding to use 64-bit when possible?

推荐答案

我想你的意思是在你的问题中Any CPU,对吗?假设是这种情况,几乎在所有情况下都可以不考虑位数进行绑定.

I think you mean Any CPU in your question, correct? Assuming that's the case, binding without regard for bitness is the way to go in nearly all circumstances.

回忆一下 .NET 代码是 JITed(及时编译)——意思是 32 位和 64 位代码来自 C# 或 VB.NET 编译器是一样的,无论你打算在什么架构上运行.当代码在运行时被 JIT 处理时,它就会变成 32 位或 64 位.

Recall that .NET code is JITed (Just In Time compiled) -- meaning 32 bit and 64 bit code out of a C# or VB.NET compiler is the same no matter what architecture you plan to run on. When the code is JITed at runtime, that's when it becomes 32 or 64 bit.

在某些情况下,您必须考虑目标架构.一种特定情况是对 COM-wrapper DLL、.NET Framework 提供或除此以外.也就是说,如果这些 DLL 文件未标记为 32 位,则这些 DLL 文件将被标记为(在 COM 的情况下)仅 32 位(因为 COM 是仅 32 位的体系结构),如果它们没有标记为 32 位,则与 COM 的互操作将不起作用.因此,由于它们被明确标记,您的项目输出也应该如此.

In some situations, you do have to mind the target architecture. One specific case would be any references/dependencies on COM-wrapper DLLs, .NET Framework supplied or otherwise. This being that these DLL files will be marked (in the case of COM) as 32 bit-only (as COM is 32 bit only architecture) if they were not marked as 32 bit, interop to COM would not function. Therefore, since they are explicitly marked, your project outputs should be as well.

这篇关于.NET 'Any CPU' 项目是否应该绑定到 Framework 或 Framework64 DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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