通过 ClickOnce 部署识别目标计算机(32 位或 64 位)
我有一个 Windows 窗体 应用程序,并通过 ClickOnce 部署来部署该应用程序。现在,我有一个第三方 DLL 文件,它有针对 32 位和 64 位操作系统的不同版本。
是否可以通过ClickOnce根据目标机器(32位或64位)部署不同的DLL文件?
I have a Windows Forms application and am deploying that application through ClickOnce deployment. Now, I've a third-party DLL file and it has different versions for 32-bit and 64-bit OS.
Is it possible to deploy different DLL files based on the target machine (32-bit or 64-bit) through ClickOnce?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[编辑]
没有必要使用反射。您可以直接在加载程序中添加对程序的引用并启动它。在 Tech and Me< 上发表了一篇包含相关代码的博客文章< /a>.
You could include both versions in your deployment, but name them differently. Then have a loader app check if you are on a 32bit or 64bit system, copy the correct dll (eg thirdparty64.dll -> thirdparty.dll) which your real program is linked to, and then invoke your program from the loader with for example
Assembly.Load
and use reflection to start your main method.一种更简单的方法是将应用程序编译为 x86 运行,确保它始终在 32 位模式下运行。如果您不依赖于 32/64 位版本的计算机上安装的某些特定应用程序,这可能是最佳选择。
[Edit]
It's not necessary to use reflection. You can add a reference to your program directly in the loader and kick it off. Did a blog post with code about it at Tech and Me.
You could include both versions in your deployment, but name them differently. Then have a loader app check if you are on a 32bit or 64bit system, copy the correct dll (eg thirdparty64.dll -> thirdparty.dll) which your real program is linked to, and then invoke your program from the loader with for example
Assembly.Load
and use reflection to start your main method.An easier method is to compile your application to run as x86, ensuring it will always run in 32bit mode. If you don´t rely on some specific application being installed on the machine in 32/64bit versions this could be the best choice.