如何创建 x64 DynamicAssembly

发布于 2024-09-06 21:43:24 字数 244 浏览 2 评论 0原文

我目前正在将我的一个项目从 x86 移植到 x64。它是一个插件,绝对必须作为 x64 运行,因为主机也是如此。

应用程序的一部分创建动态程序集:

AppDomain.CurrentDomain.DefineDynamicAssembly(...)

然后将其保存到磁盘。我用 dumpbin /headers 检查了它,它是 x86 的!

如何从代码中强制程序集为 x64?

I'm currently porting a project of mine from x86 to x64. It is a plugin and absolutely must run as an x64, since the host does too.

Part of the application creates a dynamic assembly:

AppDomain.CurrentDomain.DefineDynamicAssembly(...)

And then saves that to the disk. I checked it with dumpbin /headers, its in x86!

How can I force the assembly to be x64 from code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剑心龙吟 2024-09-13 21:43:24

这是完全正常的,包含 IL 代码的程序集始终打包在具有 32 位标头的 DLL 中。与项目 + 属性、构建选项卡、平台目标 = 任何 CPU 得到的结果相同。

请记住:纯 .NET 程序集仅包含数据,不包含代码。 JIT 编译器将 IL 转换为 32 位还是 64 位代码由启动 EXE 的位数决定。

This is entirely normal, assemblies that contain IL code always are packaged in a DLL that has a 32-bit header. Same thing you get with Project + Properties, Build tab, Platform Target = Any CPU.

Keep in mind: pure .NET assemblies only contain data, no code. Whether the JIT compiler translates the IL to 32-bit or to 64-bit code is determined by the bitness of the startup EXE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文