How to distribute both 32 and 64 bit versions of the library

倖福魔咒の 提交于 2019-12-04 01:17:42

There are several ways you can handle this. Code changes (small) are required for the first three approaches:

A. You can modify the PATH to point to the platform specific folder during application start up. Then .NET will automatically load local DLLs from that folder.

B. You can subscribe to the AssemblyResolve event and then choose the assembly based on the platform.

Check out Scott Bilias's blog post on this http://scottbilas.com/blog/automatically-choose-32-or-64-bit-mixed-mode-dlls/. Note that he ends up preferring approach A.

"In a nutshell, the solution is to trick the loader! Reference a p4dn.dll that does not exist, and use the AssemblyResolve event to intercept the load and reroute it to the correct bit size assembly."

C. Use a platform-specific set of exe.configs and the codebase element to determine assembly locations. Your setup would install the correct one based on platform.

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

D. Write two setups one for 32-bit and one for 64-bit, then only install the appropriate files for the platform.

You can load the corresponding assembly on the fly, using System.Reflection.Assembly.Load

See: http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!