同一系统上的 64 位和 32 位非托管 dll - 最佳实践?
我有一个内置的 32 位和 64 位共享 dll。两个版本都使用相同的名称 foo.dll。如何在系统上安装两个 foo.dll,以便我的 32 位和 64 位应用程序在其路径中找到正确的 dll。
Windows 本身使用 SysWOW64(用于 32 位 dll)和 System32(用于 64 位 dll)。我想避免部署到这些文件夹。让两种位数的 dll 在同一个机器上共存并被链接到它们的适当应用程序找到的可接受的方式(如果有)是什么?
I have a shared dll which is built in 32 bit and 64 bit. Both builds use the same name, foo.dll. How can I install both foo.dlls on the system so that my 32 bit and 64 bit apps find the correct dlls in their path.
Windows itself uses SysWOW64 (for 32-bit dlls) and System32 (for 64-bit dlls). I would like to avoid deploying to these folders. What is the accepted way (if any) to have a dll in both bitnesses coexist on the same box and be found by the appropriate applications that are linked to them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不部署到受文件重定向影响的文件夹(即 system32),那么您几乎需要为 DLL 指定不同的名称。原因是 DLL 搜索路径在 32 位和 64 位进程之间共享,如果您依赖搜索路径来定位 DLL,则强制您使用不同的名称。
请注意,我排除了任何依赖 SxS 版本控制的解决方案。尝试沿着这条路线走下去会给任何尝试使用您的 DLL 的人带来各种并发症和头痛。
If you don't deploy to a folder that is subject to file redirection (i.e. system32) then you pretty much need to give the DLLs different names. The reason for this is that the DLL search path is shared between 32 and 64 bit processes and if you are relying on the search path to locate the DLL, that forces you to use different names.
Note that I am ruling out any solutions that rely on SxS versioning. Attempting to go down that route leads to all sorts of complications and headaches for anyone attempting to use your DLL.
您没有说明如何安装二进制文件或如何加载或安装它们,但我推测解决方案将涉及为 32 位和 64 位安装提供单独的安装目录。
传统上,安装在 64 位计算机上的 32 位应用程序通常安装到“c:\program files(x86)”的子文件夹中,而不是“c:\program files”。我假设调用 GetSpecialFolder 的 32 位应用程序和设置(包括 MSI)将被重定向到 c:\program files(x86) 目录。
您不必担心 64 位二进制文件会安装在 32 位操作系统上。只需在安装过程中阻止这种情况发生,因为这些二进制文件无论如何都不会加载。
You didn't indicate how you were installing your binaries or how they were getting loaded or installed, but I surmise that the solution will involve having separate installation directories for 32-bit vs. 64-bit installs.
Traditionally, 32-bit apps installed on 64-bit machines typically get installed into a subfolder of "c:\program files(x86)" instead of "c:\program files". I'm assuming 32-bit apps and setups (including MSIs) that call GetSpecialFolder, will get redirected to the c:\program files(x86) directory.
You don't have to worry about 64-bit binaries getting installed on 32-bit OS. Just block that from happening in setup, since those binaries won't load anyway.